Code

read-cache.c: fix index memory allocation
[git.git] / t / t0003-attributes.sh
index a49f8a9813b81a1db41f22a2843e03abbc2aa61c..ae2f1da28fa55b92338d7dbcb6ef851b6ec40118 100755 (executable)
@@ -9,16 +9,17 @@ attr_check () {
        path="$1"
        expect="$2"
 
-       git check-attr test -- "$path" >actual &&
+       git check-attr test -- "$path" >actual 2>err &&
        echo "$path: test: $2" >expect &&
-       test_cmp expect actual
+       test_cmp expect actual &&
+       test_line_count = 0 err
 
 }
 
 
 test_expect_success 'setup' '
 
-       mkdir -p a/b/d a/c &&
+       mkdir -p a/b/d a/c &&
        (
                echo "[attr]notest !test"
                echo "f test=f"
@@ -70,7 +71,6 @@ test_expect_success 'command line checks' '
        echo "f" | test_must_fail git check-attr --stdin &&
        echo "f" | test_must_fail git check-attr --stdin -- f &&
        echo "f" | test_must_fail git check-attr --stdin test -- f &&
-       echo "f" | test_must_fail git check-attr --stdin test f &&
        test_must_fail git check-attr "" -- f
 
 '
@@ -93,6 +93,28 @@ test_expect_success 'attribute test' '
 
 '
 
+test_expect_success 'unnormalized paths' '
+
+       attr_check ./f f &&
+       attr_check ./a/g a/g &&
+       attr_check a/./g a/g &&
+       attr_check a/c/../b/g a/b/g
+
+'
+
+test_expect_success 'relative paths' '
+
+       (cd a && attr_check ../f f) &&
+       (cd a && attr_check f f) &&
+       (cd a && attr_check i a/i) &&
+       (cd a && attr_check g a/g) &&
+       (cd a && attr_check b/g a/b/g) &&
+       (cd b && attr_check ../a/f f) &&
+       (cd b && attr_check ../a/g a/g) &&
+       (cd b && attr_check ../a/b/g a/b/g)
+
+'
+
 test_expect_success 'core.attributesfile' '
        attr_check global unspecified &&
        git config core.attributesfile "$HOME/global-gitattributes" &&