Skip to content

Commit 0ba5a0b

Browse files
committed
Merge branch 'pw/rebase-skip-final-fix'
Checking out all the paths from HEAD during the last conflicted step in "git rebase" and continuing would cause the step to be skipped (which is expected), but leaves MERGE_MSG file behind in $GIT_DIR and confuses the next "git commit", which has been corrected. * pw/rebase-skip-final-fix: rebase --continue: remove .git/MERGE_MSG rebase --apply: restore some tests t3403: fix commit authorship
2 parents 2ad8d49 + e5ee33e commit 0ba5a0b

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

sequencer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4716,6 +4716,9 @@ static int commit_staged_changes(struct repository *r,
47164716
refs_delete_ref(get_main_ref_store(r), "",
47174717
"CHERRY_PICK_HEAD", NULL, 0))
47184718
return error(_("could not remove CHERRY_PICK_HEAD"));
4719+
if (unlink(git_path_merge_msg(r)) && errno != ENOENT)
4720+
return error_errno(_("could not remove '%s'"),
4721+
git_path_merge_msg(r));
47194722
if (!final_fixup)
47204723
return 0;
47214724
}

t/t3403-rebase-skip.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ test_expect_success setup '
2020
git add hello &&
2121
git commit -m "hello" &&
2222
git branch skip-reference &&
23+
git tag hello &&
2324
2425
echo world >> hello &&
2526
git commit -a -m "hello world" &&
@@ -36,7 +37,8 @@ test_expect_success setup '
3637
test_tick &&
3738
GIT_AUTHOR_NAME="Another Author" \
3839
GIT_AUTHOR_EMAIL="[email protected]" \
39-
git commit --amend --no-edit -m amended-goodbye &&
40+
git commit --amend --no-edit -m amended-goodbye \
41+
--reset-author &&
4042
test_tick &&
4143
git tag amended-goodbye &&
4244
@@ -51,7 +53,7 @@ test_expect_success setup '
5153
'
5254

5355
test_expect_success 'rebase with git am -3 (default)' '
54-
test_must_fail git rebase main
56+
test_must_fail git rebase --apply main
5557
'
5658

5759
test_expect_success 'rebase --skip can not be used with other options' '
@@ -95,6 +97,13 @@ test_expect_success 'moved back to branch correctly' '
9597

9698
test_debug 'gitk --all & sleep 1'
9799

100+
test_expect_success 'skipping final pick removes .git/MERGE_MSG' '
101+
test_must_fail git rebase --onto hello reverted-goodbye^ \
102+
reverted-goodbye &&
103+
git rebase --skip &&
104+
test_path_is_missing .git/MERGE_MSG
105+
'
106+
98107
test_expect_success 'correct advice upon picking empty commit' '
99108
test_when_finished "git rebase --abort" &&
100109
test_must_fail git rebase -i --onto goodbye \

t/t3418-rebase-continue.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test_expect_success 'setup' '
2121
git checkout main
2222
'
2323

24-
test_expect_success 'interactive rebase --continue works with touched file' '
24+
test_expect_success 'merge based rebase --continue with works with touched file' '
2525
rm -fr .git/rebase-* &&
2626
git reset --hard &&
2727
git checkout main &&
@@ -31,12 +31,22 @@ test_expect_success 'interactive rebase --continue works with touched file' '
3131
git rebase --continue
3232
'
3333

34-
test_expect_success 'non-interactive rebase --continue works with touched file' '
34+
test_expect_success 'merge based rebase --continue removes .git/MERGE_MSG' '
35+
git checkout -f --detach topic &&
36+
37+
test_must_fail git rebase --onto main HEAD^ &&
38+
git read-tree --reset -u HEAD &&
39+
test_path_is_file .git/MERGE_MSG &&
40+
git rebase --continue &&
41+
test_path_is_missing .git/MERGE_MSG
42+
'
43+
44+
test_expect_success 'apply based rebase --continue works with touched file' '
3545
rm -fr .git/rebase-* &&
3646
git reset --hard &&
3747
git checkout main &&
3848
39-
test_must_fail git rebase --onto main main topic &&
49+
test_must_fail git rebase --apply --onto main main topic &&
4050
echo "Resolved" >F2 &&
4151
git add F2 &&
4252
test-tool chmtime =-60 F1 &&
@@ -254,7 +264,7 @@ test_rerere_autoupdate () {
254264
'
255265
}
256266

257-
test_rerere_autoupdate
267+
test_rerere_autoupdate --apply
258268
test_rerere_autoupdate -m
259269
GIT_SEQUENCE_EDITOR=: && export GIT_SEQUENCE_EDITOR
260270
test_rerere_autoupdate -i

0 commit comments

Comments
 (0)