Skip to content

Commit 9a1b747

Browse files
newrengitster
authored andcommitted
sequencer: clear state upon dropping a become-empty commit
In commit e98c426 ("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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 937d143 commit 9a1b747

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

sequencer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,8 @@ static int do_pick_commit(struct repository *r,
19551955
flags |= ALLOW_EMPTY;
19561956
} else if (allow == 2) {
19571957
drop_commit = 1;
1958+
unlink(git_path_cherry_pick_head(r));
1959+
unlink(git_path_merge_msg(r));
19581960
fprintf(stderr,
19591961
_("dropping %s %s -- patch contents already upstream\n"),
19601962
oid_to_hex(&commit->object.oid), msg.subject);

t/t3424-rebase-empty.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,12 @@ test_expect_success 'rebase --interactive uses default of --empty=ask' '
123123
test_cmp expect actual
124124
'
125125

126+
test_expect_success 'rebase --merge does not leave state laying around' '
127+
git checkout -B testing localmods~2 &&
128+
git rebase --merge upstream &&
129+
130+
test_path_is_missing .git/CHERRY_PICK_HEAD &&
131+
test_path_is_missing .git/MERGE_MSG
132+
'
133+
126134
test_done

0 commit comments

Comments
 (0)