Pass the diff flags when statistics are required
authorCatalin Marinas <catalin.marinas@gmail.com>
Wed, 28 Jan 2009 23:01:24 +0000 (23:01 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Wed, 28 Jan 2009 23:01:24 +0000 (23:01 +0000)
The --diff-opts were not passed to git.diff() calls when the statistics
were required for the mail and files commands.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/files.py
stgit/commands/mail.py
stgit/git.py

index cc9ed30..af772b8 100644 (file)
@@ -57,17 +57,18 @@ def func(parser, options, args):
     else:
         parser.error('incorrect number of arguments')
 
+    if options.diff_opts:
+        diff_flags = options.diff_opts.split()
+    else:
+        diff_flags = []
+
     rev1 = git_id(crt_series, '%s//bottom' % patch)
     rev2 = git_id(crt_series, '%s//top' % patch)
 
     if options.stat:
-        out.stdout_raw(git.diffstat(rev1 = rev1, rev2 = rev2) + '\n')
+        out.stdout_raw(git.diffstat(rev1 = rev1, rev2 = rev2,
+                                    diff_flags = diff_flags) + '\n')
     elif options.bare:
         out.stdout_raw(git.barefiles(rev1, rev2) + '\n')
     else:
-        if options.diff_opts:
-            diff_flags = options.diff_opts.split()
-        else:
-            diff_flags = []
-
         out.stdout_raw(git.files(rev1, rev2, diff_flags = diff_flags) + '\n')
index 05c905b..2230d2a 100644 (file)
@@ -347,6 +347,11 @@ def __build_cover(tmpl, patches, msg_id, options):
     else:
         number_str = ''
 
+    if options.diff_opts:
+        diff_flags = options.diff_opts.split()
+    else:
+        diff_flags = []
+
     tmpl_dict = {'sender':       sender,
                  # for backward template compatibility
                  'maintainer':   sender,
@@ -363,7 +368,8 @@ def __build_cover(tmpl, patches, msg_id, options):
                                                 for p in patches),
                  'diffstat':     git.diffstat(
                      rev1 = git_id(crt_series, '%s//bottom' % patches[0]),
-                     rev2 = git_id(crt_series, '%s//top' % patches[-1]))}
+                     rev2 = git_id(crt_series, '%s//top' % patches[-1]),
+                     diff_flags = diff_flags)}
 
     try:
         msg_string = tmpl % tmpl_dict
@@ -458,7 +464,8 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options):
                      diff_flags = diff_flags),
                  'diffstat':     git.diffstat(
                      rev1 = git_id(crt_series, '%s//bottom'%patch),
-                     rev2 = git_id(crt_series, '%s//top' % patch)),
+                     rev2 = git_id(crt_series, '%s//top' % patch),
+                     diff_flags = diff_flags),
                  # for backward template compatibility
                  'date':         '',
                  'version':      version_str,
index 35579d4..ea94ecc 100644 (file)
@@ -821,10 +821,11 @@ def diff(files = None, rev1 = 'HEAD', rev2 = None, diff_flags = [],
 
 # TODO: take another parameter representing a diff string as we
 # usually invoke git.diff() form the calling functions
-def diffstat(files = None, rev1 = 'HEAD', rev2 = None):
+def diffstat(files = None, rev1 = 'HEAD', rev2 = None, diff_flags = []):
     """Return the diffstat between rev1 and rev2."""
     return GRun('apply', '--stat', '--summary'
-                ).raw_input(diff(files, rev1, rev2)).raw_output()
+               ).raw_input(diff(files, rev1, rev2, diff_flags = diff_flags)
+                          ).raw_output()
 
 def files(rev1, rev2, diff_flags = []):
     """Return the files modified between rev1 and rev2