Reputation: 151
I'm having trouble with git diff --word-diff. The thing is when diff gets file without newlines (one line file) it differrs it line by line. And I want to differ it word by word.
Here's what happens when I'm comparing 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 @@
[- a a a a a a a a a a-]
No newline at end of file
{+a a a a a ab a a a a+}
And if I add newline to the end of the files everything works 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 @@
a a a a a [-a -]{+ab +}a a a a
Upvotes: 7
Views: 4227
Reputation: 151
I wrote to GIT team and they answered that it is a bug indeed. Also they send me a patch for that case. Looks like it would be fixed in 1.7.9.
Upvotes: 7