cherry-pick: fix --quit not deleting CHERRY_PICK_HEAD
--quit is supposed to be --abort but without restoring HEAD. Leaving CHERRY_PICK_HEAD behind could make other commands mistake that cherry-pick is still ongoing (e.g. "git commit --amend" will refuse to work). Clean it too. For --abort, this job of deleting CHERRY_PICK_HEAD is on "git reset" so we don't need to do anything else. But let's add extra checks in --abort tests to confirm. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4dde7b8799
commit
3e7dd99208
@ -7,6 +7,7 @@
|
|||||||
#include "rerere.h"
|
#include "rerere.h"
|
||||||
#include "dir.h"
|
#include "dir.h"
|
||||||
#include "sequencer.h"
|
#include "sequencer.h"
|
||||||
|
#include "branch.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This implements the builtins revert and cherry-pick.
|
* This implements the builtins revert and cherry-pick.
|
||||||
@ -191,8 +192,12 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
|
|||||||
opts->gpg_sign = xstrdup_or_null(opts->gpg_sign);
|
opts->gpg_sign = xstrdup_or_null(opts->gpg_sign);
|
||||||
opts->strategy = xstrdup_or_null(opts->strategy);
|
opts->strategy = xstrdup_or_null(opts->strategy);
|
||||||
|
|
||||||
if (cmd == 'q')
|
if (cmd == 'q') {
|
||||||
return sequencer_remove_state(opts);
|
int ret = sequencer_remove_state(opts);
|
||||||
|
if (!ret)
|
||||||
|
remove_branch_state();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
if (cmd == 'c')
|
if (cmd == 'c')
|
||||||
return sequencer_continue(opts);
|
return sequencer_continue(opts);
|
||||||
if (cmd == 'a')
|
if (cmd == 'a')
|
||||||
|
@ -103,7 +103,8 @@ test_expect_success '--quit cleans up sequencer state' '
|
|||||||
pristine_detach initial &&
|
pristine_detach initial &&
|
||||||
test_expect_code 1 git cherry-pick base..picked &&
|
test_expect_code 1 git cherry-pick base..picked &&
|
||||||
git cherry-pick --quit &&
|
git cherry-pick --quit &&
|
||||||
test_path_is_missing .git/sequencer
|
test_path_is_missing .git/sequencer &&
|
||||||
|
test_path_is_missing .git/CHERRY_PICK_HEAD
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '--quit keeps HEAD and conflicted index intact' '
|
test_expect_success '--quit keeps HEAD and conflicted index intact' '
|
||||||
@ -132,6 +133,7 @@ test_expect_success '--abort to cancel multiple cherry-pick' '
|
|||||||
test_expect_code 1 git cherry-pick base..anotherpick &&
|
test_expect_code 1 git cherry-pick base..anotherpick &&
|
||||||
git cherry-pick --abort &&
|
git cherry-pick --abort &&
|
||||||
test_path_is_missing .git/sequencer &&
|
test_path_is_missing .git/sequencer &&
|
||||||
|
test_path_is_missing .git/CHERRY_PICK_HEAD &&
|
||||||
test_cmp_rev initial HEAD &&
|
test_cmp_rev initial HEAD &&
|
||||||
git update-index --refresh &&
|
git update-index --refresh &&
|
||||||
git diff-index --exit-code HEAD
|
git diff-index --exit-code HEAD
|
||||||
@ -142,6 +144,7 @@ test_expect_success '--abort to cancel single cherry-pick' '
|
|||||||
test_expect_code 1 git cherry-pick picked &&
|
test_expect_code 1 git cherry-pick picked &&
|
||||||
git cherry-pick --abort &&
|
git cherry-pick --abort &&
|
||||||
test_path_is_missing .git/sequencer &&
|
test_path_is_missing .git/sequencer &&
|
||||||
|
test_path_is_missing .git/CHERRY_PICK_HEAD &&
|
||||||
test_cmp_rev initial HEAD &&
|
test_cmp_rev initial HEAD &&
|
||||||
git update-index --refresh &&
|
git update-index --refresh &&
|
||||||
git diff-index --exit-code HEAD
|
git diff-index --exit-code HEAD
|
||||||
@ -162,6 +165,7 @@ test_expect_success 'cherry-pick --abort to cancel multiple revert' '
|
|||||||
test_expect_code 1 git revert base..picked &&
|
test_expect_code 1 git revert base..picked &&
|
||||||
git cherry-pick --abort &&
|
git cherry-pick --abort &&
|
||||||
test_path_is_missing .git/sequencer &&
|
test_path_is_missing .git/sequencer &&
|
||||||
|
test_path_is_missing .git/CHERRY_PICK_HEAD &&
|
||||||
test_cmp_rev anotherpick HEAD &&
|
test_cmp_rev anotherpick HEAD &&
|
||||||
git update-index --refresh &&
|
git update-index --refresh &&
|
||||||
git diff-index --exit-code HEAD
|
git diff-index --exit-code HEAD
|
||||||
@ -239,6 +243,7 @@ test_expect_success '--abort after last commit in sequence' '
|
|||||||
test_expect_code 1 git cherry-pick base..picked &&
|
test_expect_code 1 git cherry-pick base..picked &&
|
||||||
git cherry-pick --abort &&
|
git cherry-pick --abort &&
|
||||||
test_path_is_missing .git/sequencer &&
|
test_path_is_missing .git/sequencer &&
|
||||||
|
test_path_is_missing .git/CHERRY_PICK_HEAD &&
|
||||||
test_cmp_rev initial HEAD &&
|
test_cmp_rev initial HEAD &&
|
||||||
git update-index --refresh &&
|
git update-index --refresh &&
|
||||||
git diff-index --exit-code HEAD
|
git diff-index --exit-code HEAD
|
||||||
|
Loading…
Reference in New Issue
Block a user