git diff --word-diff with oneline files
Asked Answered
F

1

7

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
Frauenfeld answered 11/1, 2012 at 11:53 Comment(2)
AFAIK --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 listHippodrome
Just sent them a letter. Looks like a bug.Frauenfeld
F
7

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.

Frauenfeld answered 12/1, 2012 at 11:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.