]> Pileus Git - ~andy/git/blobdiff - t/t0020-crlf.sh
silence gcc array-bounds warning
[~andy/git] / t / t0020-crlf.sh
index 2bfeac986eadeca0064b1aee808d08b2f86082c4..4e72b53140bd35db87a6c873eda9e75e896e1cdd 100755 (executable)
@@ -52,7 +52,7 @@ test_expect_success 'safecrlf: autocrlf=input, all CRLF' '
        git config core.safecrlf true &&
 
        for w in I am all CRLF; do echo $w; done | append_cr >allcrlf &&
-       ! git add allcrlf
+       test_must_fail git add allcrlf
 '
 
 test_expect_success 'safecrlf: autocrlf=input, mixed LF/CRLF' '
@@ -61,7 +61,7 @@ test_expect_success 'safecrlf: autocrlf=input, mixed LF/CRLF' '
        git config core.safecrlf true &&
 
        for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >mixed &&
-       ! git add mixed
+       test_must_fail git add mixed
 '
 
 test_expect_success 'safecrlf: autocrlf=true, all LF' '
@@ -70,7 +70,7 @@ test_expect_success 'safecrlf: autocrlf=true, all LF' '
        git config core.safecrlf true &&
 
        for w in I am all LF; do echo $w; done >alllf &&
-       ! git add alllf
+       test_must_fail git add alllf
 '
 
 test_expect_success 'safecrlf: autocrlf=true mixed LF/CRLF' '
@@ -79,7 +79,7 @@ test_expect_success 'safecrlf: autocrlf=true mixed LF/CRLF' '
        git config core.safecrlf true &&
 
        for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >mixed &&
-       ! git add mixed
+       test_must_fail git add mixed
 '
 
 test_expect_success 'safecrlf: print warning only once' '
@@ -429,6 +429,37 @@ test_expect_success 'in-tree .gitattributes (4)' '
        }
 '
 
+test_expect_success 'checkout with existing .gitattributes' '
+
+       git config core.autocrlf true &&
+       git config --unset core.safecrlf &&
+       echo ".file2 -crlfQ" | q_to_cr >> .gitattributes &&
+       git add .gitattributes &&
+       git commit -m initial &&
+       echo ".file -crlfQ" | q_to_cr >> .gitattributes &&
+       echo "contents" > .file &&
+       git add .gitattributes .file &&
+       git commit -m second &&
+
+       git checkout master~1 &&
+       git checkout master &&
+       test "$(git diff-files --raw)" = ""
+
+'
+
+test_expect_success 'checkout when deleting .gitattributes' '
+
+       git rm .gitattributes &&
+       echo "contentsQ" | q_to_cr > .file2 &&
+       git add .file2 &&
+       git commit -m third
+
+       git checkout master~1 &&
+       git checkout master &&
+       remove_cr .file2 >/dev/null
+
+'
+
 test_expect_success 'invalid .gitattributes (must not crash)' '
 
        echo "three +crlf" >>.gitattributes &&