blob: 0797b86ad0fb19cf42d51f001f509dbb44f1e210 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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
|