revert: introduce --abort to cancel a failed cherry-pick
After running some ill-advised command like "git cherry-pick
HEAD..linux-next", the bewildered novice may want to return to more
familiar territory. Introduce a "git cherry-pick --abort" command
that rolls back the entire cherry-pick sequence and places the
repository back on solid ground.
Just like "git merge --abort", this internally uses "git reset
--merge", so local changes not involved in the conflict resolution are
preserved.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Jonathan Nieder13 years agocommitted byJunio C Hamano
@ -75,6 +83,11 @@ test_expect_success '--quit does not complain when no cherry-pick is in progress
@@ -75,6 +83,11 @@ test_expect_success '--quit does not complain when no cherry-pick is in progress
git cherry-pick --quit
'
test_expect_success '--abort requires cherry-pick in progress' '
pristine_detach initial &&
test_must_fail git cherry-pick --abort
'
test_expect_success '--quit cleans up sequencer state' '
pristine_detach initial &&
test_must_fail git cherry-pick base..picked &&
@ -103,6 +116,79 @@ test_expect_success 'cherry-pick --reset (another name for --quit)' '
@@ -103,6 +116,79 @@ test_expect_success 'cherry-pick --reset (another name for --quit)' '
test_cmp expect actual
'
test_expect_success '--abort to cancel multiple cherry-pick' '
test_expect_success 'cherry-pick cleans up sequencer state when one commit is left' '
pristine_detach initial &&
test_must_fail git cherry-pick base..picked &&
@ -127,6 +213,16 @@ test_expect_success 'cherry-pick cleans up sequencer state when one commit is le
@@ -127,6 +213,16 @@ test_expect_success 'cherry-pick cleans up sequencer state when one commit is le
test_cmp expect actual
'
test_expect_failure '--abort after last commit in sequence' '
pristine_detach initial &&
test_must_fail git cherry-pick base..picked &&
git cherry-pick --abort &&
test_path_is_missing .git/sequencer &&
test_cmp_rev initial HEAD &&
git update-index --refresh &&
git diff-index --exit-code HEAD
'
test_expect_success 'cherry-pick does not implicitly stomp an existing operation' '