help = 'show the commit corresponding to a patch (or the current patch)'
-usage = """%prog [options] [<patch>]
+usage = """%prog [options] [<patch1>] [<patch2>] [<patch3>..<patch4>]
-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'),
+ make_option('-O', '--diff-opts',
+ help = 'options to pass to git-diff')]
def func(parser, options, args):
"""Show commit log and diff
"""
- if len(args) == 0:
- patch = 'HEAD'
- elif len(args) == 1:
- patch = args[0]
+ applied = crt_series.get_applied()
+ unapplied = crt_series.get_unapplied()
+
+ if options.applied:
+ patches = applied
+ elif options.unapplied:
+ patches = unapplied
+ elif len(args) == 0:
+ patches = ['HEAD']
+ else:
+ 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, applied + unapplied, len(applied))
+
+ if options.diff_opts:
+ diff_flags = options.diff_opts.split()
else:
- parser.error('incorrect number of arguments')
+ diff_flags = []
- commit_id = git_id(patch)
- commit_str = git.pretty_commit(commit_id)
+ commit_ids = [git_id(patch) for patch in patches]
+ commit_str = '\n'.join([git.pretty_commit(commit_id, diff_flags=diff_flags)
+ for commit_id in commit_ids])
if commit_str:
pager(commit_str)