dir.c: don't exclude whole dir prematurely if neg pattern may match
[git/git.git] / t / t3001-ls-files-others-exclude.sh
index b2798fe..2a13af1 100755 (executable)
@@ -305,4 +305,29 @@ test_expect_success 'ls-files with "**" patterns and no slashes' '
        test_cmp expect actual
 '
 
        test_cmp expect actual
 '
 
+test_expect_success 'negative patterns' '
+       git init reinclude &&
+       (
+               cd reinclude &&
+               cat >.gitignore <<-\EOF &&
+               /fooo
+               /foo
+               !foo/bar/bar
+               EOF
+               mkdir fooo &&
+               cat >fooo/.gitignore <<-\EOF &&
+               !/*
+               EOF
+               mkdir -p foo/bar &&
+               touch abc foo/def foo/bar/ghi foo/bar/bar &&
+               git ls-files -o --exclude-standard >../actual &&
+               cat >../expected <<-\EOF &&
+               .gitignore
+               abc
+               foo/bar/bar
+               EOF
+               test_cmp ../expected ../actual
+       )
+'
+
 test_done
 test_done