From: Elijah Newren <newren@xxxxxxxxx> In commit e98c4269c8 ("rebase (interactive-backend): fix handling of commits that become empty", 2020-02-15), the merge backend was changed to drop commits that did not start empty but became so after being applied (because their changes were a subset of what was already upstream). This new code path did not need to go through the process of creating a commit, since we were dropping the commit instead. Unfortunately, this also means we bypassed the clearing of the CHERRY_PICK_HEAD and MERGE_MSG files, which if there were no further commits to cherry-pick would mean that the rebase would end but assume there was still an operation in progress. Ensure that we clear such state files when we decide to drop the commit. Signed-off-by: Elijah Newren <newren@xxxxxxxxx> --- sequencer.c | 2 ++ t/t3424-rebase-empty.sh | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/sequencer.c b/sequencer.c index 7477b15422a..e528225e787 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1957,6 +1957,8 @@ static int do_pick_commit(struct repository *r, flags |= ALLOW_EMPTY; } else if (allow == 2) { drop_commit = 1; + unlink(git_path_cherry_pick_head(r)); + unlink(git_path_merge_msg(r)); fprintf(stderr, _("dropping %s %s -- patch contents already upstream\n"), oid_to_hex(&commit->object.oid), msg.subject); diff --git a/t/t3424-rebase-empty.sh b/t/t3424-rebase-empty.sh index 98fc2a558a0..e1e30517ea6 100755 --- a/t/t3424-rebase-empty.sh +++ b/t/t3424-rebase-empty.sh @@ -123,4 +123,12 @@ test_expect_success 'rebase --interactive uses default of --empty=ask' ' test_cmp expect actual ' +test_expect_success 'rebase --merge does not leave state laying around' ' + git checkout -B testing localmods~2 && + git rebase --merge upstream && + + test_path_is_missing .git/CHERRY_PICK_HEAD && + test_path_is_missing .git/MERGE_MSG +' + test_done -- gitgitgadget