summaryrefslogtreecommitdiff
path: root/builtin/revert.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2011-12-10 12:59:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-12-12 21:32:16 (GMT)
commit7acaaac275a1d338f7b2540779b7ea60f3f0667c (patch)
treed7319ca691bcd52b37d71603988dd1107c2dda4c /builtin/revert.c
parent7f13334e074bb053eccd14787e416306bc4b413a (diff)
downloadgit-7acaaac275a1d338f7b2540779b7ea60f3f0667c.zip
git-7acaaac275a1d338f7b2540779b7ea60f3f0667c.tar.gz
git-7acaaac275a1d338f7b2540779b7ea60f3f0667c.tar.bz2
revert: allow single-pick in the middle of cherry-pick sequence
After messing up a difficult conflict resolution in the middle of a cherry-pick sequence, it can be useful to be able to git checkout HEAD . && git cherry-pick that-one-commit to restart the conflict resolution. The current code however errors out saying that another cherry-pick is already in progress. Suggested-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/revert.c')
-rw-r--r--builtin/revert.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/builtin/revert.c b/builtin/revert.c
index f7f4bb3..5785ff9 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -1072,6 +1072,12 @@ static int sequencer_continue(struct replay_opts *opts)
return pick_commits(todo_list, opts);
}
+static int single_pick(struct commit *cmit, struct replay_opts *opts)
+{
+ setenv(GIT_REFLOG_ACTION, action_name(opts), 0);
+ return do_pick_commit(cmit, opts);
+}
+
static int pick_revisions(struct replay_opts *opts)
{
struct commit_list *todo_list = NULL;
@@ -1097,6 +1103,26 @@ static int pick_revisions(struct replay_opts *opts)
return sequencer_continue(opts);
/*
+ * If we were called as "git cherry-pick <commit>", just
+ * cherry-pick/revert it, set CHERRY_PICK_HEAD /
+ * REVERT_HEAD, and don't touch the sequencer state.
+ * This means it is possible to cherry-pick in the middle
+ * of a cherry-pick sequence.
+ */
+ if (opts->revs->cmdline.nr == 1 &&
+ opts->revs->cmdline.rev->whence == REV_CMD_REV &&
+ opts->revs->no_walk &&
+ !opts->revs->cmdline.rev->flags) {
+ struct commit *cmit;
+ if (prepare_revision_walk(opts->revs))
+ die(_("revision walk setup failed"));
+ cmit = get_revision(opts->revs);
+ if (!cmit || get_revision(opts->revs))
+ die("BUG: expected exactly one commit from walk");
+ return single_pick(cmit, opts);
+ }
+
+ /*
* Start a new cherry-pick/ revert sequence; but
* first, make sure that an existing one isn't in
* progress