[PATCH 3/4] Make diff flags handling more modular.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Signed-off-by: Yann Dirson <ydirson@xxxxxxxxxx>
---

 stgit/commands/diff.py   |    7 ++++++-
 stgit/commands/export.py |    8 +++++++-
 stgit/commands/mail.py   |    7 ++++++-
 stgit/git.py             |   12 ++++--------
 4 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/stgit/commands/diff.py b/stgit/commands/diff.py
index f56cbeb..b66c75b 100644
--- a/stgit/commands/diff.py
+++ b/stgit/commands/diff.py
@@ -79,10 +79,15 @@ def func(parser, options, args):
         rev1 = 'HEAD'
         rev2 = None
 
+    if options.binary:
+        diff_flags = [ '--binary' ]
+    else:
+        diff_flags = []
+
     if options.stat:
         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),
-                            binary = options.binary)
+                            diff_flags = diff_flags )
         if diff_str:
             pager(diff_str)
diff --git a/stgit/commands/export.py b/stgit/commands/export.py
index cafcbe3..d6b36a9 100644
--- a/stgit/commands/export.py
+++ b/stgit/commands/export.py
@@ -87,6 +87,11 @@ def func(parser, options, args):
             os.makedirs(dirname)
         series = file(os.path.join(dirname, 'series'), 'w+')
 
+    if options.binary:
+        diff_flags = [ '--binary' ]
+    else:
+        diff_flags = []
+
     applied = crt_series.get_applied()
     if len(args) != 0:
         patches = parse_patches(args, applied)
@@ -175,7 +180,8 @@ def func(parser, options, args):
         # write the diff
         git.diff(rev1 = patch.get_bottom(),
                  rev2 = patch.get_top(),
-                 out_fd = f, binary = options.binary)
+                 out_fd = f,
+                 diff_flags = diff_flags )
         if not options.stdout:
             f.close()
         patch_no += 1
diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py
index b95014c..7113cff 100644
--- a/stgit/commands/mail.py
+++ b/stgit/commands/mail.py
@@ -377,6 +377,11 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options):
     else:
         prefix_str = ''
         
+    if options.binary:
+        diff_flags = [ '--binary' ]
+    else:
+        diff_flags = []
+
     total_nr_str = str(total_nr)
     patch_nr_str = str(patch_nr).zfill(len(total_nr_str))
     if total_nr > 1:
@@ -394,7 +399,7 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options):
                  'endofheaders': '',
                  'diff':         git.diff(rev1 = git_id('%s//bottom' % patch),
                                           rev2 = git_id('%s//top' % patch),
-                                          binary = options.binary),
+                                          diff_flags = diff_flags ),
                  'diffstat':     git.diffstat(rev1 = git_id('%s//bottom'%patch),
                                               rev2 = git_id('%s//top' % patch)),
                  # for backward template compatibility
diff --git a/stgit/git.py b/stgit/git.py
index 5cdc8cd..7358fae 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -770,27 +770,23 @@ def status(files = None, modified = False, new = False, deleted = False,
             out.stdout('%s' % fs[1])
 
 def diff(files = None, rev1 = 'HEAD', rev2 = None, out_fd = None,
-         binary = False):
+         diff_flags = []):
     """Show the diff between rev1 and rev2
     """
     if not files:
         files = []
 
-    args = []
-    if binary:
-        args.append('--binary')
-
     if rev1 and rev2:
-        diff_str = _output(['git-diff-tree', '-p'] + args
+        diff_str = _output(['git-diff-tree', '-p'] + diff_flags
                            + [rev1, rev2, '--'] + files)
     elif rev1 or rev2:
         refresh_index()
         if rev2:
             diff_str = _output(['git-diff-index', '-p', '-R']
-                               + args + [rev2, '--'] + files)
+                               + diff_flags + [rev2, '--'] + files)
         else:
             diff_str = _output(['git-diff-index', '-p']
-                               + args + [rev1, '--'] + files)
+                               + diff_flags + [rev1, '--'] + files)
     else:
         diff_str = ''
 

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux