Merge branch 'sb/diff-color-move-more'
[gitweb.git] / t / t0020-crlf.sh
index f7a6a3ce7dc2b18f9fd9c351998992f34ead9518..854da0ae16f8c437c239a0a4e16f1549d87521a2 100755 (executable)
@@ -35,9 +35,7 @@ test_expect_success setup '
        for w in Some extra lines here; do echo $w; done >>one &&
        git diff >patch.file &&
        patched=$(git hash-object --stdin <one) &&
-       git read-tree --reset -u HEAD &&
-
-       echo happy.
+       git read-tree --reset -u HEAD
 '
 
 test_expect_success 'safecrlf: autocrlf=input, all CRLF' '
@@ -85,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
 '
 
 
@@ -96,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 &&
@@ -225,29 +237,9 @@ test_expect_success '.gitattributes says two is binary' '
        git config core.autocrlf true &&
        git read-tree --reset -u HEAD &&
 
-       if has_cr dir/two
-       then
-               echo "Huh?"
-               false
-       else
-               : happy
-       fi &&
-
-       if has_cr one
-       then
-               : happy
-       else
-               echo "Huh?"
-               false
-       fi &&
-
-       if has_cr three
-       then
-               echo "Huh?"
-               false
-       else
-               : happy
-       fi
+       test_must_fail has_cr dir/two &&
+       verbose has_cr one &&
+       test_must_fail has_cr three
 '
 
 test_expect_success '.gitattributes says two is input' '
@@ -256,13 +248,7 @@ test_expect_success '.gitattributes says two is input' '
        echo "two crlf=input" >.gitattributes &&
        git read-tree --reset -u HEAD &&
 
-       if has_cr dir/two
-       then
-               echo "Huh?"
-               false
-       else
-               : happy
-       fi
+       test_must_fail has_cr dir/two
 '
 
 test_expect_success '.gitattributes says two and three are text' '