Hi Luca
Thanks for your patches. It would be very helpful to have the
explanation from the cover letter in the commit messages for both
commits to explain why this change is being made, otherwise that
information will not appear in the history.
The cover letter says this happened when using '--no-edit', but unless
I've missed something 'git merge --no-edit' creates its message using
fmt_merge_msg() which calls strbuf_complete_line() just before it
returns. append_signoff() and 'merge -m' always terminate the message
with a newline. The only path I found that does not ensure the message
ends with a newline before calling the prepare-commit-msg hook is when
using '-F' and I suspect that may have been a deliberate decision but it
could be an oversight. In any case we would want to make sure that 'git
commit -F' and 'git merge -F' to behave the same which I think they do
at the moment.
Best Wishes
Phillip
On 16/07/2021 08:43, Luca Weiss via GitGitGadget wrote:
From: Luca Weiss <luca@xxxxxxxxx>
Signed-off-by: Luca Weiss <luca@xxxxxxxxx>
---
builtin/merge.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/builtin/merge.c b/builtin/merge.c
index a8a843b1f54..646bb49367f 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -867,6 +867,7 @@ static void prepare_to_commit(struct commit_list *remoteheads)
}
if (signoff)
append_signoff(&msg, ignore_non_trailer(msg.buf, msg.len), 0);
+ strbuf_complete_line(&msg);
write_merge_heads(remoteheads);
write_file_buf(git_path_merge_msg(the_repository), msg.buf, msg.len);
if (run_commit_hook(0 < option_edit, get_index_file(), "prepare-commit-msg",