git diff 忽略白色 space 除非 space 被删除

git diff ignoring whitespace unless a space is deleted

如果我使用 git diff --ignore-space-change --ignore-all-space 只获取相关更改,我会错过更改,其中两个单词之间的 space 被完全删除.

示例

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"

我不会看到将 foo 和 bar 粘合在一起的变化,创建一个新的单词。

我想在 git diff 输出中看到那些(有时非常相关的)变化,比如

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

取出--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"