rebase -r: don't write .git/MERGE_MSG when fast-forwarding
commitbaf8ec8d3a0327307f79efd31d5717a0c91c4d8c
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Fri, 20 Aug 2021 15:40:37 +0000 (20 15:40 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Aug 2021 16:36:30 +0000 (23 09:36 -0700)
tree5e4ff4c2e0801cc72ea24144f0c078748d759530
parent0c164ae7a65f811ef3fb3188c63cd157335463bb
rebase -r: don't write .git/MERGE_MSG when fast-forwarding

When fast-forwarding we do not create a new commit so .git/MERGE_MSG
is not removed and can end up seeding the message of a commit made
after the rebase has finished. Avoid writing .git/MERGE_MSG when we
are fast-forwarding by writing the file after the fast-forward
checks. Note that there are no changes to the fast-forward code, it is
simply moved.

Note that the way this change is implemented means we no longer write
the author script when fast-forwarding either. I believe this is safe
for the reasons below but it is a departure from what we do when
fast-forwarding a non-merge commit. If we reword the merge then 'git
commit --amend' will keep the authorship of the commit we're rewording
as it ignores GIT_AUTHOR_* unless --reset-author is passed. It will
also export the correct GIT_AUTHOR_* variables to any hooks and we
already test the authorship of the reworded commit. If we are not
rewording then we no longer call spilt_ident() which means we are no
longer checking the commit author header looks sane. However this is
what we already do when fast-forwarding non-merge commits in
skip_unnecessary_picks() so I don't think we're breaking any promises
by not checking the author here.

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c
t/lib-rebase.sh