Merge branch 'jc/exclusion-doc'
[alt-git.git] / t / t3007-ls-files-other-negative.sh
blob0797b86ad0fb19cf42d51f001f509dbb44f1e210
1 #!/bin/sh
3 test_description='test re-include patterns'
5 . ./test-lib.sh
7 test_expect_success 'setup' '
8 mkdir -p fooo foo/bar tmp &&
9 touch abc foo/def foo/bar/ghi foo/bar/bar
12 test_expect_success 'no match, do not enter subdir and waste cycles' '
13 cat >.gitignore <<-\EOF &&
14 /tmp
15 /foo
16 !fooo/bar/bar
17 EOF
18 GIT_TRACE_EXCLUDE="$(pwd)/tmp/trace" git ls-files -o --exclude-standard >tmp/actual &&
19 ! grep "enter .foo/.\$" tmp/trace &&
20 cat >tmp/expected <<-\EOF &&
21 .gitignore
22 abc
23 EOF
24 test_cmp tmp/expected tmp/actual
27 test_expect_success 'match, excluded by literal pathname pattern' '
28 cat >.gitignore <<-\EOF &&
29 /tmp
30 /fooo
31 /foo
32 !foo/bar/bar
33 EOF
34 cat >fooo/.gitignore <<-\EOF &&
35 !/*
36 EOF git ls-files -o --exclude-standard >tmp/actual &&
37 cat >tmp/expected <<-\EOF &&
38 .gitignore
39 abc
40 foo/bar/bar
41 EOF
42 test_cmp tmp/expected tmp/actual
45 test_expect_success 'match, excluded by wildcard pathname pattern' '
46 cat >.gitignore <<-\EOF &&
47 /tmp
48 /fooo
49 /fo?
50 !foo/bar/bar
51 EOF
52 git ls-files -o --exclude-standard >tmp/actual &&
53 cat >tmp/expected <<-\EOF &&
54 .gitignore
55 abc
56 foo/bar/bar
57 EOF
58 test_cmp tmp/expected tmp/actual
61 test_expect_success 'match, excluded by literal basename pattern' '
62 cat >.gitignore <<-\EOF &&
63 /tmp
64 /fooo
65 foo
66 !foo/bar/bar
67 EOF
68 git ls-files -o --exclude-standard >tmp/actual &&
69 cat >tmp/expected <<-\EOF &&
70 .gitignore
71 abc
72 foo/bar/bar
73 EOF
74 test_cmp tmp/expected tmp/actual
77 test_expect_success 'match, excluded by wildcard basename pattern' '
78 cat >.gitignore <<-\EOF &&
79 /tmp
80 /fooo
81 fo?
82 !foo/bar/bar
83 EOF
84 git ls-files -o --exclude-standard >tmp/actual &&
85 cat >tmp/expected <<-\EOF &&
86 .gitignore
87 abc
88 foo/bar/bar
89 EOF
90 test_cmp tmp/expected tmp/actual
93 test_expect_success 'match, excluded by literal mustbedir, basename pattern' '
94 cat >.gitignore <<-\EOF &&
95 /tmp
96 /fooo
97 foo/
98 !foo/bar/bar
99 EOF
100 git ls-files -o --exclude-standard >tmp/actual &&
101 cat >tmp/expected <<-\EOF &&
102 .gitignore
104 foo/bar/bar
106 test_cmp tmp/expected tmp/actual
109 test_expect_success 'match, excluded by literal mustbedir, pathname pattern' '
110 cat >.gitignore <<-\EOF &&
111 /tmp
112 /fooo
113 /foo/
114 !foo/bar/bar
116 git ls-files -o --exclude-standard >tmp/actual &&
117 cat >tmp/expected <<-\EOF &&
118 .gitignore
120 foo/bar/bar
122 test_cmp tmp/expected tmp/actual
125 test_expect_success 'prepare for nested negatives' '
126 cat >.git/info/exclude <<-\EOF &&
127 /.gitignore
128 /tmp
129 /foo
130 /abc
132 git ls-files -o --exclude-standard >tmp/actual &&
133 test_must_be_empty tmp/actual &&
134 mkdir -p 1/2/3/4 &&
135 touch 1/f 1/2/f 1/2/3/f 1/2/3/4/f
138 test_expect_success 'match, literal pathname, nested negatives' '
139 cat >.gitignore <<-\EOF &&
141 !1/2
142 1/2/3
143 !1/2/3/4
145 git ls-files -o --exclude-standard >tmp/actual &&
146 cat >tmp/expected <<-\EOF &&
147 1/2/3/4/f
148 1/2/f
150 test_cmp tmp/expected tmp/actual
153 test_done