From 641d287da88f80171cce28d14fa06f139e40c177 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Wed, 28 Jan 2009 23:01:24 +0000 Subject: [PATCH] Pass the diff flags when statistics are required 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 --- stgit/commands/files.py | 13 +++++++------ stgit/commands/mail.py | 11 +++++++++-- stgit/git.py | 5 +++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/stgit/commands/files.py b/stgit/commands/files.py index cc9ed30..af772b8 100644 --- a/stgit/commands/files.py +++ b/stgit/commands/files.py @@ -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') diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py index 05c905b..2230d2a 100644 --- a/stgit/commands/mail.py +++ b/stgit/commands/mail.py @@ -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, diff --git a/stgit/git.py b/stgit/git.py index 35579d4..ea94ecc 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -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 -- 2.11.0