1

How can I get git diff to ignore changes like:

a + b + c

to

a +
b +
c

i.e, treat all sequences of whitespace as identical for the purposes of diff?

Note that given file1:

a + b + c

and file2:

a +
b +
c

running

git diff -w --word-diff-regex=[^[:space:]] file1 file2

gives:

diff --git a/file1 b/file2
index baaa7f9..1ded6d8 100644
--- a/file1
+++ b/file2
@@ -1 +1,3 @@
a +
b +
c

not an empty diff as expected. Although the hunk presented actually has no changes (as in no lines begin with + or -). Is there a way to remove hunks with no changes?

Clinton
  • 22,361
  • 15
  • 67
  • 163

0 Answers0