Re: Stacked GIT 0.3 (now more Quilt-like)
- From
- Peter Osterlund <petero2@telia.com>
- Date
- Jul 8, 2005, 08:14 UTC
- Message-ID
- <m3d5ptlnoi.fsf@telia.com>
- In-Reply-To
- <7vk6k2dr8i.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 11 quoted lines
> >>>>> "PO" == Peter Osterlund <petero2@telia.com> writes: > > PO> I think it would be good if it was possible to include diffstat output > PO> in exported patches, something like this: > > PO> Added possibility to include diffstat output in exported patches. > > And you wuold want to do things similarly to what others have > already done. git-resolve-script uses "git-apply --stat" there, > instead of "diffstat", so people without diffstat installed can > still get the same information.
Thanks for the hint. Here is a replacement patch that uses git-apply instead.
Added possibility to include diffstat output in exported patches.
Signed-off-by: Peter Osterlund <petero2@telia.com> ---
stgit/git.py | 23 +++++++++++++++++++++++ stgit/main.py | 2 ++ 2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/stgit/git.py b/stgit/git.py --- a/stgit/git.py +++ b/stgit/git.py @@ -345,6 +345,29 @@ def diff(files = [], rev1 = 'HEAD', rev2 % (rev1, files_str, extra_args)) != 0: raise GitException, 'git-diff-cache failed' +def diffstat(files = [], rev1 = 'HEAD', rev2 = None): + """Return the diffstat between rev1 and rev2 + """ + files_str = reduce(lambda x, y: x + ' ' + y, files, '') + + os.system('git-update-cache --refresh > /dev/null') + ds_cmd = '| git-apply --stat --summary' + + if rev2: + f = os.popen('git-diff-tree -p %s %s %s %s' + % (rev1, rev2, files_str, ds_cmd), 'r') + str = f.read() + if f.close(): + raise GitException, 'git-diff-tree failed' + return str + else: + f = os.popen('git-diff-cache -p %s %s %s' + % (rev1, files_str, ds_cmd), 'r') + str = f.read() + if f.close(): + raise GitException, 'git-diff-cache failed' + return str + def checkout(files = [], force = False): """Check out the given or all files """ diff --git a/stgit/main.py b/stgit/main.py --- a/stgit/main.py +++ b/stgit/main.py @@ -659,6 +659,8 @@ def export(parser, options, args): patch = crt_series.get_patch(p) tmpl_dict = {'description': patch.get_description().rstrip(), + 'diffstat': git.diffstat(rev1 = __git_id('%s/bottom' % p), + rev2 = __git_id('%s/top' % p)), 'authname': patch.get_authname(), 'authemail': patch.get_authemail(), 'authdate': patch.get_authdate(),
-- Peter Osterlund - petero2@telia.com http://web.telia.com/~u89404340