Merge branch 'main' of github.com:git/git
[alt-git.git] / t / t7061-wtstatus-ignore.sh
blob2f9bea9793cec8b2900c35b3add315b67192a882
1 #!/bin/sh
3 test_description='git-status ignored files'
5 . ./test-lib.sh
7 cat >expected <<\EOF
8 ?? .gitignore
9 ?? actual
10 ?? expected
11 ?? untracked/
12 !! untracked/ignored
13 EOF
15 test_expect_success 'status untracked directory with --ignored' '
16 echo "ignored" >.gitignore &&
17 mkdir untracked &&
18 : >untracked/ignored &&
19 : >untracked/uncommitted &&
20 git status --porcelain --ignored >actual &&
21 test_cmp expected actual
24 test_expect_success 'same with gitignore starting with BOM' '
25 printf "\357\273\277ignored\n" >.gitignore &&
26 mkdir -p untracked &&
27 : >untracked/ignored &&
28 : >untracked/uncommitted &&
29 git status --porcelain --ignored >actual &&
30 test_cmp expected actual
33 test_expect_success 'status untracked files --ignored with pathspec (no match)' '
34 git status --porcelain --ignored -- untracked/i >actual &&
35 test_must_be_empty actual &&
36 git status --porcelain --ignored -- untracked/u >actual &&
37 test_must_be_empty actual
40 test_expect_success 'status untracked files --ignored with pathspec (literal match)' '
41 git status --porcelain --ignored -- untracked/ignored >actual &&
42 echo "!! untracked/ignored" >expected &&
43 test_cmp expected actual &&
44 git status --porcelain --ignored -- untracked/uncommitted >actual &&
45 echo "?? untracked/uncommitted" >expected &&
46 test_cmp expected actual
49 test_expect_success 'status untracked files --ignored with pathspec (glob match)' '
50 git status --porcelain --ignored -- untracked/i\* >actual &&
51 echo "!! untracked/ignored" >expected &&
52 test_cmp expected actual &&
53 git status --porcelain --ignored -- untracked/u\* >actual &&
54 echo "?? untracked/uncommitted" >expected &&
55 test_cmp expected actual
58 cat >expected <<\EOF
59 ?? .gitignore
60 ?? actual
61 ?? expected
62 ?? untracked/uncommitted
63 !! untracked/ignored
64 EOF
66 test_expect_success 'status untracked directory with --ignored -u' '
67 git status --porcelain --ignored -u >actual &&
68 test_cmp expected actual
70 cat >expected <<\EOF
71 ?? untracked/
72 !! untracked/ignored
73 EOF
75 test_expect_success 'status of untracked directory with --ignored works with or without prefix' '
76 git status --porcelain --ignored >tmp &&
77 grep untracked/ tmp >actual &&
78 rm tmp &&
79 test_cmp expected actual &&
81 git status --porcelain --ignored untracked/ >actual &&
82 test_cmp expected actual
85 cat >expected <<\EOF
86 ?? untracked/uncommitted
87 !! untracked/ignored
88 EOF
90 test_expect_success 'status prefixed untracked sub-directory with --ignored -u' '
91 git status --porcelain --ignored -u untracked/ >actual &&
92 test_cmp expected actual
95 cat >expected <<\EOF
96 ?? .gitignore
97 ?? actual
98 ?? expected
99 !! ignored/
102 test_expect_success 'status ignored directory with --ignore' '
103 rm -rf untracked &&
104 mkdir ignored &&
105 : >ignored/uncommitted &&
106 git status --porcelain --ignored >actual &&
107 test_cmp expected actual
110 cat >expected <<\EOF
111 ?? .gitignore
112 ?? actual
113 ?? expected
114 !! ignored/uncommitted
117 test_expect_success 'status ignored directory with --ignore -u' '
118 git status --porcelain --ignored -u >actual &&
119 test_cmp expected actual
122 cat >expected <<\EOF
123 ?? .gitignore
124 ?? actual
125 ?? expected
128 test_expect_success 'status empty untracked directory with --ignore' '
129 rm -rf ignored &&
130 mkdir untracked-ignored &&
131 mkdir untracked-ignored/test &&
132 git status --porcelain --ignored >actual &&
133 test_cmp expected actual
136 cat >expected <<\EOF
137 ?? .gitignore
138 ?? actual
139 ?? expected
142 test_expect_success 'status empty untracked directory with --ignore -u' '
143 git status --porcelain --ignored -u >actual &&
144 test_cmp expected actual
147 cat >expected <<\EOF
148 ?? .gitignore
149 ?? actual
150 ?? expected
151 !! untracked-ignored/
154 test_expect_success 'status untracked directory with ignored files with --ignore' '
155 : >untracked-ignored/ignored &&
156 : >untracked-ignored/test/ignored &&
157 git status --porcelain --ignored >actual &&
158 test_cmp expected actual
161 cat >expected <<\EOF
162 ?? .gitignore
163 ?? actual
164 ?? expected
165 !! untracked-ignored/ignored
166 !! untracked-ignored/test/ignored
169 test_expect_success 'status untracked directory with ignored files with --ignore -u' '
170 git status --porcelain --ignored -u >actual &&
171 test_cmp expected actual
174 cat >expected <<\EOF
175 ?? .gitignore
176 ?? actual
177 ?? expected
180 test_expect_success 'status ignored tracked directory with --ignore' '
181 rm -rf untracked-ignored &&
182 mkdir tracked &&
183 : >tracked/committed &&
184 git add tracked/committed &&
185 git commit -m. &&
186 echo "tracked" >.gitignore &&
187 git status --porcelain --ignored >actual &&
188 test_cmp expected actual
191 cat >expected <<\EOF
192 ?? .gitignore
193 ?? actual
194 ?? expected
197 test_expect_success 'status ignored tracked directory with --ignore -u' '
198 git status --porcelain --ignored -u >actual &&
199 test_cmp expected actual
202 cat >expected <<\EOF
203 ?? .gitignore
204 ?? actual
205 ?? expected
208 test_expect_success 'status ignored tracked directory and ignored file with --ignore' '
209 echo "committed" >>.gitignore &&
210 git status --porcelain --ignored >actual &&
211 test_cmp expected actual
214 cat >expected <<\EOF
215 ?? .gitignore
216 ?? actual
217 ?? expected
220 test_expect_success 'status ignored tracked directory and ignored file with --ignore -u' '
221 git status --porcelain --ignored -u >actual &&
222 test_cmp expected actual
225 cat >expected <<\EOF
226 ?? .gitignore
227 ?? actual
228 ?? expected
229 !! tracked/uncommitted
232 test_expect_success 'status ignored tracked directory and uncommitted file with --ignore' '
233 echo "tracked" >.gitignore &&
234 : >tracked/uncommitted &&
235 git status --porcelain --ignored >actual &&
236 test_cmp expected actual
239 cat >expected <<\EOF
240 ?? .gitignore
241 ?? actual
242 ?? expected
243 !! tracked/uncommitted
246 test_expect_success 'status ignored tracked directory and uncommitted file with --ignore -u' '
247 git status --porcelain --ignored -u >actual &&
248 test_cmp expected actual
251 cat >expected <<\EOF
252 ?? .gitignore
253 ?? actual
254 ?? expected
255 !! tracked/ignored/
258 test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore' '
259 rm -rf tracked/uncommitted &&
260 mkdir tracked/ignored &&
261 : >tracked/ignored/uncommitted &&
262 git status --porcelain --ignored >actual &&
263 test_cmp expected actual
266 cat >expected <<\EOF
267 ?? .gitignore
268 ?? actual
269 ?? expected
270 !! tracked/ignored/uncommitted
273 test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore -u' '
274 git status --porcelain --ignored -u >actual &&
275 test_cmp expected actual
278 cat >expected <<\EOF
279 ?? .gitignore
280 ?? actual
281 ?? expected
282 !! tracked/ignored/uncommitted
285 test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore' '
286 : >tracked/ignored/committed &&
287 git add -f tracked/ignored/committed &&
288 git commit -m. &&
289 git status --porcelain --ignored >actual &&
290 test_cmp expected actual
293 cat >expected <<\EOF
294 ?? .gitignore
295 ?? actual
296 ?? expected
297 !! tracked/ignored/uncommitted
300 test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore -u' '
301 git status --porcelain --ignored -u >actual &&
302 test_cmp expected actual
305 cat >expected <<\EOF
306 !! tracked/submodule/
309 test_expect_success 'status ignores submodule in excluded directory' '
310 git init tracked/submodule &&
311 test_commit -C tracked/submodule initial &&
312 git status --porcelain --ignored -u tracked/submodule >actual &&
313 test_cmp expected actual
316 test_done