Skip to content

Commit

Permalink
Merge branch 'pw/rebase-skip-final-fix'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gitster committed Sep 3, 2021
2 parents 2ad8d49 + e5ee33e commit 0ba5a0b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
3 changes: 3 additions & 0 deletions sequencer.c
Expand Up @@ -4716,6 +4716,9 @@ static int commit_staged_changes(struct repository *r,
refs_delete_ref(get_main_ref_store(r), "",
"CHERRY_PICK_HEAD", NULL, 0))
return error(_("could not remove CHERRY_PICK_HEAD"));
if (unlink(git_path_merge_msg(r)) && errno != ENOENT)
return error_errno(_("could not remove '%s'"),
git_path_merge_msg(r));
if (!final_fixup)
return 0;
}
Expand Down
13 changes: 11 additions & 2 deletions t/t3403-rebase-skip.sh
Expand Up @@ -20,6 +20,7 @@ test_expect_success setup '
git add hello &&
git commit -m "hello" &&
git branch skip-reference &&
git tag hello &&
echo world >> hello &&
git commit -a -m "hello world" &&
Expand All @@ -36,7 +37,8 @@ test_expect_success setup '
test_tick &&
GIT_AUTHOR_NAME="Another Author" \
GIT_AUTHOR_EMAIL="another.author@example.com" \
git commit --amend --no-edit -m amended-goodbye &&
git commit --amend --no-edit -m amended-goodbye \
--reset-author &&
test_tick &&
git tag amended-goodbye &&
Expand All @@ -51,7 +53,7 @@ test_expect_success setup '
'

test_expect_success 'rebase with git am -3 (default)' '
test_must_fail git rebase main
test_must_fail git rebase --apply main
'

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

test_debug 'gitk --all & sleep 1'

test_expect_success 'skipping final pick removes .git/MERGE_MSG' '
test_must_fail git rebase --onto hello reverted-goodbye^ \
reverted-goodbye &&
git rebase --skip &&
test_path_is_missing .git/MERGE_MSG
'

test_expect_success 'correct advice upon picking empty commit' '
test_when_finished "git rebase --abort" &&
test_must_fail git rebase -i --onto goodbye \
Expand Down
18 changes: 14 additions & 4 deletions t/t3418-rebase-continue.sh
Expand Up @@ -21,7 +21,7 @@ test_expect_success 'setup' '
git checkout main
'

test_expect_success 'interactive rebase --continue works with touched file' '
test_expect_success 'merge based rebase --continue with works with touched file' '
rm -fr .git/rebase-* &&
git reset --hard &&
git checkout main &&
Expand All @@ -31,12 +31,22 @@ test_expect_success 'interactive rebase --continue works with touched file' '
git rebase --continue
'

test_expect_success 'non-interactive rebase --continue works with touched file' '
test_expect_success 'merge based rebase --continue removes .git/MERGE_MSG' '
git checkout -f --detach topic &&
test_must_fail git rebase --onto main HEAD^ &&
git read-tree --reset -u HEAD &&
test_path_is_file .git/MERGE_MSG &&
git rebase --continue &&
test_path_is_missing .git/MERGE_MSG
'

test_expect_success 'apply based rebase --continue works with touched file' '
rm -fr .git/rebase-* &&
git reset --hard &&
git checkout main &&
test_must_fail git rebase --onto main main topic &&
test_must_fail git rebase --apply --onto main main topic &&
echo "Resolved" >F2 &&
git add F2 &&
test-tool chmtime =-60 F1 &&
Expand Down Expand Up @@ -254,7 +264,7 @@ test_rerere_autoupdate () {
'
}

test_rerere_autoupdate
test_rerere_autoupdate --apply
test_rerere_autoupdate -m
GIT_SEQUENCE_EDITOR=: && export GIT_SEQUENCE_EDITOR
test_rerere_autoupdate -i
Expand Down

0 comments on commit 0ba5a0b

Please sign in to comment.