diff: --color-moved: rename "dimmed_zebra" to "dimmed-zebra"
[gitweb.git] / t / t4015-diff-whitespace.sh
index 6c9a93b734542cc17fa1591525dc3c49019b77fe..8cdfa225ef6cecb8d44b56c90da5b7e6f0355175 100755 (executable)
@@ -106,6 +106,8 @@ test_expect_success 'another test, without options' '
        git diff -w -b --ignore-space-at-eol >out &&
        test_cmp expect out &&
 
+       git diff -w --ignore-cr-at-eol >out &&
+       test_cmp expect out &&
 
        tr "Q_" "\015 " <<-\EOF >expect &&
        diff --git a/x b/x
@@ -128,6 +130,9 @@ test_expect_success 'another test, without options' '
        git diff -b --ignore-space-at-eol >out &&
        test_cmp expect out &&
 
+       git diff -b --ignore-cr-at-eol >out &&
+       test_cmp expect out &&
+
        tr "Q_" "\015 " <<-\EOF >expect &&
        diff --git a/x b/x
        index d99af23..22d9f73 100644
@@ -145,6 +150,29 @@ test_expect_success 'another test, without options' '
         CR at end
        EOF
        git diff --ignore-space-at-eol >out &&
+       test_cmp expect out &&
+
+       git diff --ignore-space-at-eol --ignore-cr-at-eol >out &&
+       test_cmp expect out &&
+
+       tr "Q_" "\015 " <<-\EOF >expect &&
+       diff --git a/x b/x
+       index_d99af23..22d9f73 100644
+       --- a/x
+       +++ b/x
+       @@ -1,6 +1,6 @@
+       -whitespace at beginning
+       -whitespace change
+       -whitespace in the middle
+       -whitespace at end
+       +_      whitespace at beginning
+       +whitespace_    _change
+       +white space in the middle
+       +whitespace at end__
+        unchanged line
+        CR at end
+       EOF
+       git diff --ignore-cr-at-eol >out &&
        test_cmp expect out
 '
 
@@ -608,6 +636,23 @@ test_expect_success 'check with space before tab in indent (diff-tree)' '
        test_must_fail git diff-tree --check HEAD^ HEAD
 '
 
+test_expect_success 'check with ignored trailing whitespace attr (diff-tree)' '
+       test_when_finished "git reset --hard HEAD^" &&
+
+       # create a whitespace error that should be ignored
+       echo "* -whitespace" >.gitattributes &&
+       git add .gitattributes &&
+       echo "foo(); " >x &&
+       git add x &&
+       git commit -m "add trailing space" &&
+
+       # with a worktree diff-tree ignores the whitespace error
+       git diff-tree --root --check HEAD &&
+
+       # without a worktree diff-tree still ignores the whitespace error
+       git -C .git diff-tree --root --check HEAD
+'
+
 test_expect_success 'check trailing whitespace (trailing-space: off)' '
        git config core.whitespace "-trailing-space" &&
        echo "foo ();   " >x &&
@@ -1178,7 +1223,7 @@ test_expect_success 'plain moved code, inside file' '
        test_cmp expected actual
 '
 
-test_expect_success 'detect permutations inside moved code -- dimmed_zebra' '
+test_expect_success 'detect permutations inside moved code -- dimmed-zebra' '
        git reset --hard &&
        cat <<-\EOF >lines.txt &&
                long line 1
@@ -1226,7 +1271,7 @@ test_expect_success 'detect permutations inside moved code -- dimmed_zebra' '
        test_config color.diff.newMovedDimmed "normal cyan" &&
        test_config color.diff.oldMovedAlternativeDimmed "normal blue" &&
        test_config color.diff.newMovedAlternativeDimmed "normal yellow" &&
-       git diff HEAD --no-renames --color-moved=dimmed_zebra --color |
+       git diff HEAD --no-renames --color-moved=dimmed-zebra --color |
                grep -v "index" |
                test_decode_color >actual &&
        cat <<-\EOF >expected &&