walles / riff

A diff filter highlighting which line parts have changed
MIT License
253 stars 5 forks source link

"No newline at end of file" feature is dependent on system language being english #39

Closed 0x5c closed 1 year ago

0x5c commented 1 year ago

When the system language is not english, the output of diff -u will not contain the string \ No newline at end of file, but instead some translated text in the user's locale.

aaa

yo

bbb

yo

image (the text is \ Pas de fin de ligne à la fin du fichier)

I would assume that the exact text used isn't part of the unified diff format, and at only the \ on col 1 of the line matters. It seems that gnu patch does indeed only care about the backslash, although I'm not sure if my reading of that code is correct.

0x5c commented 1 year ago

It seems that gnu patch does indeed consider the backslash only.

Wrote the output of $ LANG=fr_CA.UTF-8 diff -u aaa bbb to test.patch

--- aaa 2023-03-15 01:46:21.639805928 -0400
+++ bbb 2023-03-15 01:46:31.812927237 -0400
@@ -1 +1 @@
-yo
\ Pas de fin de ligne à la fin du fichier
+yo

$ patch -u -o ccc aaa test.patch indeed produces a ccc file which is identical to bbb.

EDIT: did the same test with a patch file that had \ Hello world, will this line break patch?, with the same result.

walles commented 1 year ago

Released: https://github.com/walles/riff/releases/tag/2.23.1

walles commented 1 year ago

Nice catch @0x5c!