]> git.feebdaed.xyz Git - 0xmirror/git.git/commit
apply: check and fix incomplete lines
authorJunio C Hamano <gitster@pobox.com>
Wed, 12 Nov 2025 22:02:56 +0000 (14:02 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Nov 2025 22:04:04 +0000 (14:04 -0800)
commit9fb15a8e1430b77e2cc771e425ce4f0954ce4777
tree597a31d17d44891390c6f9d4b989ddcd462a2b7c
parenta675104c399d242dd3ff5a0823fcd770563cf60f
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