Merge branch 'pw/rebase-skip-final-fix' into maint

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
This commit is contained in:
Junio C Hamano 2021-10-12 13:51:39 -07:00
commit 8b02ffee3f
3 changed files with 28 additions and 6 deletions

View File

@ -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;
}

View File

@ -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" &&
@ -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 &&
@ -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' '
@ -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 \

View File

@ -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 &&
@ -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 &&
@ -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