Code

sparse checkout: do not eagerly decide the fate for whole directory
[git.git] / t / t1011-read-tree-sparse-checkout.sh
index 3f9d66f0b2b41f32038724e81aa9e086f8967d99..20a50eba5b77e23b6e540402b4eabb311feabd0d 100755 (executable)
@@ -106,6 +106,47 @@ test_expect_success 'match directories without trailing slash' '
        test -f sub/added
 '
 
+test_expect_success 'match directories with negated patterns' '
+       cat >expected.swt-negation <<\EOF &&
+S init.t
+S sub/added
+H sub/addedtoo
+S subsub/added
+EOF
+
+       cat >.git/info/sparse-checkout <<\EOF &&
+sub
+!sub/added
+EOF
+       git read-tree -m -u HEAD &&
+       git ls-files -t >result &&
+       test_cmp expected.swt-negation result &&
+       test ! -f init.t &&
+       test ! -f sub/added &&
+       test -f sub/addedtoo
+'
+
+test_expect_success 'match directories with negated patterns (2)' '
+       cat >expected.swt-negation2 <<\EOF &&
+H init.t
+H sub/added
+S sub/addedtoo
+H subsub/added
+EOF
+
+       cat >.git/info/sparse-checkout <<\EOF &&
+/*
+!sub
+sub/added
+EOF
+       git read-tree -m -u HEAD &&
+       git ls-files -t >result &&
+       test_cmp expected.swt-negation2 result &&
+       test -f init.t &&
+       test -f sub/added &&
+       test ! -f sub/addedtoo
+'
+
 test_expect_success 'match directory pattern' '
        echo "s?b" >.git/info/sparse-checkout &&
        git read-tree -m -u HEAD &&