]> git.ipfire.org Git - thirdparty/git.git/commit
patch-id: tighten code to detect the patch header
authorJunio C Hamano <gitster@pobox.com>
Tue, 30 Jul 2024 01:17:38 +0000 (18:17 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 30 Jul 2024 01:19:14 +0000 (18:19 -0700)
commita6e9429f728d088999b815c25adbd2f2c115e051
tree4e12dc17b4ff72055a12152a9c041b3ff6a9f4c8
parent3f288b6fafbb8c76edf53fba7cea90d5a20a9c56
patch-id: tighten code to detect the patch header

The get_one_patchid() function unconditionally takes a line that
matches the patch header (namely, a line that begins with a full
object name, possibly prefixed by "commit" or "From" plus a space)
as the beginning of a patch.  Even when it is *not* looking for one
(namely, when the previous call found the patch header and returned,
and then we are called again to skip the log message and process the
patch whose header was found by the previous invocation).

As a consequence, a line in the commit log message that begins with
one of these patterns can be mistaken to start another patch, with
current message entirely skipped (because we haven't even reached
the patch at all).

Allow the caller to tell us if it called us already and saw the
patch header (in which case we shouldn't be looking for another one,
until we see the "diff" part of the patch; instead we simply should
be skipping these lines as part of the commit log message), and skip
the header processing logic when that is the case.  In the helper
function, it also needs to flip this "are we looking for a header?"
bit, once it finished skipping the commit log message and started
processing the patches, as the patch header of the _next_ message is
the only clue in the input that the current patch is done.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/patch-id.c
t/t4204-patch-id.sh