chiark / gitweb /
Refactor output handling to break circular dependency
[stgit] / stgit / commands / diff.py
index d3e119084759110da6aa06586567cd9cba84975a..aeca4ab72a48bf1765d7d33ed9e4f5f0470ad2e1 100644 (file)
@@ -22,6 +22,7 @@ from pydoc import pager
 
 from stgit.commands.common import *
 from stgit.utils import *
 
 from stgit.commands.common import *
 from stgit.utils import *
+from stgit.out import *
 from stgit import stack, git
 
 
 from stgit import stack, git
 
 
@@ -44,9 +45,8 @@ shows the specified patch (defaulting to the current one)."""
 options = [make_option('-r', '--range',
                        metavar = 'rev1[..[rev2]]', dest = 'revs',
                        help = 'show the diff between revisions'),
 options = [make_option('-r', '--range',
                        metavar = 'rev1[..[rev2]]', dest = 'revs',
                        help = 'show the diff between revisions'),
-           make_option('--binary',
-                       help = 'output a diff even for binary files',
-                       action = 'store_true'),
+           make_option('-O', '--diff-opts',
+                       help = 'options to pass to git-diff'),
            make_option('-s', '--stat',
                        help = 'show the stat instead of the diff',
                        action = 'store_true')]
            make_option('-s', '--stat',
                        help = 'show the stat instead of the diff',
                        action = 'store_true')]
@@ -79,10 +79,15 @@ def func(parser, options, args):
         rev1 = 'HEAD'
         rev2 = None
 
         rev1 = 'HEAD'
         rev2 = None
 
+    if options.diff_opts:
+        diff_flags = options.diff_opts.split()
+    else:
+        diff_flags = []
+
     if options.stat:
     if options.stat:
-        print git.diffstat(args, git_id(rev1), git_id(rev2))
+        out.stdout_raw(git.diffstat(args, git_id(rev1), git_id(rev2)) + '\n')
     else:
         diff_str = git.diff(args, git_id(rev1), git_id(rev2),
     else:
         diff_str = git.diff(args, git_id(rev1), git_id(rev2),
-                            binary = options.binary)
+                            diff_flags = diff_flags )
         if diff_str:
             pager(diff_str)
         if diff_str:
             pager(diff_str)