Imported Upstream version 2.22.2
[platform/upstream/git.git] / t / t0020-crlf.sh
index f94120a..854da0a 100755 (executable)
@@ -83,7 +83,11 @@ test_expect_success 'safecrlf: print warning only once' '
        git add doublewarn &&
        git commit -m "nowarn" &&
        for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >doublewarn &&
-       test $(git add doublewarn 2>&1 | grep "CRLF will be replaced by LF" | wc -l) = 1
+       git add doublewarn 2>err &&
+       if test_have_prereq C_LOCALE_OUTPUT
+       then
+               test $(grep "CRLF will be replaced by LF" err | wc -l) = 1
+       fi
 '
 
 
@@ -94,6 +98,16 @@ test_expect_success 'safecrlf: git diff demotes safecrlf=true to warn' '
 '
 
 
+test_expect_success 'safecrlf: no warning with safecrlf=false' '
+       git config core.autocrlf input &&
+       git config core.safecrlf false &&
+
+       for w in I am all CRLF; do echo $w; done | append_cr >allcrlf &&
+       git add allcrlf 2>err &&
+       test_must_be_empty err
+'
+
+
 test_expect_success 'switch off autocrlf, safecrlf, reset HEAD' '
        git config core.autocrlf false &&
        git config core.safecrlf false &&
@@ -146,7 +160,7 @@ test_expect_success 'checkout with autocrlf=input' '
        git config core.autocrlf input &&
        git read-tree --reset -u HEAD &&
        test_must_fail has_cr one &&
-       test_must_fail has_cr two &&
+       test_must_fail has_cr dir/two &&
        git update-index -- one dir/two &&
        test "$one" = $(git hash-object --stdin <one) &&
        test "$two" = $(git hash-object --stdin <dir/two) &&