Git diff -word-diff with oneline files

I'm having problems with git diff -word-diff. The fact is that diff receives a file without newline characters (one line file), it changes it line by line. And I want to share this word by word.

This is what happens when I compare files without newlines:

git diff -a --word-diff=plain file1 file2 diff --git a/file1 b/file2 index 3526254..0515a63 100644 --- a/file1 +++ b/file2 @@ -1 +1 @@ [- aaaaaaaaa a-] No newline at end of file {+aaaaa ab aaa a+} 

And if I add a new line to the end of the files, everything will work as expected:

 git diff -a --word-diff=plain file1 file2 diff --git a/file1 b/file2 index 1756d83..1ec45b9 100644 --- a/file1 +++ b/file2 @@ -1,2 +1,2 @@ aaaaa [-a -]{+ab +}aaaa 
+6
source share
1 answer

I wrote to the GIT team and they replied that it was really a mistake. They also send me a patch for this case. It looks like it will be fixed in 1.7.9.

+6
source

Source: https://habr.com/ru/post/905705/


All Articles