Code

Merge branch 'js/maint-diff-color-words' into maint
[git.git] / t / t4019-diff-wserror.sh
index 7eae1f4500591799d656f1dde20cf15f296cf6e4..3a3663fbcb4795a9e3755fe831c89a7e312f659e 100755 (executable)
@@ -165,7 +165,7 @@ test_expect_success 'trailing empty lines (1)' '
 
        rm -f .gitattributes &&
        test_must_fail git diff --check >output &&
-       grep "ends with blank lines." output &&
+       grep "new blank line at" output &&
        grep "trailing whitespace" output
 
 '
@@ -178,4 +178,25 @@ test_expect_success 'trailing empty lines (2)' '
 
 '
 
+test_expect_success 'do not color trailing cr in context' '
+       git config --unset core.whitespace
+       rm -f .gitattributes &&
+       echo AAAQ | tr Q "\015" >G &&
+       git add G &&
+       echo BBBQ | tr Q "\015" >>G
+       git diff --color G | tr "\015" Q >output &&
+       grep "BBB.*${blue_grep}Q" output &&
+       grep "AAA.*\[mQ" output
+
+'
+
+test_expect_success 'color new trailing blank lines' '
+       { echo a; echo b; echo; echo; } >x &&
+       git add x &&
+       { echo a; echo; echo; echo; echo c; echo; echo; echo; echo; } >x &&
+       git diff --color x >output &&
+       cnt=$(grep "${blue_grep}" output | wc -l) &&
+       test $cnt = 2
+'
+
 test_done