+options = [make_option('-b', '--branch',
+ help = 'use BRANCH instead of the default one'),
+ make_option('-a', '--all',
+ help = 'show all patches, including the hidden ones',
+ action = 'store_true'),
+ make_option('-i', '--invisible',
+ help = 'show the hidden patches only',
+ action = 'store_true'),
+ make_option('-m', '--missing', metavar = 'BRANCH',
+ help = 'show patches in BRANCH missing in current'),
+ make_option('-c', '--count',
+ help = 'print the number of patches in the series',
+ action = 'store_true'),
+ make_option('-d', '--description',
+ help = 'show a short description for each patch',
+ action = 'store_true'),
+ make_option('-e', '--empty',
+ help = 'check whether patches are empty '
+ '(much slower)',
+ action = 'store_true'),
+ make_option('--showbranch',
+ help = 'append the branch name to the listed patches',
+ action = 'store_true'),
+ make_option('--noprefix',
+ help = 'do not show the patch status prefix',
+ action = 'store_true'),
+ make_option('-s', '--short',
+ help = 'list just the patches around the topmost patch',
+ action = 'store_true'),
+ make_option('-g', '--graphical',
+ help = 'run gitk instead of printing',
+ action = 'store_true')]
+
+
+def __get_description(patch):
+ """Extract and return a patch's short description
+ """
+ p = crt_series.get_patch(patch)
+ descr = (p.get_description() or '').strip()
+ descr_lines = descr.split('\n')
+ return descr_lines[0].rstrip()
+
+def __print_patch(patch, hidden, branch_str, prefix, empty_prefix, length,
+ options):
+ """Print a patch name, description and various markers.
+ """
+ if options.noprefix:
+ prefix = ''
+ elif options.empty and crt_series.empty_patch(patch):
+ prefix = empty_prefix
+
+ patch_str = patch + branch_str
+ if not options.noprefix and patch in hidden:
+ patch_str += '*'
+
+ if options.description:
+ print prefix + patch_str.ljust(length) + ' | ' \
+ + __get_description(patch)
+ else:
+ print prefix + patch_str