]> git.ipfire.org Git - thirdparty/git.git/commit
apply: check and fix incomplete lines
authorJunio C Hamano <gitster@pobox.com>
Wed, 5 Nov 2025 21:30:50 +0000 (13:30 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Nov 2025 21:37:20 +0000 (13:37 -0800)
commit806aa30511bcb487c7bf56a0e716f299c8c467ff
tree60b98911f558057ee868ca53b08d43eb32c90fbe
parentbdc2dbbe4bd5a82a5a28374c336d0ac2f24126c4
apply: check and fix incomplete lines

The final line of a file that lacks the terminating newline at its
end is called an incomplete line.  In general they are frowned upon
for many reasons (imagine concatenating two files with "cat A B" and
what happens when A ends in an incomplete line, for example), and
text-oriented tools often mishandle such a line.

Implement checks in "git apply" for incomplete lines, which is off
by default for backward compatibility's sake, so that "git apply
--whitespace={fix,warn,error}" can notice, warn against, and fix
them.

As one of the new test shows, if you modify contents on an
incomplete line in the original and leave the resulting line
incomplete, it is still considered a whitespace error, the reasoning
being that "you'd better fix it while at it if you are making a
change on an incomplete line anyway", which may controversial.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
apply.c
t/t4124-apply-ws-rule.sh
ws.c