This patch renames --reverse to --revert and sets the picked patch
message similar to the "git revert" command.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
Import one or more patches from a different branch or a commit object
into the current series. By default, the name of the imported patch is
used as the name of the current patch. It can be overridden with the
Import one or more patches from a different branch or a commit object
into the current series. By default, the name of the imported patch is
used as the name of the current patch. It can be overridden with the
-'--name' option. A commit object can be reverted with the '--reverse'
+'--name' option. A commit object can be reverted with the '--revert'
option. The log and author information are those of the commit
object."""
option. The log and author information are those of the commit
object."""
short = 'Use NAME as the patch name'),
opt('-B', '--ref-branch', args = [argparse.stg_branches],
short = 'Pick patches from BRANCH'),
short = 'Use NAME as the patch name'),
opt('-B', '--ref-branch', args = [argparse.stg_branches],
short = 'Pick patches from BRANCH'),
- opt('-r', '--reverse', action = 'store_true',
- short = 'Reverse the commit object before importing'),
+ opt('-r', '--revert', action = 'store_true',
+ short = 'Revert the given commit object'),
opt('-p', '--parent', metavar = 'COMMITID', args = [argparse.commit],
short = 'Use COMMITID as parent'),
opt('-x', '--expose', action = 'store_true',
opt('-p', '--parent', metavar = 'COMMITID', args = [argparse.commit],
short = 'Use COMMITID as parent'),
opt('-x', '--expose', action = 'store_true',
if options.name:
patchname = options.name
if options.name:
patchname = options.name
+ elif patchname and options.revert:
+ patchname = 'revert-' + patchname
if patchname:
patchname = find_patch_name(patchname, crt_series.patch_exists)
if patchname:
patchname = find_patch_name(patchname, crt_series.patch_exists)
else:
parent = commit.get_parent()
else:
parent = commit.get_parent()
- if not options.reverse:
bottom = parent
top = commit_id
else:
bottom = parent
top = commit_id
else:
out.done()
else:
message = commit.get_log()
out.done()
else:
message = commit.get_log()
+ if options.revert:
+ if message:
+ subject = message.splitlines()[0]
+ else:
+ subject = commit.get_id_hash()
+ message = 'Revert "%s"\n\nThis reverts commit %s.\n' \
+ % (subject, commit.get_id_hash())
+ elif options.expose:
message += '(imported from commit %s)\n' % commit.get_id_hash()
author_name, author_email, author_date = \
name_email_date(commit.get_author())
message += '(imported from commit %s)\n' % commit.get_id_hash()
author_name, author_email, author_date = \
name_email_date(commit.get_author())
- 'Pick --fold --reverse local patch' \
+ 'Pick --fold --revert local patch' \
- stg pick --fold --reverse D &&
+ stg pick --fold --revert D &&
stg refresh && stg clean &&
test "$(echo $(stg series --applied --noprefix))" = "A B C" &&
test "$(echo $(stg series --unapplied --noprefix))" = "D"
stg refresh && stg clean &&
test "$(echo $(stg series --applied --noprefix))" = "A B C" &&
test "$(echo $(stg series --unapplied --noprefix))" = "D"