path: root/sequencer.c
diff options
authorPhillip Wood <>2019-12-06 16:06:09 (GMT)
committerJunio C Hamano <>2019-12-06 17:32:01 (GMT)
commit21b11c6d1de3840dcaf3fa82dae14ca3924f689f (patch)
treee64d350048a385453c8f208dd31de2df6150a593 /sequencer.c
parentf028d661c74f29de0e26494e6c9fbcf186b0d4ae (diff)
sequencer: write CHERRY_PICK_HEAD for reword and edit
`git commit` relies on the presence of CHERRY_PICK_HEAD to show the correct error message in the case of an empty pick. This fixes a regression introduced by the conversion from shell to C. In the shell version everything was a cherry-pick as far as the sequencer code was concerned so it always wrote CHERRY_PICK_HEAD. The conversion to C forgot to update the code that creates CHERRY_PICK_HEAD. We do not want to create CHERRY_PICK_HEAD for fixup and squash commands as that would prevent `git commit --amend` from running. Note that the error message shown by `git commit` for an empty pick during a rebase is currently wrong as it talks about running `git cherry-pick --skip` rather than `git rebase --skip`. This will be fixed in a future commit which is why the tests are in Signed-off-by: Phillip Wood <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'sequencer.c')
1 files changed, 3 insertions, 1 deletions
diff --git a/sequencer.c b/sequencer.c
index d18aba6..d668568 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1916,7 +1916,9 @@ static int do_pick_commit(struct repository *r,
* However, if the merge did not even start, then we don't want to
* write it at all.
- if (command == TODO_PICK && !opts->no_commit && (res == 0 || res == 1) &&
+ if ((command == TODO_PICK || command == TODO_REWORD ||
+ command == TODO_EDIT) && !opts->no_commit &&
+ (res == 0 || res == 1) &&
update_ref(NULL, "CHERRY_PICK_HEAD", &commit->object.oid, NULL,
res = -1;