rubo77
rubo77

Reputation: 20845

git diff ignoring whitespace unless a space is deleted

If I use git diff --ignore-space-change --ignore-all-space to get only relevant changes, I miss changes, where a space between two words was completely deleted.

Example

echo       "the space before this string is irrelevant"
echo "foo bar are two words"

changes to

echo "the space before this string is irrelevant"
echo "foobar are two words"

I wouldn't see the change gluing foo and bar together, creating a new single word.

I want to see those (sometimes really relevant) changes in the git diff output, something like

git diff --ignore-space-change-unless-no-space-left

Upvotes: 0

Views: 70

Answers (1)

jthill
jthill

Reputation: 60285

Just take out --ignore-all-space.

$ cat f1 f2
echo       "the space before this string is irrelevant"
echo "foo bar are two words"
echo "the space before this string is irrelevant"
echo "foobar are two words"
$ git diff --ignore-space-change f1 f2
diff --git a/f1 b/f2
index c9f73d1..fba75e4 100644
--- a/f1
+++ b/f2
@@ -1,2 +1,2 @@
 echo "the space before this string is irrelevant"
-echo "foo bar are two words"
+echo "foobar are two words"

Upvotes: 1

Related Questions