From: Junio C Hamano Date: Mon, 20 Aug 2018 19:41:34 +0000 (-0700) Subject: Merge branch 'nd/cherry-pick-quit-fix' X-Git-Tag: v2.19.0-rc0~3 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/39e415cfd1390ed31a61ca0ca175530302c9a58c?hp=-c Merge branch 'nd/cherry-pick-quit-fix' "git cherry-pick --quit" failed to remove CHERRY_PICK_HEAD even though we won't be in a cherry-pick session after it returns, which has been corrected. * nd/cherry-pick-quit-fix: cherry-pick: fix --quit not deleting CHERRY_PICK_HEAD --- 39e415cfd1390ed31a61ca0ca175530302c9a58c diff --combined builtin/revert.c index 76f0a35b07,baf1cd70d1..9a66720cfc --- a/builtin/revert.c +++ b/builtin/revert.c @@@ -7,6 -7,7 +7,7 @@@ #include "rerere.h" #include "dir.h" #include "sequencer.h" + #include "branch.h" /* * This implements the builtins revert and cherry-pick. @@@ -191,8 -192,12 +192,12 @@@ static int run_sequencer(int argc, cons opts->gpg_sign = xstrdup_or_null(opts->gpg_sign); opts->strategy = xstrdup_or_null(opts->strategy); - if (cmd == 'q') - return sequencer_remove_state(opts); + if (cmd == 'q') { + int ret = sequencer_remove_state(opts); + if (!ret) + remove_branch_state(); + return ret; + } if (cmd == 'c') return sequencer_continue(opts); if (cmd == 'a') @@@ -208,7 -213,7 +213,7 @@@ int cmd_revert(int argc, const char **a if (isatty(0)) opts.edit = 1; opts.action = REPLAY_REVERT; - git_config(git_default_config, NULL); + sequencer_init_config(&opts); res = run_sequencer(argc, argv, &opts); if (res < 0) die(_("revert failed")); @@@ -221,7 -226,7 +226,7 @@@ int cmd_cherry_pick(int argc, const cha int res; opts.action = REPLAY_PICK; - git_config(git_default_config, NULL); + sequencer_init_config(&opts); res = run_sequencer(argc, argv, &opts); if (res < 0) die(_("cherry-pick failed")); diff --combined t/t3510-cherry-pick-sequence.sh index 3505b6aa14,d2d87b0e6c..c84eeefdc9 --- a/t/t3510-cherry-pick-sequence.sh +++ b/t/t3510-cherry-pick-sequence.sh @@@ -103,7 -103,8 +103,8 @@@ test_expect_success '--quit cleans up s pristine_detach initial && test_expect_code 1 git cherry-pick base..picked && 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' ' @@@ -122,7 -123,7 +123,7 @@@ { git rev-list HEAD | git diff-tree --root --stdin | - sed "s/$_x40/OBJID/g" + sed "s/$OID_REGEX/OBJID/g" } >actual && test_cmp expect actual ' @@@ -132,6 -133,7 +133,7 @@@ test_expect_success '--abort to cancel test_expect_code 1 git cherry-pick base..anotherpick && git cherry-pick --abort && test_path_is_missing .git/sequencer && + test_path_is_missing .git/CHERRY_PICK_HEAD && test_cmp_rev initial HEAD && git update-index --refresh && git diff-index --exit-code HEAD @@@ -142,6 -144,7 +144,7 @@@ test_expect_success '--abort to cancel test_expect_code 1 git cherry-pick picked && git cherry-pick --abort && test_path_is_missing .git/sequencer && + test_path_is_missing .git/CHERRY_PICK_HEAD && test_cmp_rev initial HEAD && git update-index --refresh && git diff-index --exit-code HEAD @@@ -162,6 -165,7 +165,7 @@@ test_expect_success 'cherry-pick --abor test_expect_code 1 git revert base..picked && git cherry-pick --abort && test_path_is_missing .git/sequencer && + test_path_is_missing .git/CHERRY_PICK_HEAD && test_cmp_rev anotherpick HEAD && git update-index --refresh && git diff-index --exit-code HEAD @@@ -220,7 -224,7 +224,7 @@@ test_expect_success 'cherry-pick still { git rev-list HEAD | git diff-tree --root --stdin | - sed "s/$_x40/OBJID/g" + sed "s/$OID_REGEX/OBJID/g" } >actual && cat >expect <<-\EOF && OBJID @@@ -239,6 -243,7 +243,7 @@@ test_expect_success '--abort after las test_expect_code 1 git cherry-pick base..picked && git cherry-pick --abort && test_path_is_missing .git/sequencer && + test_path_is_missing .git/CHERRY_PICK_HEAD && test_cmp_rev initial HEAD && git update-index --refresh && git diff-index --exit-code HEAD @@@ -247,9 -252,9 +252,9 @@@ test_expect_success 'cherry-pick does not implicitly stomp an existing operation' ' pristine_detach initial && test_expect_code 1 git cherry-pick base..anotherpick && - test-chmtime -v +0 .git/sequencer >expect && + test-tool chmtime --get .git/sequencer >expect && test_expect_code 128 git cherry-pick unrelatedpick && - test-chmtime -v +0 .git/sequencer >actual && + test-tool chmtime --get .git/sequencer >actual && test_cmp expect actual ' @@@ -317,7 -322,7 +322,7 @@@ test_expect_success '--continue after r { git rev-list HEAD | git diff-tree --root --stdin | - sed "s/$_x40/OBJID/g" + sed "s/$OID_REGEX/OBJID/g" } >actual.log && test_cmp expect foo && test_cmp expect.log actual.log @@@ -334,7 -339,7 +339,7 @@@ test_expect_success '--continue after r { git rev-list HEAD | git diff-tree --root --stdin | - sed "s/$_x40/OBJID/g" + sed "s/$OID_REGEX/OBJID/g" } >actual && cat >expect <<-\EOF && OBJID @@@ -480,16 -485,11 +485,16 @@@ test_expect_success 'malformed instruct test_expect_code 128 git cherry-pick --continue ' -test_expect_success 'empty commit set' ' +test_expect_success 'empty commit set (no commits to walk)' ' pristine_detach initial && test_expect_code 128 git cherry-pick base..base ' +test_expect_success 'empty commit set (culled during walk)' ' + pristine_detach initial && + test_expect_code 128 git cherry-pick -2 --author=no.such.author base +' + test_expect_success 'malformed instruction sheet 3' ' pristine_detach initial && test_expect_code 1 git cherry-pick base..anotherpick &&