]> git.ipfire.org Git - thirdparty/git.git/commit
trailer: find the end of the log message
authorLinus Arver <linusa@google.com>
Fri, 20 Oct 2023 19:01:34 +0000 (19:01 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Dec 2023 19:55:04 +0000 (11:55 -0800)
commit97e9d0b78a038de37245acbef11a10c4ae2feeb3
treeec90e7d1c35e50650a0de597181e658649a703ec
parent7cb26a1722a7f7d9f1b01f2dcde8fe81d3a96bc1
trailer: find the end of the log message

Previously, trailer_info_get() computed the trailer block end position
by

(1) checking for the opts->no_divider flag and optionally calling
    find_patch_start() to find the "patch start" location (patch_start), and
(2) calling find_trailer_end() to find the end of the trailer block
    using patch_start as a guide, saving the return value into
    "trailer_end".

The logic in (1) was awkward because the variable "patch_start" is
misleading if there is no patch in the input. The logic in (2) was
misleading because it could be the case that no trailers are in the
input (yet we are setting a "trailer_end" variable before even searching
for trailers, which happens later in find_trailer_start()). The name
"find_trailer_end" was misleading because that function did not look for
any trailer block itself --- instead it just computed the end position
of the log message in the input where the end of the trailer block (if
it exists) would be (because trailer blocks must always come after the
end of the log message).

Combine the logic in (1) and (2) together into find_patch_start() by
renaming it to find_end_of_log_message(). The end of the log message is
the starting point which find_trailer_start() needs to start searching
backward to parse individual trailers (if any).

Helped-by: Jonathan Tan <jonathantanmy@google.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
trailer.c