help = 'send a patch or series of patches by e-mail'
-usage = """%prog [options] [<patch1>] [<patch2>] [<patch3>..<patch4>]
+usage = r"""%prog [options] [<patch1>] [<patch2>] [<patch3>..<patch4>]
Send a patch or a range of patches by e-mail using the SMTP server
specified by the 'stgit.smtpserver' configuration option, or the
%(commemail)s - committer's e-mail
%(commname)s - committer's name
%(diff)s - unified diff of the patch
- %(fromauth)s - 'From: author\\n\\n' if different from sender
+ %(fromauth)s - 'From: author\n\n' if different from sender
%(longdescr)s - the rest of the patch description, after the first line
%(patch)s - patch name
%(prefix)s - 'prefix ' string passed on the command line
action = 'store_true'),
make_option('-b', '--branch',
help = 'use BRANCH instead of the default one'),
- make_option('-O', '--diff-opts',
- help = 'options to pass to git-diff'),
make_option('-m', '--mbox',
help = 'generate an mbox file instead of sending',
- action = 'store_true')]
+ action = 'store_true')
+ ] + make_diff_opts_option()
def __get_sender():
'number': number_str,
'shortlog': stack.shortlog(crt_series.get_patch(p)
for p in patches),
- 'diffstat': git.diffstat(
+ 'diffstat': git.diffstat(git.diff(
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])))}
try:
msg_string = tmpl % tmpl_dict
"""
p = crt_series.get_patch(patch)
- descr = p.get_description().strip()
- descr_lines = descr.split('\n')
+ if p.get_description():
+ descr = p.get_description().strip()
+ else:
+ # provide a place holder and force the edit message option on
+ descr = '<empty message>'
+ options.edit_patches = True
+ descr_lines = descr.split('\n')
short_descr = descr_lines[0].rstrip()
long_descr = '\n'.join(descr_lines[1:]).lstrip()
prefix_str = confprefix + ' '
else:
prefix_str = ''
-
- if options.diff_opts:
- diff_flags = options.diff_opts.split()
- else:
- diff_flags = []
total_nr_str = str(total_nr)
patch_nr_str = str(patch_nr).zfill(len(total_nr_str))
else:
number_str = ''
+ diff = git.diff(rev1 = git_id(crt_series, '%s//bottom' % patch),
+ rev2 = git_id(crt_series, '%s//top' % patch),
+ diff_flags = options.diff_flags)
tmpl_dict = {'patch': patch,
'sender': sender,
# for backward template compatibility
'longdescr': long_descr,
# for backward template compatibility
'endofheaders': '',
- 'diff': git.diff(
- rev1 = git_id(crt_series, '%s//bottom' % patch),
- rev2 = git_id(crt_series, '%s//top' % patch),
- diff_flags = diff_flags),
- 'diffstat': git.diffstat(
- rev1 = git_id(crt_series, '%s//bottom'%patch),
- rev2 = git_id(crt_series, '%s//top' % patch)),
+ 'diff': diff,
+ 'diffstat': git.diffstat(diff),
# for backward template compatibility
'date': '',
'version': version_str,