rebase -m: fix --signoff with conflicts
commita6c2654f839d508c9c912372a9cad18340d7b59c
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Thu, 18 Apr 2024 13:14:09 +0000 (18 14:14 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 18 Apr 2024 20:33:41 +0000 (18 13:33 -0700)
tree6da66beee760f60b34818ce3e564dd11b9f727b5
parent53f67466153ffd291955d7d55bcb33decf664aaf
rebase -m: fix --signoff with conflicts

When rebasing with "--signoff" the commit created by "rebase --continue"
after resolving conflicts or editing a commit fails to add the
"Signed-off-by:" trailer. This happens because the message from the
original commit is reused instead of the one that would have been used
if the sequencer had not stopped for the user interaction. The correct
message is stored in ctx->message and so with a couple of exceptions
this is written to rebase_path_message() when stopping for user
interaction instead. The exceptions are (i) "fixup" and "squash"
commands where the file is written by error_failed_squash() and (ii)
"edit" commands that are fast-forwarded where the original message is
still reused. The latter is safe because "--signoff" will never
fast-forward.

Note this introduces a change in behavior as the message file now
contains conflict comments. This is safe because commit_staged_changes()
passes an explicit cleanup flag when not editing the message and when
the message is being edited it will be cleaned up automatically. This
means user now sees the same message comments in editor with "rebase
--continue" as they would if they ran "git commit" themselves before
continuing the rebase. It also matches the behavior of "git
cherry-pick", "git merge" etc. which all list the files with merge
conflicts.

The tests are extended to check that all commits made after continuing a
rebase have a "Signed-off-by:" trailer. Sadly there are a couple of
leaks in apply.c which I've not been able to track down that mean this
test file is no-longer leak free when testing "git rebase --apply
--signoff" with conflicts.

Reported-by: David Bimmler <david.bimmler@isovalent.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c
t/t3428-rebase-signoff.sh
t/t3434-rebase-i18n.sh