Skip to content

Commit 218b65f

Browse files
jrngitster
authored andcommitted
revert: do not remove state until sequence is finished
As v1.7.8-rc0~141^2~4 (2011-08-04) explains, git cherry-pick removes the sequencer state just before applying the final patch. In the single-pick case, that was a good thing, since --abort and --continue work fine without access to such state and removing it provides a signal that git should not complain about the need to clobber it ("a cherry-pick or revert is already in progress") in sequences like the following: git cherry-pick foo git read-tree -m -u HEAD; # forget that; let's try a different one git cherry-pick bar After the recent patch "allow single-pick in the middle of cherry-pick sequence" we don't need that hack any more. In the new regime, a traditional "git cherry-pick <commit>" command never looks at .git/sequencer, so we do not need to cripple "git cherry-pick <commit>..<commit>" for it any more. So now you can run "git cherry-pick --abort" near the end of a multi-pick sequence and it will abort the entire sequence, instead of misbehaving and aborting just the final commit. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7acaaac commit 218b65f

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

builtin/revert.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,18 +1018,8 @@ static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts)
10181018
for (cur = todo_list; cur; cur = cur->next) {
10191019
save_todo(cur, opts);
10201020
res = do_pick_commit(cur->item, opts);
1021-
if (res) {
1022-
if (!cur->next)
1023-
/*
1024-
* An error was encountered while
1025-
* picking the last commit; the
1026-
* sequencer state is useless now --
1027-
* the user simply needs to resolve
1028-
* the conflict and commit
1029-
*/
1030-
remove_sequencer_state(0);
1021+
if (res)
10311022
return res;
1032-
}
10331023
}
10341024

10351025
/*

t/t3510-cherry-pick-sequence.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ test_expect_success '--abort refuses to clobber unrelated change, harder case' '
203203
test_cmp_rev initial HEAD
204204
'
205205

206-
test_expect_success 'cherry-pick cleans up sequencer state when one commit is left' '
206+
test_expect_success 'cherry-pick still writes sequencer state when one commit is left' '
207207
pristine_detach initial &&
208208
test_must_fail git cherry-pick base..picked &&
209-
test_path_is_missing .git/sequencer &&
209+
test_path_is_dir .git/sequencer &&
210210
echo "resolved" >foo &&
211211
git add foo &&
212212
git commit &&
@@ -227,7 +227,7 @@ test_expect_success 'cherry-pick cleans up sequencer state when one commit is le
227227
test_cmp expect actual
228228
'
229229

230-
test_expect_failure '--abort after last commit in sequence' '
230+
test_expect_success '--abort after last commit in sequence' '
231231
pristine_detach initial &&
232232
test_must_fail git cherry-pick base..picked &&
233233
git cherry-pick --abort &&

0 commit comments

Comments
 (0)