]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t0003-attributes.sh
Merge branch 'en/ort-perf-batch-9'
[thirdparty/git.git] / t / t0003-attributes.sh
index b660593c20f8d4012e8c81e2276004708c2a1259..1e4c672b84aa366de04969b3c3f073c1f02ce92f 100755 (executable)
@@ -4,12 +4,16 @@ test_description=gitattributes
 
 . ./test-lib.sh
 
-attr_check () {
+attr_check_basic () {
        path="$1" expect="$2" git_opts="$3" &&
 
        git $git_opts check-attr test -- "$path" >actual 2>err &&
        echo "$path: test: $expect" >expect &&
-       test_cmp expect actual &&
+       test_cmp expect actual
+}
+
+attr_check () {
+       attr_check_basic "$@" &&
        test_must_be_empty err
 }
 
@@ -331,7 +335,6 @@ test_expect_success 'binary macro expanded by -a' '
        test_cmp expect actual
 '
 
-
 test_expect_success 'query binary macro directly' '
        echo "file binary" >.gitattributes &&
        echo file: binary: set >expect &&
@@ -339,4 +342,31 @@ test_expect_success 'query binary macro directly' '
        test_cmp expect actual
 '
 
+test_expect_success SYMLINKS 'set up symlink tests' '
+       echo "* test" >attr &&
+       rm -f .gitattributes
+'
+
+test_expect_success SYMLINKS 'symlinks respected in core.attributesFile' '
+       test_when_finished "rm symlink" &&
+       ln -s attr symlink &&
+       test_config core.attributesFile "$(pwd)/symlink" &&
+       attr_check file set
+'
+
+test_expect_success SYMLINKS 'symlinks respected in info/attributes' '
+       test_when_finished "rm .git/info/attributes" &&
+       ln -s ../../attr .git/info/attributes &&
+       attr_check file set
+'
+
+test_expect_success SYMLINKS 'symlinks not respected in-tree' '
+       test_when_finished "rm -rf .gitattributes subdir" &&
+       ln -s attr .gitattributes &&
+       mkdir subdir &&
+       ln -s ../attr subdir/.gitattributes &&
+       attr_check_basic subdir/file unspecified &&
+       test_i18ngrep "unable to access.*gitattributes" err
+'
+
 test_done