read-tree: note about dropping split-index mode or index version
[gitweb.git] / t / t0003-attributes.sh
index 1035a14b37203202a5476f65d07f9bc505bfb52c..f0fbb425545019a6275a347a5826f6ba2977d394 100755 (executable)
@@ -13,7 +13,6 @@ attr_check () {
        test_line_count = 0 err
 }
 
-
 test_expect_success 'setup' '
        mkdir -p a/b/d a/c b &&
        (
@@ -207,40 +206,95 @@ test_expect_success 'patterns starting with exclamation' '
        attr_check "!f" foo
 '
 
+test_expect_success '"**" test' '
+       echo "**/f foo=bar" >.gitattributes &&
+       cat <<\EOF >expect &&
+f: foo: bar
+a/f: foo: bar
+a/b/f: foo: bar
+a/b/c/f: foo: bar
+EOF
+       git check-attr foo -- "f" >actual 2>err &&
+       git check-attr foo -- "a/f" >>actual 2>>err &&
+       git check-attr foo -- "a/b/f" >>actual 2>>err &&
+       git check-attr foo -- "a/b/c/f" >>actual 2>>err &&
+       test_cmp expect actual &&
+       test_line_count = 0 err
+'
+
+test_expect_success '"**" with no slashes test' '
+       echo "a**f foo=bar" >.gitattributes &&
+       git check-attr foo -- "f" >actual &&
+       cat <<\EOF >expect &&
+f: foo: unspecified
+af: foo: bar
+axf: foo: bar
+a/f: foo: unspecified
+a/b/f: foo: unspecified
+a/b/c/f: foo: unspecified
+EOF
+       git check-attr foo -- "f" >actual 2>err &&
+       git check-attr foo -- "af" >>actual 2>err &&
+       git check-attr foo -- "axf" >>actual 2>err &&
+       git check-attr foo -- "a/f" >>actual 2>>err &&
+       git check-attr foo -- "a/b/f" >>actual 2>>err &&
+       git check-attr foo -- "a/b/c/f" >>actual 2>>err &&
+       test_cmp expect actual &&
+       test_line_count = 0 err
+'
+
+test_expect_success 'using --git-dir and --work-tree' '
+       mkdir unreal real &&
+       git init real &&
+       echo "file test=in-real" >real/.gitattributes &&
+       (
+               cd unreal &&
+               attr_check file in-real "--git-dir ../real/.git --work-tree ../real"
+       )
+'
+
 test_expect_success 'setup bare' '
-       git clone --bare . bare.git &&
-       cd bare.git
+       git clone --bare . bare.git
 '
 
 test_expect_success 'bare repository: check that .gitattribute is ignored' '
        (
-               echo "f test=f"
-               echo "a/i test=a/i"
-       ) >.gitattributes &&
-       attr_check f unspecified &&
-       attr_check a/f unspecified &&
-       attr_check a/c/f unspecified &&
-       attr_check a/i unspecified &&
-       attr_check subdir/a/i unspecified
+               cd bare.git &&
+               (
+                       echo "f test=f"
+                       echo "a/i test=a/i"
+               ) >.gitattributes &&
+               attr_check f unspecified &&
+               attr_check a/f unspecified &&
+               attr_check a/c/f unspecified &&
+               attr_check a/i unspecified &&
+               attr_check subdir/a/i unspecified
+       )
 '
 
 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
+       (
+               cd bare.git &&
+               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' '
        (
-               echo "f test=f"
-               echo "a/i test=a/i"
-       ) >info/attributes &&
-       attr_check f f &&
-       attr_check a/f f &&
-       attr_check a/c/f f &&
-       attr_check a/i a/i &&
-       attr_check subdir/a/i unspecified
+               cd bare.git &&
+               (
+                       echo "f test=f"
+                       echo "a/i test=a/i"
+               ) >info/attributes &&
+               attr_check f f &&
+               attr_check a/f f &&
+               attr_check a/c/f f &&
+               attr_check a/i a/i &&
+               attr_check subdir/a/i unspecified
+       )
 '
 
 test_done