Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-02-15 12:03:39 +0300
committerJunio C Hamano <gitster@pobox.com>2016-02-16 02:32:33 +0300
commitd589a67eceacd1cc171bbe94906ca7c9a0edd8c5 (patch)
treefa380845f615c5f0742f6ff61bd20befbf06db77 /t/t3007-ls-files-other-negative.sh
parentc62a91736a6dcd909167cf9fbb751d65c85482dd (diff)
dir.c: don't exclude whole dir prematurely
If there is a pattern "!foo/bar", this patch makes it not exclude "foo" right away. This gives us a chance to examine "foo" and re-include "foo/bar". Helped-by: brian m. carlson <sandals@crustytoothpaste.net> Helped-by: Micha Wiedenmann <mw-u2@gmx.de> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3007-ls-files-other-negative.sh')
-rwxr-xr-xt/t3007-ls-files-other-negative.sh153
1 files changed, 153 insertions, 0 deletions
diff --git a/t/t3007-ls-files-other-negative.sh b/t/t3007-ls-files-other-negative.sh
new file mode 100755
index 0000000000..0797b86ad0
--- /dev/null
+++ b/t/t3007-ls-files-other-negative.sh
@@ -0,0 +1,153 @@
+#!/bin/sh
+
+test_description='test re-include patterns'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ mkdir -p fooo foo/bar tmp &&
+ touch abc foo/def foo/bar/ghi foo/bar/bar
+'
+
+test_expect_success 'no match, do not enter subdir and waste cycles' '
+ cat >.gitignore <<-\EOF &&
+ /tmp
+ /foo
+ !fooo/bar/bar
+ EOF
+ GIT_TRACE_EXCLUDE="$(pwd)/tmp/trace" git ls-files -o --exclude-standard >tmp/actual &&
+ ! grep "enter .foo/.\$" tmp/trace &&
+ cat >tmp/expected <<-\EOF &&
+ .gitignore
+ abc
+ EOF
+ test_cmp tmp/expected tmp/actual
+'
+
+test_expect_success 'match, excluded by literal pathname pattern' '
+ cat >.gitignore <<-\EOF &&
+ /tmp
+ /fooo
+ /foo
+ !foo/bar/bar
+ EOF
+ cat >fooo/.gitignore <<-\EOF &&
+ !/*
+ EOF git ls-files -o --exclude-standard >tmp/actual &&
+ cat >tmp/expected <<-\EOF &&
+ .gitignore
+ abc
+ foo/bar/bar
+ EOF
+ test_cmp tmp/expected tmp/actual
+'
+
+test_expect_success 'match, excluded by wildcard pathname pattern' '
+ cat >.gitignore <<-\EOF &&
+ /tmp
+ /fooo
+ /fo?
+ !foo/bar/bar
+ EOF
+ git ls-files -o --exclude-standard >tmp/actual &&
+ cat >tmp/expected <<-\EOF &&
+ .gitignore
+ abc
+ foo/bar/bar
+ EOF
+ test_cmp tmp/expected tmp/actual
+'
+
+test_expect_success 'match, excluded by literal basename pattern' '
+ cat >.gitignore <<-\EOF &&
+ /tmp
+ /fooo
+ foo
+ !foo/bar/bar
+ EOF
+ git ls-files -o --exclude-standard >tmp/actual &&
+ cat >tmp/expected <<-\EOF &&
+ .gitignore
+ abc
+ foo/bar/bar
+ EOF
+ test_cmp tmp/expected tmp/actual
+'
+
+test_expect_success 'match, excluded by wildcard basename pattern' '
+ cat >.gitignore <<-\EOF &&
+ /tmp
+ /fooo
+ fo?
+ !foo/bar/bar
+ EOF
+ git ls-files -o --exclude-standard >tmp/actual &&
+ cat >tmp/expected <<-\EOF &&
+ .gitignore
+ abc
+ foo/bar/bar
+ EOF
+ test_cmp tmp/expected tmp/actual
+'
+
+test_expect_success 'match, excluded by literal mustbedir, basename pattern' '
+ cat >.gitignore <<-\EOF &&
+ /tmp
+ /fooo
+ foo/
+ !foo/bar/bar
+ EOF
+ git ls-files -o --exclude-standard >tmp/actual &&
+ cat >tmp/expected <<-\EOF &&
+ .gitignore
+ abc
+ foo/bar/bar
+ EOF
+ test_cmp tmp/expected tmp/actual
+'
+
+test_expect_success 'match, excluded by literal mustbedir, pathname pattern' '
+ cat >.gitignore <<-\EOF &&
+ /tmp
+ /fooo
+ /foo/
+ !foo/bar/bar
+ EOF
+ git ls-files -o --exclude-standard >tmp/actual &&
+ cat >tmp/expected <<-\EOF &&
+ .gitignore
+ abc
+ foo/bar/bar
+ EOF
+ test_cmp tmp/expected tmp/actual
+'
+
+test_expect_success 'prepare for nested negatives' '
+ cat >.git/info/exclude <<-\EOF &&
+ /.gitignore
+ /tmp
+ /foo
+ /abc
+ EOF
+ git ls-files -o --exclude-standard >tmp/actual &&
+ test_must_be_empty tmp/actual &&
+ mkdir -p 1/2/3/4 &&
+ touch 1/f 1/2/f 1/2/3/f 1/2/3/4/f
+'
+
+test_expect_success 'match, literal pathname, nested negatives' '
+ cat >.gitignore <<-\EOF &&
+ /1
+ !1/2
+ 1/2/3
+ !1/2/3/4
+ EOF
+ git ls-files -o --exclude-standard >tmp/actual &&
+ cat >tmp/expected <<-\EOF &&
+ 1/2/3/4/f
+ 1/2/f
+ EOF
+ test_cmp tmp/expected tmp/actual
+'
+
+test_done