summaryrefslogtreecommitdiff
path: root/t/t4018/php-abstract-class
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-11-12 14:02:54 -0800
committerJunio C Hamano <gitster@pobox.com>2025-11-12 14:04:04 -0800
commit3a4eb5ad2e9166255d5921196470710523f24ec4 (patch)
tree8a74ba0cc4526f24ecf2ccecefa9b71c2bf82298 /t/t4018/php-abstract-class
parent8d8e3c61874bbcf50d64aff34fb6c533458adf5e (diff)
apply: revamp the parsing of incomplete lines
A patch file represents the incomplete line at the end of the file with two lines, one that is the usual "context" with " " as the first letter, "added" with "+" as the first letter, or "removed" with "-" as the first letter that shows the content of the line, plus an extra "\ No newline at the end of file" line that comes immediately after it. Ever since the apply machinery was written, the "git apply" machinery parses "\ No newline at the end of file" line independently, without even knowing what line the incomplete-ness applies to, simply because it does not even remember what the previous line was. This poses a problem if we want to check and warn on an incomplete line. Revamp the code that parses a fragment, to actually drop the '\n' at the end of the incoming patch file that terminates a line, so that check_whitespace() calls made from the code path actually sees an incomplete as incomplete. Note that the result of this parsing is not directly used by the code path that applies the patch. apply_one_fragment() function already checks if each of the patch text it handles is followed by a line that begins with a backslash to drop the newline at the end of the current line it is looking at. In a sense, this patch harmonizes the behaviour of the parsing side to what is already done in the application side. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4018/php-abstract-class')
0 files changed, 0 insertions, 0 deletions