]> git.ipfire.org Git - thirdparty/git.git/commit
diff: correct suppress_blank_empty hack
authorJunio C Hamano <gitster@pobox.com>
Wed, 12 Nov 2025 22:02:49 +0000 (14:02 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Nov 2025 22:04:04 +0000 (14:04 -0800)
commitfc7abcd9d5460b381701ef43b7f6dafa73962950
tree35874becfbcfc3da357bc3e32b98e27298361778
parentf83d1afafb8b772397aa3854184c42f7810fa0df
diff: correct suppress_blank_empty hack

The suppress-blank-empty feature abused the CONTEXT_INCOMPLETE
symbol that was meant to be used only for "\ No newline at the end
of file" code path.

The intent of the feature was to turn a context line we receive from
xdiff machinery (which always uses ' ' for context lines, even an
empty one) and spit it out as a truly empty line.

Perform such a conversion very locally at where a line from xdiff
that begins with ' ' is handled for output; there are many checks
before the control reaches such place that checks the first letter
of the diff output line to see if it is a context line, and having
to check for '\n' and treat it as a special case is error prone.

In order to catch similar hacks in the future, make sure the code
path that is meant for "\ No newline" case checks the first byte is
indeed a backslash.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c