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
--word-diff
is a post-processing step after lines got diffed (it basically diffs the "added" with "removed" lines). Looks like this is a bug in Git, maybe you can send a bug report to the Git mailing list – Hippodrome