From: Catalin Marinas Date: Wed, 22 Nov 2006 20:14:57 +0000 (+0000) Subject: Allow 'show' to display many patches X-Git-Tag: v0.14.3~412 X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/commitdiff_plain/7c47eea5bf3e1af67b06417fa2fbda093b7e8c37 Allow 'show' to display many patches The show command should be allowed to display more than one patch. Signed-off-by: Catalin Marinas --- diff --git a/stgit/commands/show.py b/stgit/commands/show.py index a3169b9..5c297c0 100644 --- a/stgit/commands/show.py +++ b/stgit/commands/show.py @@ -24,25 +24,40 @@ from stgit import git help = 'show the commit corresponding to a patch (or the current patch)' -usage = """%prog [options] [] +usage = """%prog [options] [] [] [..] -Show the commit log and the diff corresponding to a given patch. The -output is similar to that generated by the 'git show' command.""" +Show the commit log and the diff corresponding to the given +patches. The output is similar to that generated by the 'git show' +command.""" -options = [] +options = [make_option('-a', '--applied', + help = 'show the applied patches', + action = 'store_true'), + make_option('-u', '--unapplied', + help = 'show the unapplied patches', + action = 'store_true')] def func(parser, options, args): """Show commit log and diff """ - if len(args) == 0: - patch = 'HEAD' - elif len(args) == 1: - patch = args[0] + if options.applied: + patches = crt_series.get_applied() + elif options.unapplied: + patches = crt_series.get_unapplied() + elif len(args) == 0: + patches = ['HEAD'] else: - parser.error('incorrect number of arguments') - - commit_id = git_id(patch) - commit_str = git.pretty_commit(commit_id) + if len(args) == 1 and args[0].find('..') == -1 \ + and not crt_series.patch_exists(args[0]): + # it might be just a commit id + patches = args + else: + patches = parse_patches(args, crt_series.get_applied() + + crt_series.get_unapplied()) + + commit_ids = [git_id(patch) for patch in patches] + commit_str = '\n'.join([git.pretty_commit(commit_id) + for commit_id in commit_ids]) if commit_str: pager(commit_str)