aboutsummaryrefslogtreecommitdiffstats
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-11-05 13:30:48 -0800
committerJunio C Hamano <gitster@pobox.com>2025-11-05 13:37:19 -0800
commitc66b547f13923c3beaa09c81a5872dd482644ebd (patch)
tree75d6a12968815f180432cee420252b05d5a590f7 /diff.c
parentdiff: update the way rewrite diff handles incomplete lines (diff)
downloadgit-c66b547f13923c3beaa09c81a5872dd482644ebd.tar.gz
git-c66b547f13923c3beaa09c81a5872dd482644ebd.zip
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 'diff.c')
0 files changed, 0 insertions, 0 deletions