]> git.ipfire.org Git - thirdparty/git.git/commit
trailer: fix comment/cut-line regression with opts->no_divider
authorJeff King <peff@peff.net>
Tue, 20 Feb 2024 01:09:36 +0000 (20:09 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 20 Feb 2024 03:06:18 +0000 (19:06 -0800)
commitbc47139f4ff6c0c41d4c854ca74c35b1006a464a
treeb4022b46ffca3df9c2fdf1740d5052dfab26a45f
parentde7c27a1869953158436e60542ea556d78c3f4c2
trailer: fix comment/cut-line regression with opts->no_divider

Commit 97e9d0b78a (trailer: find the end of the log message, 2023-10-20)
combined two code paths for finding the end of the log message. For the
"no_divider" case, we used to use find_trailer_end(), and that has now
been rolled into find_end_of_log_message(). But there's a regression;
that function returns early when no_divider is set, returning the whole
string.

That's not how find_trailer_end() behaved. Although it did skip the
"---" processing (which is what "no_divider" is meant to do), we should
still respect ignored_log_message_bytes(), which covers things like
comments, "commit -v" cut lines, and so on.

The bug is actually in the interpret-trailers command, but the obvious
way to experience it is by running "commit -v" with a "--trailer"
option. The new trailer will be added at the end of the verbose diff,
rather than before it (and consequently will be ignored entirely, since
everything after the diff's intro scissors line is thrown away).

I've added two tests here: one for interpret-trailers directly, which
shows the bug via the parsing routines, and one for "commit -v".

The fix itself is pretty simple: instead of returning early, no_divider
just skips the "---" handling but still calls ignored_log_message_bytes().

Reported-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7502-commit-porcelain.sh
t/t7513-interpret-trailers.sh
trailer.c