summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7f13334)
raw | patch | inline | side by side (parent: 7f13334)
author | Jonathan Nieder <jrnieder@gmail.com> | |
Sat, 10 Dec 2011 12:59:48 +0000 (06:59 -0600) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 12 Dec 2011 21:32:16 +0000 (13:32 -0800) |
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>
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>
builtin/revert.c | patch | blob | history | |
t/t3510-cherry-pick-sequence.sh | patch | blob | history |
diff --git a/builtin/revert.c b/builtin/revert.c
index f7f4bb35774db6445348b41c61dd2c27883d2381..5785ff9941e698eee7b6e480676a411d52076078 100644 (file)
--- a/builtin/revert.c
+++ b/builtin/revert.c
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;
if (opts->subcommand == REPLAY_CONTINUE)
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
index 56c95ec18c5061ef8ac760503dd6fd16f72779c3..98a27a23eaa22231ac33b0a32b6a18a1aa54b500 100755 (executable)
test_path_is_file .git/sequencer/opts
'
+test_expect_success 'cherry-pick mid-cherry-pick-sequence' '
+ pristine_detach initial &&
+ test_must_fail git cherry-pick base..anotherpick &&
+ test_cmp_rev picked CHERRY_PICK_HEAD &&
+ # "oops, I forgot that these patches rely on the change from base"
+ git checkout HEAD foo &&
+ git cherry-pick base &&
+ git cherry-pick picked &&
+ git cherry-pick --continue &&
+ git diff --exit-code anotherpick
+'
+
test_expect_success 'cherry-pick persists opts correctly' '
pristine_detach initial &&
test_must_fail git cherry-pick -s -m 1 --strategy=recursive -X patience -X ours base..anotherpick &&