Code

Teach '--cached' option to check-attr
[git.git] / t / t0003-attributes.sh
index ae2f1da28fa55b92338d7dbcb6ef851b6ec40118..c0a45630be7204fde75632a5abea8f9aeda9f13d 100755 (executable)
@@ -134,10 +134,20 @@ test_expect_success 'attribute test: read paths from stdin' '
 
 test_expect_success 'attribute test: --all option' '
 
-       grep -v unspecified < expect-all | sort > expect &&
-       sed -e "s/:.*//" < expect-all | uniq |
-               git check-attr --stdin --all | sort > actual &&
-       test_cmp expect actual
+       grep -v unspecified <expect-all | sort >specified-all &&
+       sed -e "s/:.*//" <expect-all | uniq >stdin-all &&
+       git check-attr --stdin --all <stdin-all | sort >actual &&
+       test_cmp specified-all actual
+'
+
+test_expect_success 'attribute test: --cached option' '
+
+       : >empty &&
+       git check-attr --cached --stdin --all <stdin-all | sort >actual &&
+       test_cmp empty actual &&
+       git add .gitattributes a/.gitattributes a/b/.gitattributes &&
+       git check-attr --cached --stdin --all <stdin-all | sort >actual &&
+       test_cmp specified-all actual
 '
 
 test_expect_success 'root subdir attribute test' '
@@ -168,6 +178,13 @@ test_expect_success 'bare repository: check that .gitattribute is ignored' '
 
 '
 
+test_expect_success 'bare repository: check that --cached honors index' '
+       GIT_INDEX_FILE=../.git/index \
+       git check-attr --cached --stdin --all <../stdin-all |
+       sort >actual &&
+       test_cmp ../specified-all actual
+'
+
 test_expect_success 'bare repository: test info/attributes' '
 
        (