]>
Commit | Line | Data |
---|---|---|
367c9886 JS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Johannes E. Schindelin | |
4 | # | |
5 | ||
47a528ad | 6 | test_description='git status' |
367c9886 JS |
7 | |
8 | . ./test-lib.sh | |
9 | ||
5d3dd915 NTND |
10 | test_expect_success 'status -h in broken repository' ' |
11 | mkdir broken && | |
12 | test_when_finished "rm -fr broken" && | |
13 | ( | |
14 | cd broken && | |
15 | git init && | |
16 | echo "[status] showuntrackedfiles = CORRUPT" >>.git/config && | |
17 | test_expect_code 129 git status -h >usage 2>&1 | |
18 | ) && | |
cc6658e7 | 19 | test_i18ngrep "[Uu]sage" broken/usage |
5d3dd915 NTND |
20 | ' |
21 | ||
22 | test_expect_success 'commit -h in broken repository' ' | |
23 | mkdir broken && | |
24 | test_when_finished "rm -fr broken" && | |
25 | ( | |
26 | cd broken && | |
27 | git init && | |
28 | echo "[status] showuntrackedfiles = CORRUPT" >>.git/config && | |
29 | test_expect_code 129 git commit -h >usage 2>&1 | |
30 | ) && | |
cc6658e7 | 31 | test_i18ngrep "[Uu]sage" broken/usage |
5d3dd915 NTND |
32 | ' |
33 | ||
367c9886 | 34 | test_expect_success 'setup' ' |
68cfc6f5 MG |
35 | : >tracked && |
36 | : >modified && | |
367c9886 | 37 | mkdir dir1 && |
68cfc6f5 MG |
38 | : >dir1/tracked && |
39 | : >dir1/modified && | |
367c9886 | 40 | mkdir dir2 && |
68cfc6f5 MG |
41 | : >dir1/tracked && |
42 | : >dir1/modified && | |
367c9886 | 43 | git add . && |
ff58b9aa JK |
44 | |
45 | git status >output && | |
46 | ||
367c9886 JS |
47 | test_tick && |
48 | git commit -m initial && | |
68cfc6f5 MG |
49 | : >untracked && |
50 | : >dir1/untracked && | |
51 | : >dir2/untracked && | |
52 | echo 1 >dir1/modified && | |
53 | echo 2 >dir2/modified && | |
54 | echo 3 >dir2/added && | |
367c9886 JS |
55 | git add dir2/added |
56 | ' | |
57 | ||
cc6658e7 JH |
58 | test_expect_success 'status (1)' ' |
59 | test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output | |
ff58b9aa JK |
60 | ' |
61 | ||
68cfc6f5 | 62 | cat >expect <<\EOF |
367c9886 JS |
63 | # On branch master |
64 | # Changes to be committed: | |
65 | # (use "git reset HEAD <file>..." to unstage) | |
66 | # | |
67 | # new file: dir2/added | |
68 | # | |
8009d83c | 69 | # Changes not staged for commit: |
367c9886 | 70 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 71 | # (use "git checkout -- <file>..." to discard changes in working directory) |
367c9886 JS |
72 | # |
73 | # modified: dir1/modified | |
74 | # | |
75 | # Untracked files: | |
76 | # (use "git add <file>..." to include in what will be committed) | |
77 | # | |
78 | # dir1/untracked | |
79 | # dir2/modified | |
80 | # dir2/untracked | |
81 | # expect | |
82 | # output | |
83 | # untracked | |
84 | EOF | |
85 | ||
cc6658e7 | 86 | test_expect_success 'status (2)' ' |
68cfc6f5 | 87 | git status >output && |
cc6658e7 | 88 | test_i18ncmp expect output |
367c9886 JS |
89 | ' |
90 | ||
18f3b5a9 MG |
91 | cat >expect <<\EOF |
92 | # On branch master | |
93 | # Changes to be committed: | |
94 | # new file: dir2/added | |
95 | # | |
8009d83c | 96 | # Changes not staged for commit: |
18f3b5a9 MG |
97 | # modified: dir1/modified |
98 | # | |
99 | # Untracked files: | |
100 | # dir1/untracked | |
101 | # dir2/modified | |
102 | # dir2/untracked | |
103 | # expect | |
104 | # output | |
105 | # untracked | |
106 | EOF | |
107 | ||
cc6658e7 JH |
108 | test_expect_success 'status (advice.statusHints false)' ' |
109 | test_when_finished "git config --unset advice.statusHints" && | |
110 | git config advice.statusHints false && | |
18f3b5a9 | 111 | git status >output && |
cc6658e7 | 112 | test_i18ncmp expect output |
18f3b5a9 MG |
113 | |
114 | ' | |
115 | ||
68cfc6f5 | 116 | cat >expect <<\EOF |
14ed05dd MG |
117 | M dir1/modified |
118 | A dir2/added | |
119 | ?? dir1/untracked | |
120 | ?? dir2/modified | |
121 | ?? dir2/untracked | |
122 | ?? expect | |
123 | ?? output | |
124 | ?? untracked | |
125 | EOF | |
126 | ||
46077fa5 | 127 | test_expect_success 'status -s' ' |
14ed05dd | 128 | |
68cfc6f5 | 129 | git status -s >output && |
14ed05dd MG |
130 | test_cmp expect output |
131 | ||
132 | ' | |
133 | ||
150b493a JH |
134 | test_expect_success 'status with gitignore' ' |
135 | { | |
136 | echo ".gitignore" && | |
137 | echo "expect" && | |
138 | echo "output" && | |
139 | echo "untracked" | |
140 | } >.gitignore && | |
141 | ||
142 | cat >expect <<-\EOF && | |
143 | M dir1/modified | |
144 | A dir2/added | |
145 | ?? dir2/modified | |
146 | EOF | |
147 | git status -s >output && | |
148 | test_cmp expect output && | |
149 | ||
150 | cat >expect <<-\EOF && | |
151 | M dir1/modified | |
152 | A dir2/added | |
153 | ?? dir2/modified | |
154 | !! .gitignore | |
155 | !! dir1/untracked | |
156 | !! dir2/untracked | |
157 | !! expect | |
158 | !! output | |
159 | !! untracked | |
160 | EOF | |
161 | git status -s --ignored >output && | |
162 | test_cmp expect output && | |
163 | ||
164 | cat >expect <<-\EOF && | |
165 | # On branch master | |
166 | # Changes to be committed: | |
167 | # (use "git reset HEAD <file>..." to unstage) | |
168 | # | |
169 | # new file: dir2/added | |
170 | # | |
50cebdad | 171 | # Changes not staged for commit: |
150b493a JH |
172 | # (use "git add <file>..." to update what will be committed) |
173 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
174 | # | |
175 | # modified: dir1/modified | |
176 | # | |
177 | # Untracked files: | |
178 | # (use "git add <file>..." to include in what will be committed) | |
179 | # | |
180 | # dir2/modified | |
181 | # Ignored files: | |
182 | # (use "git add -f <file>..." to include in what will be committed) | |
183 | # | |
184 | # .gitignore | |
185 | # dir1/untracked | |
186 | # dir2/untracked | |
187 | # expect | |
188 | # output | |
189 | # untracked | |
190 | EOF | |
191 | git status --ignored >output && | |
ca0f515d | 192 | test_i18ncmp expect output |
150b493a JH |
193 | ' |
194 | ||
195 | test_expect_success 'status with gitignore (nothing untracked)' ' | |
196 | { | |
197 | echo ".gitignore" && | |
198 | echo "expect" && | |
199 | echo "dir2/modified" && | |
200 | echo "output" && | |
201 | echo "untracked" | |
202 | } >.gitignore && | |
203 | ||
204 | cat >expect <<-\EOF && | |
205 | M dir1/modified | |
206 | A dir2/added | |
207 | EOF | |
208 | git status -s >output && | |
209 | test_cmp expect output && | |
210 | ||
211 | cat >expect <<-\EOF && | |
212 | M dir1/modified | |
213 | A dir2/added | |
214 | !! .gitignore | |
215 | !! dir1/untracked | |
216 | !! dir2/modified | |
217 | !! dir2/untracked | |
218 | !! expect | |
219 | !! output | |
220 | !! untracked | |
221 | EOF | |
222 | git status -s --ignored >output && | |
223 | test_cmp expect output && | |
224 | ||
225 | cat >expect <<-\EOF && | |
226 | # On branch master | |
227 | # Changes to be committed: | |
228 | # (use "git reset HEAD <file>..." to unstage) | |
229 | # | |
230 | # new file: dir2/added | |
231 | # | |
50cebdad | 232 | # Changes not staged for commit: |
150b493a JH |
233 | # (use "git add <file>..." to update what will be committed) |
234 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
235 | # | |
236 | # modified: dir1/modified | |
237 | # | |
238 | # Ignored files: | |
239 | # (use "git add -f <file>..." to include in what will be committed) | |
240 | # | |
241 | # .gitignore | |
242 | # dir1/untracked | |
243 | # dir2/modified | |
244 | # dir2/untracked | |
245 | # expect | |
246 | # output | |
247 | # untracked | |
248 | EOF | |
249 | git status --ignored >output && | |
ca0f515d | 250 | test_i18ncmp expect output |
150b493a JH |
251 | ' |
252 | ||
253 | rm -f .gitignore | |
254 | ||
46077fa5 MG |
255 | cat >expect <<\EOF |
256 | ## master | |
257 | M dir1/modified | |
258 | A dir2/added | |
259 | ?? dir1/untracked | |
260 | ?? dir2/modified | |
261 | ?? dir2/untracked | |
262 | ?? expect | |
263 | ?? output | |
264 | ?? untracked | |
265 | EOF | |
266 | ||
267 | test_expect_success 'status -s -b' ' | |
268 | ||
269 | git status -s -b >output && | |
270 | test_cmp expect output | |
271 | ||
272 | ' | |
273 | ||
a5985237 JK |
274 | test_expect_success 'status -s -z -b' ' |
275 | tr "\\n" Q <expect >expect.q && | |
276 | mv expect.q expect && | |
277 | git status -s -z -b >output && | |
278 | nul_to_q <output >output.q && | |
279 | mv output.q output && | |
280 | test_cmp expect output | |
281 | ' | |
282 | ||
355ec7a1 ÆAB |
283 | test_expect_success 'setup dir3' ' |
284 | mkdir dir3 && | |
285 | : >dir3/untracked1 && | |
286 | : >dir3/untracked2 | |
287 | ' | |
288 | ||
6c2ce048 MSO |
289 | cat >expect <<EOF |
290 | # On branch master | |
291 | # Changes to be committed: | |
292 | # (use "git reset HEAD <file>..." to unstage) | |
293 | # | |
294 | # new file: dir2/added | |
295 | # | |
8009d83c | 296 | # Changes not staged for commit: |
6c2ce048 | 297 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 298 | # (use "git checkout -- <file>..." to discard changes in working directory) |
6c2ce048 MSO |
299 | # |
300 | # modified: dir1/modified | |
301 | # | |
302 | # Untracked files not listed (use -u option to show untracked files) | |
303 | EOF | |
cc6658e7 | 304 | test_expect_success 'status -uno' ' |
6c2ce048 | 305 | git status -uno >output && |
cc6658e7 | 306 | test_i18ncmp expect output |
6c2ce048 MSO |
307 | ' |
308 | ||
cc6658e7 | 309 | test_expect_success 'status (status.showUntrackedFiles no)' ' |
d6293d1f | 310 | git config status.showuntrackedfiles no |
355ec7a1 | 311 | test_when_finished "git config --unset status.showuntrackedfiles" && |
d6293d1f | 312 | git status >output && |
cc6658e7 | 313 | test_i18ncmp expect output |
d6293d1f MSO |
314 | ' |
315 | ||
18f3b5a9 MG |
316 | cat >expect <<EOF |
317 | # On branch master | |
318 | # Changes to be committed: | |
319 | # new file: dir2/added | |
320 | # | |
8009d83c | 321 | # Changes not staged for commit: |
18f3b5a9 MG |
322 | # modified: dir1/modified |
323 | # | |
980bde38 | 324 | # Untracked files not listed |
18f3b5a9 MG |
325 | EOF |
326 | git config advice.statusHints false | |
cc6658e7 | 327 | test_expect_success 'status -uno (advice.statusHints false)' ' |
18f3b5a9 | 328 | git status -uno >output && |
cc6658e7 | 329 | test_i18ncmp expect output |
18f3b5a9 MG |
330 | ' |
331 | git config --unset advice.statusHints | |
332 | ||
14ed05dd MG |
333 | cat >expect << EOF |
334 | M dir1/modified | |
335 | A dir2/added | |
336 | EOF | |
337 | test_expect_success 'status -s -uno' ' | |
14ed05dd MG |
338 | git status -s -uno >output && |
339 | test_cmp expect output | |
340 | ' | |
341 | ||
342 | test_expect_success 'status -s (status.showUntrackedFiles no)' ' | |
343 | git config status.showuntrackedfiles no | |
344 | git status -s >output && | |
345 | test_cmp expect output | |
346 | ' | |
347 | ||
4bfee30a MSO |
348 | cat >expect <<EOF |
349 | # On branch master | |
350 | # Changes to be committed: | |
351 | # (use "git reset HEAD <file>..." to unstage) | |
352 | # | |
353 | # new file: dir2/added | |
354 | # | |
8009d83c | 355 | # Changes not staged for commit: |
4bfee30a | 356 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 357 | # (use "git checkout -- <file>..." to discard changes in working directory) |
4bfee30a MSO |
358 | # |
359 | # modified: dir1/modified | |
360 | # | |
361 | # Untracked files: | |
362 | # (use "git add <file>..." to include in what will be committed) | |
363 | # | |
364 | # dir1/untracked | |
365 | # dir2/modified | |
366 | # dir2/untracked | |
367 | # dir3/ | |
368 | # expect | |
369 | # output | |
370 | # untracked | |
371 | EOF | |
cc6658e7 | 372 | test_expect_success 'status -unormal' ' |
4bfee30a | 373 | git status -unormal >output && |
cc6658e7 | 374 | test_i18ncmp expect output |
4bfee30a MSO |
375 | ' |
376 | ||
cc6658e7 | 377 | test_expect_success 'status (status.showUntrackedFiles normal)' ' |
d6293d1f | 378 | git config status.showuntrackedfiles normal |
355ec7a1 | 379 | test_when_finished "git config --unset status.showuntrackedfiles" && |
d6293d1f | 380 | git status >output && |
cc6658e7 | 381 | test_i18ncmp expect output |
d6293d1f MSO |
382 | ' |
383 | ||
14ed05dd MG |
384 | cat >expect <<EOF |
385 | M dir1/modified | |
386 | A dir2/added | |
387 | ?? dir1/untracked | |
388 | ?? dir2/modified | |
389 | ?? dir2/untracked | |
390 | ?? dir3/ | |
391 | ?? expect | |
392 | ?? output | |
393 | ?? untracked | |
394 | EOF | |
395 | test_expect_success 'status -s -unormal' ' | |
14ed05dd MG |
396 | git status -s -unormal >output && |
397 | test_cmp expect output | |
398 | ' | |
399 | ||
400 | test_expect_success 'status -s (status.showUntrackedFiles normal)' ' | |
401 | git config status.showuntrackedfiles normal | |
402 | git status -s >output && | |
403 | test_cmp expect output | |
404 | ' | |
405 | ||
4bfee30a MSO |
406 | cat >expect <<EOF |
407 | # On branch master | |
408 | # Changes to be committed: | |
409 | # (use "git reset HEAD <file>..." to unstage) | |
410 | # | |
411 | # new file: dir2/added | |
412 | # | |
8009d83c | 413 | # Changes not staged for commit: |
4bfee30a | 414 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 415 | # (use "git checkout -- <file>..." to discard changes in working directory) |
4bfee30a MSO |
416 | # |
417 | # modified: dir1/modified | |
418 | # | |
419 | # Untracked files: | |
420 | # (use "git add <file>..." to include in what will be committed) | |
421 | # | |
422 | # dir1/untracked | |
423 | # dir2/modified | |
424 | # dir2/untracked | |
425 | # dir3/untracked1 | |
426 | # dir3/untracked2 | |
427 | # expect | |
428 | # output | |
429 | # untracked | |
430 | EOF | |
cc6658e7 | 431 | test_expect_success 'status -uall' ' |
4bfee30a | 432 | git status -uall >output && |
cc6658e7 | 433 | test_i18ncmp expect output |
d6293d1f | 434 | ' |
cc6658e7 JH |
435 | |
436 | test_expect_success 'status (status.showUntrackedFiles all)' ' | |
d6293d1f | 437 | git config status.showuntrackedfiles all |
355ec7a1 | 438 | test_when_finished "git config --unset status.showuntrackedfiles" && |
d6293d1f | 439 | git status >output && |
cc6658e7 | 440 | test_i18ncmp expect output |
4bfee30a MSO |
441 | ' |
442 | ||
355ec7a1 ÆAB |
443 | test_expect_success 'teardown dir3' ' |
444 | rm -rf dir3 | |
445 | ' | |
446 | ||
14ed05dd MG |
447 | cat >expect <<EOF |
448 | M dir1/modified | |
449 | A dir2/added | |
450 | ?? dir1/untracked | |
451 | ?? dir2/modified | |
452 | ?? dir2/untracked | |
453 | ?? expect | |
454 | ?? output | |
455 | ?? untracked | |
456 | EOF | |
457 | test_expect_success 'status -s -uall' ' | |
458 | git config --unset status.showuntrackedfiles | |
459 | git status -s -uall >output && | |
460 | test_cmp expect output | |
461 | ' | |
462 | test_expect_success 'status -s (status.showUntrackedFiles all)' ' | |
463 | git config status.showuntrackedfiles all | |
464 | git status -s >output && | |
465 | rm -rf dir3 && | |
466 | git config --unset status.showuntrackedfiles && | |
467 | test_cmp expect output | |
468 | ' | |
469 | ||
68cfc6f5 | 470 | cat >expect <<\EOF |
367c9886 JS |
471 | # On branch master |
472 | # Changes to be committed: | |
473 | # (use "git reset HEAD <file>..." to unstage) | |
474 | # | |
475 | # new file: ../dir2/added | |
476 | # | |
8009d83c | 477 | # Changes not staged for commit: |
367c9886 | 478 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 479 | # (use "git checkout -- <file>..." to discard changes in working directory) |
367c9886 | 480 | # |
69e74918 | 481 | # modified: modified |
367c9886 JS |
482 | # |
483 | # Untracked files: | |
484 | # (use "git add <file>..." to include in what will be committed) | |
485 | # | |
486 | # untracked | |
487 | # ../dir2/modified | |
488 | # ../dir2/untracked | |
489 | # ../expect | |
490 | # ../output | |
491 | # ../untracked | |
492 | EOF | |
493 | ||
cc6658e7 | 494 | test_expect_success 'status with relative paths' ' |
68cfc6f5 | 495 | (cd dir1 && git status) >output && |
cc6658e7 | 496 | test_i18ncmp expect output |
367c9886 JS |
497 | ' |
498 | ||
68cfc6f5 | 499 | cat >expect <<\EOF |
14ed05dd MG |
500 | M modified |
501 | A ../dir2/added | |
502 | ?? untracked | |
503 | ?? ../dir2/modified | |
504 | ?? ../dir2/untracked | |
505 | ?? ../expect | |
506 | ?? ../output | |
507 | ?? ../untracked | |
508 | EOF | |
509 | test_expect_success 'status -s with relative paths' ' | |
510 | ||
68cfc6f5 | 511 | (cd dir1 && git status -s) >output && |
14ed05dd MG |
512 | test_cmp expect output |
513 | ||
514 | ' | |
515 | ||
68cfc6f5 | 516 | cat >expect <<\EOF |
c521bb71 MG |
517 | M dir1/modified |
518 | A dir2/added | |
519 | ?? dir1/untracked | |
520 | ?? dir2/modified | |
521 | ?? dir2/untracked | |
522 | ?? expect | |
523 | ?? output | |
524 | ?? untracked | |
525 | EOF | |
526 | ||
527 | test_expect_success 'status --porcelain ignores relative paths setting' ' | |
528 | ||
68cfc6f5 | 529 | (cd dir1 && git status --porcelain) >output && |
c521bb71 MG |
530 | test_cmp expect output |
531 | ||
532 | ' | |
533 | ||
68cfc6f5 MG |
534 | test_expect_success 'setup unique colors' ' |
535 | ||
1d282327 AA |
536 | git config status.color.untracked blue && |
537 | git config status.color.branch green | |
68cfc6f5 MG |
538 | |
539 | ' | |
540 | ||
541 | cat >expect <<\EOF | |
1d282327 | 542 | # On branch <GREEN>master<RESET> |
68cfc6f5 MG |
543 | # Changes to be committed: |
544 | # (use "git reset HEAD <file>..." to unstage) | |
545 | # | |
546 | # <GREEN>new file: dir2/added<RESET> | |
547 | # | |
8009d83c | 548 | # Changes not staged for commit: |
68cfc6f5 MG |
549 | # (use "git add <file>..." to update what will be committed) |
550 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
551 | # | |
552 | # <RED>modified: dir1/modified<RESET> | |
553 | # | |
554 | # Untracked files: | |
555 | # (use "git add <file>..." to include in what will be committed) | |
556 | # | |
557 | # <BLUE>dir1/untracked<RESET> | |
558 | # <BLUE>dir2/modified<RESET> | |
559 | # <BLUE>dir2/untracked<RESET> | |
560 | # <BLUE>expect<RESET> | |
561 | # <BLUE>output<RESET> | |
562 | # <BLUE>untracked<RESET> | |
563 | EOF | |
564 | ||
cc6658e7 | 565 | test_expect_success 'status with color.ui' ' |
68cfc6f5 | 566 | git config color.ui always && |
355ec7a1 | 567 | test_when_finished "git config --unset color.ui" && |
68cfc6f5 | 568 | git status | test_decode_color >output && |
cc6658e7 | 569 | test_i18ncmp expect output |
68cfc6f5 MG |
570 | ' |
571 | ||
cc6658e7 | 572 | test_expect_success 'status with color.status' ' |
68cfc6f5 | 573 | git config color.status always && |
355ec7a1 | 574 | test_when_finished "git config --unset color.status" && |
68cfc6f5 | 575 | git status | test_decode_color >output && |
cc6658e7 | 576 | test_i18ncmp expect output |
68cfc6f5 MG |
577 | ' |
578 | ||
579 | cat >expect <<\EOF | |
580 | <RED>M<RESET> dir1/modified | |
581 | <GREEN>A<RESET> dir2/added | |
582 | <BLUE>??<RESET> dir1/untracked | |
583 | <BLUE>??<RESET> dir2/modified | |
584 | <BLUE>??<RESET> dir2/untracked | |
585 | <BLUE>??<RESET> expect | |
586 | <BLUE>??<RESET> output | |
587 | <BLUE>??<RESET> untracked | |
588 | EOF | |
589 | ||
590 | test_expect_success 'status -s with color.ui' ' | |
591 | ||
68cfc6f5 MG |
592 | git config color.ui always && |
593 | git status -s | test_decode_color >output && | |
594 | test_cmp expect output | |
595 | ||
596 | ' | |
597 | ||
598 | test_expect_success 'status -s with color.status' ' | |
599 | ||
600 | git config --unset color.ui && | |
601 | git config color.status always && | |
602 | git status -s | test_decode_color >output && | |
603 | test_cmp expect output | |
604 | ||
605 | ' | |
606 | ||
46077fa5 MG |
607 | cat >expect <<\EOF |
608 | ## <GREEN>master<RESET> | |
609 | <RED>M<RESET> dir1/modified | |
610 | <GREEN>A<RESET> dir2/added | |
611 | <BLUE>??<RESET> dir1/untracked | |
612 | <BLUE>??<RESET> dir2/modified | |
613 | <BLUE>??<RESET> dir2/untracked | |
614 | <BLUE>??<RESET> expect | |
615 | <BLUE>??<RESET> output | |
616 | <BLUE>??<RESET> untracked | |
617 | EOF | |
618 | ||
619 | test_expect_success 'status -s -b with color.status' ' | |
620 | ||
621 | git status -s -b | test_decode_color >output && | |
622 | test_cmp expect output | |
623 | ||
624 | ' | |
625 | ||
68cfc6f5 MG |
626 | cat >expect <<\EOF |
627 | M dir1/modified | |
628 | A dir2/added | |
629 | ?? dir1/untracked | |
630 | ?? dir2/modified | |
631 | ?? dir2/untracked | |
632 | ?? expect | |
633 | ?? output | |
634 | ?? untracked | |
635 | EOF | |
636 | ||
637 | test_expect_success 'status --porcelain ignores color.ui' ' | |
638 | ||
639 | git config --unset color.status && | |
640 | git config color.ui always && | |
641 | git status --porcelain | test_decode_color >output && | |
642 | test_cmp expect output | |
643 | ||
644 | ' | |
645 | ||
646 | test_expect_success 'status --porcelain ignores color.status' ' | |
647 | ||
648 | git config --unset color.ui && | |
649 | git config color.status always && | |
650 | git status --porcelain | test_decode_color >output && | |
651 | test_cmp expect output | |
652 | ||
653 | ' | |
654 | ||
655 | # recover unconditionally from color tests | |
656 | git config --unset color.status | |
657 | git config --unset color.ui | |
658 | ||
46077fa5 MG |
659 | test_expect_success 'status --porcelain ignores -b' ' |
660 | ||
661 | git status --porcelain -b >output && | |
662 | test_cmp expect output | |
663 | ||
664 | ' | |
665 | ||
68cfc6f5 | 666 | cat >expect <<\EOF |
46f721c8 JK |
667 | # On branch master |
668 | # Changes to be committed: | |
669 | # (use "git reset HEAD <file>..." to unstage) | |
670 | # | |
671 | # new file: dir2/added | |
672 | # | |
8009d83c | 673 | # Changes not staged for commit: |
46f721c8 | 674 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 675 | # (use "git checkout -- <file>..." to discard changes in working directory) |
46f721c8 JK |
676 | # |
677 | # modified: dir1/modified | |
678 | # | |
679 | # Untracked files: | |
680 | # (use "git add <file>..." to include in what will be committed) | |
681 | # | |
682 | # dir1/untracked | |
683 | # dir2/modified | |
684 | # dir2/untracked | |
685 | # expect | |
686 | # output | |
687 | # untracked | |
688 | EOF | |
689 | ||
68cfc6f5 | 690 | |
cc6658e7 | 691 | test_expect_success 'status without relative paths' ' |
46f721c8 | 692 | |
355ec7a1 ÆAB |
693 | git config status.relativePaths false && |
694 | test_when_finished "git config --unset status.relativePaths" && | |
68cfc6f5 | 695 | (cd dir1 && git status) >output && |
cc6658e7 | 696 | test_i18ncmp expect output |
46f721c8 JK |
697 | |
698 | ' | |
699 | ||
68cfc6f5 | 700 | cat >expect <<\EOF |
14ed05dd MG |
701 | M dir1/modified |
702 | A dir2/added | |
703 | ?? dir1/untracked | |
704 | ?? dir2/modified | |
705 | ?? dir2/untracked | |
706 | ?? expect | |
707 | ?? output | |
708 | ?? untracked | |
709 | EOF | |
710 | ||
711 | test_expect_success 'status -s without relative paths' ' | |
712 | ||
355ec7a1 ÆAB |
713 | git config status.relativePaths false && |
714 | test_when_finished "git config --unset status.relativePaths" && | |
68cfc6f5 | 715 | (cd dir1 && git status -s) >output && |
14ed05dd MG |
716 | test_cmp expect output |
717 | ||
718 | ' | |
719 | ||
959ba670 JK |
720 | cat <<EOF >expect |
721 | # On branch master | |
722 | # Changes to be committed: | |
723 | # (use "git reset HEAD <file>..." to unstage) | |
724 | # | |
725 | # modified: dir1/modified | |
726 | # | |
727 | # Untracked files: | |
728 | # (use "git add <file>..." to include in what will be committed) | |
729 | # | |
730 | # dir1/untracked | |
731 | # dir2/ | |
732 | # expect | |
733 | # output | |
734 | # untracked | |
735 | EOF | |
9e4b7ab6 | 736 | test_expect_success 'dry-run of partial commit excluding new file in index' ' |
cc6658e7 JH |
737 | git commit --dry-run dir1/modified >output && |
738 | test_i18ncmp expect output | |
959ba670 JK |
739 | ' |
740 | ||
4c926b37 MH |
741 | cat >expect <<EOF |
742 | :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified | |
743 | EOF | |
4bb6644d | 744 | test_expect_success 'status refreshes the index' ' |
4c926b37 MH |
745 | touch dir2/added && |
746 | git status && | |
747 | git diff-files >output && | |
748 | test_cmp expect output | |
749 | ' | |
750 | ||
e5e4a7f2 PY |
751 | test_expect_success 'setup status submodule summary' ' |
752 | test_create_repo sm && ( | |
753 | cd sm && | |
754 | >foo && | |
755 | git add foo && | |
756 | git commit -m "Add foo" | |
757 | ) && | |
758 | git add sm | |
759 | ' | |
760 | ||
761 | cat >expect <<EOF | |
762 | # On branch master | |
763 | # Changes to be committed: | |
764 | # (use "git reset HEAD <file>..." to unstage) | |
765 | # | |
766 | # new file: dir2/added | |
767 | # new file: sm | |
768 | # | |
8009d83c | 769 | # Changes not staged for commit: |
e5e4a7f2 | 770 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 771 | # (use "git checkout -- <file>..." to discard changes in working directory) |
e5e4a7f2 PY |
772 | # |
773 | # modified: dir1/modified | |
774 | # | |
775 | # Untracked files: | |
776 | # (use "git add <file>..." to include in what will be committed) | |
777 | # | |
778 | # dir1/untracked | |
779 | # dir2/modified | |
780 | # dir2/untracked | |
781 | # expect | |
782 | # output | |
783 | # untracked | |
784 | EOF | |
cc6658e7 | 785 | test_expect_success 'status submodule summary is disabled by default' ' |
e5e4a7f2 | 786 | git status >output && |
cc6658e7 | 787 | test_i18ncmp expect output |
e5e4a7f2 PY |
788 | ' |
789 | ||
98fa4738 | 790 | # we expect the same as the previous test |
cc6658e7 | 791 | test_expect_success 'status --untracked-files=all does not show submodule' ' |
98fa4738 | 792 | git status --untracked-files=all >output && |
cc6658e7 | 793 | test_i18ncmp expect output |
e5e4a7f2 PY |
794 | ' |
795 | ||
14ed05dd MG |
796 | cat >expect <<EOF |
797 | M dir1/modified | |
798 | A dir2/added | |
799 | A sm | |
800 | ?? dir1/untracked | |
801 | ?? dir2/modified | |
802 | ?? dir2/untracked | |
803 | ?? expect | |
804 | ?? output | |
805 | ?? untracked | |
806 | EOF | |
807 | test_expect_success 'status -s submodule summary is disabled by default' ' | |
808 | git status -s >output && | |
809 | test_cmp expect output | |
810 | ' | |
811 | ||
812 | # we expect the same as the previous test | |
813 | test_expect_success 'status -s --untracked-files=all does not show submodule' ' | |
814 | git status -s --untracked-files=all >output && | |
815 | test_cmp expect output | |
816 | ' | |
817 | ||
e5e4a7f2 PY |
818 | head=$(cd sm && git rev-parse --short=7 --verify HEAD) |
819 | ||
820 | cat >expect <<EOF | |
821 | # On branch master | |
822 | # Changes to be committed: | |
823 | # (use "git reset HEAD <file>..." to unstage) | |
824 | # | |
825 | # new file: dir2/added | |
826 | # new file: sm | |
827 | # | |
8009d83c | 828 | # Changes not staged for commit: |
e5e4a7f2 | 829 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 830 | # (use "git checkout -- <file>..." to discard changes in working directory) |
e5e4a7f2 PY |
831 | # |
832 | # modified: dir1/modified | |
833 | # | |
f17a5d34 | 834 | # Submodule changes to be committed: |
e5e4a7f2 PY |
835 | # |
836 | # * sm 0000000...$head (1): | |
837 | # > Add foo | |
838 | # | |
839 | # Untracked files: | |
840 | # (use "git add <file>..." to include in what will be committed) | |
841 | # | |
842 | # dir1/untracked | |
843 | # dir2/modified | |
844 | # dir2/untracked | |
845 | # expect | |
846 | # output | |
847 | # untracked | |
848 | EOF | |
cc6658e7 | 849 | test_expect_success 'status submodule summary' ' |
e5e4a7f2 PY |
850 | git config status.submodulesummary 10 && |
851 | git status >output && | |
cc6658e7 | 852 | test_i18ncmp expect output |
e5e4a7f2 PY |
853 | ' |
854 | ||
14ed05dd MG |
855 | cat >expect <<EOF |
856 | M dir1/modified | |
857 | A dir2/added | |
858 | A sm | |
859 | ?? dir1/untracked | |
860 | ?? dir2/modified | |
861 | ?? dir2/untracked | |
862 | ?? expect | |
863 | ?? output | |
864 | ?? untracked | |
865 | EOF | |
866 | test_expect_success 'status -s submodule summary' ' | |
867 | git status -s >output && | |
868 | test_cmp expect output | |
869 | ' | |
e5e4a7f2 PY |
870 | |
871 | cat >expect <<EOF | |
872 | # On branch master | |
8009d83c | 873 | # Changes not staged for commit: |
e5e4a7f2 | 874 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 875 | # (use "git checkout -- <file>..." to discard changes in working directory) |
e5e4a7f2 PY |
876 | # |
877 | # modified: dir1/modified | |
878 | # | |
879 | # Untracked files: | |
880 | # (use "git add <file>..." to include in what will be committed) | |
881 | # | |
882 | # dir1/untracked | |
883 | # dir2/modified | |
884 | # dir2/untracked | |
885 | # expect | |
886 | # output | |
887 | # untracked | |
888 | no changes added to commit (use "git add" and/or "git commit -a") | |
889 | EOF | |
355ec7a1 | 890 | test_expect_success 'status submodule summary (clean submodule): commit' ' |
cc6658e7 | 891 | git commit -m "commit submodule" && |
e5e4a7f2 | 892 | git config status.submodulesummary 10 && |
9e4b7ab6 | 893 | test_must_fail git commit --dry-run >output && |
cc6658e7 | 894 | test_i18ncmp expect output && |
9e4b7ab6 | 895 | git status >output && |
cc6658e7 | 896 | test_i18ncmp expect output |
e5e4a7f2 PY |
897 | ' |
898 | ||
14ed05dd MG |
899 | cat >expect <<EOF |
900 | M dir1/modified | |
901 | ?? dir1/untracked | |
902 | ?? dir2/modified | |
903 | ?? dir2/untracked | |
904 | ?? expect | |
905 | ?? output | |
906 | ?? untracked | |
907 | EOF | |
908 | test_expect_success 'status -s submodule summary (clean submodule)' ' | |
909 | git status -s >output && | |
910 | test_cmp expect output | |
911 | ' | |
912 | ||
000f97bd | 913 | test_expect_success 'status -z implies porcelain' ' |
95b9f9f9 BC |
914 | git status --porcelain | |
915 | perl -pe "s/\012/\000/g" >expect && | |
916 | git status -z >output && | |
917 | test_cmp expect output | |
918 | ' | |
919 | ||
e5e4a7f2 PY |
920 | cat >expect <<EOF |
921 | # On branch master | |
922 | # Changes to be committed: | |
923 | # (use "git reset HEAD^1 <file>..." to unstage) | |
924 | # | |
925 | # new file: dir2/added | |
926 | # new file: sm | |
927 | # | |
8009d83c | 928 | # Changes not staged for commit: |
e5e4a7f2 | 929 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 930 | # (use "git checkout -- <file>..." to discard changes in working directory) |
e5e4a7f2 PY |
931 | # |
932 | # modified: dir1/modified | |
933 | # | |
f17a5d34 | 934 | # Submodule changes to be committed: |
e5e4a7f2 PY |
935 | # |
936 | # * sm 0000000...$head (1): | |
937 | # > Add foo | |
938 | # | |
939 | # Untracked files: | |
940 | # (use "git add <file>..." to include in what will be committed) | |
941 | # | |
942 | # dir1/untracked | |
943 | # dir2/modified | |
944 | # dir2/untracked | |
945 | # expect | |
946 | # output | |
947 | # untracked | |
948 | EOF | |
cc6658e7 | 949 | test_expect_success 'commit --dry-run submodule summary (--amend)' ' |
e5e4a7f2 | 950 | git config status.submodulesummary 10 && |
9e4b7ab6 | 951 | git commit --dry-run --amend >output && |
cc6658e7 | 952 | test_i18ncmp expect output |
e5e4a7f2 PY |
953 | ' |
954 | ||
c91cfd19 | 955 | test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' ' |
b2f6fd95 MH |
956 | ( |
957 | chmod a-w .git && | |
958 | # make dir1/tracked stat-dirty | |
959 | >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked && | |
960 | git status -s >output && | |
961 | ! grep dir1/tracked output && | |
962 | # make sure "status" succeeded without writing index out | |
963 | git diff-files | grep dir1/tracked | |
964 | ) | |
965 | status=$? | |
966 | chmod 775 .git | |
967 | (exit $status) | |
968 | ' | |
969 | ||
c2e0940b | 970 | (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm |
aee9c7d6 JL |
971 | new_head=$(cd sm && git rev-parse --short=7 --verify HEAD) |
972 | touch .gitmodules | |
973 | ||
46a958b3 JL |
974 | cat > expect << EOF |
975 | # On branch master | |
aee9c7d6 JL |
976 | # Changes to be committed: |
977 | # (use "git reset HEAD <file>..." to unstage) | |
978 | # | |
979 | # modified: sm | |
980 | # | |
8009d83c | 981 | # Changes not staged for commit: |
46a958b3 JL |
982 | # (use "git add <file>..." to update what will be committed) |
983 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
984 | # | |
985 | # modified: dir1/modified | |
986 | # | |
aee9c7d6 JL |
987 | # Submodule changes to be committed: |
988 | # | |
989 | # * sm $head...$new_head (1): | |
990 | # > Add bar | |
991 | # | |
46a958b3 JL |
992 | # Untracked files: |
993 | # (use "git add <file>..." to include in what will be committed) | |
994 | # | |
aee9c7d6 | 995 | # .gitmodules |
46a958b3 JL |
996 | # dir1/untracked |
997 | # dir2/modified | |
998 | # dir2/untracked | |
999 | # expect | |
1000 | # output | |
1001 | # untracked | |
46a958b3 JL |
1002 | EOF |
1003 | ||
cc6658e7 JH |
1004 | test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' ' |
1005 | echo modified sm/untracked && | |
1006 | git status --ignore-submodules=untracked >output && | |
1007 | test_i18ncmp expect output | |
46a958b3 JL |
1008 | ' |
1009 | ||
cc6658e7 | 1010 | test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' ' |
90e14525 JL |
1011 | git config diff.ignoreSubmodules dirty && |
1012 | git status >output && | |
cc6658e7 | 1013 | test_i18ncmp expect output && |
302ad7a9 JL |
1014 | git config --add -f .gitmodules submodule.subname.ignore untracked && |
1015 | git config --add -f .gitmodules submodule.subname.path sm && | |
cc6658e7 JH |
1016 | git status >output && |
1017 | test_i18ncmp expect output && | |
90e14525 JL |
1018 | git config -f .gitmodules --remove-section submodule.subname && |
1019 | git config --unset diff.ignoreSubmodules | |
302ad7a9 JL |
1020 | ' |
1021 | ||
cc6658e7 | 1022 | test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' ' |
302ad7a9 JL |
1023 | git config --add -f .gitmodules submodule.subname.ignore none && |
1024 | git config --add -f .gitmodules submodule.subname.path sm && | |
aee9c7d6 JL |
1025 | git config --add submodule.subname.ignore untracked && |
1026 | git config --add submodule.subname.path sm && | |
cc6658e7 JH |
1027 | git status >output && |
1028 | test_i18ncmp expect output && | |
302ad7a9 JL |
1029 | git config --remove-section submodule.subname && |
1030 | git config --remove-section -f .gitmodules submodule.subname | |
aee9c7d6 JL |
1031 | ' |
1032 | ||
cc6658e7 JH |
1033 | test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' ' |
1034 | git status --ignore-submodules=dirty >output && | |
1035 | test_i18ncmp expect output | |
46a958b3 JL |
1036 | ' |
1037 | ||
cc6658e7 | 1038 | test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' ' |
90e14525 JL |
1039 | git config diff.ignoreSubmodules dirty && |
1040 | git status >output && | |
1041 | ! test -s actual && | |
302ad7a9 JL |
1042 | git config --add -f .gitmodules submodule.subname.ignore dirty && |
1043 | git config --add -f .gitmodules submodule.subname.path sm && | |
cc6658e7 JH |
1044 | git status >output && |
1045 | test_i18ncmp expect output && | |
90e14525 JL |
1046 | git config -f .gitmodules --remove-section submodule.subname && |
1047 | git config --unset diff.ignoreSubmodules | |
302ad7a9 JL |
1048 | ' |
1049 | ||
cc6658e7 | 1050 | test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' ' |
302ad7a9 JL |
1051 | git config --add -f .gitmodules submodule.subname.ignore none && |
1052 | git config --add -f .gitmodules submodule.subname.path sm && | |
aee9c7d6 JL |
1053 | git config --add submodule.subname.ignore dirty && |
1054 | git config --add submodule.subname.path sm && | |
cc6658e7 JH |
1055 | git status >output && |
1056 | test_i18ncmp expect output && | |
302ad7a9 JL |
1057 | git config --remove-section submodule.subname && |
1058 | git config -f .gitmodules --remove-section submodule.subname | |
aee9c7d6 JL |
1059 | ' |
1060 | ||
cc6658e7 JH |
1061 | test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' ' |
1062 | echo modified >sm/foo && | |
1063 | git status --ignore-submodules=dirty >output && | |
1064 | test_i18ncmp expect output | |
46a958b3 JL |
1065 | ' |
1066 | ||
cc6658e7 | 1067 | test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' ' |
302ad7a9 JL |
1068 | git config --add -f .gitmodules submodule.subname.ignore dirty && |
1069 | git config --add -f .gitmodules submodule.subname.path sm && | |
cc6658e7 JH |
1070 | git status >output && |
1071 | test_i18ncmp expect output && | |
302ad7a9 JL |
1072 | git config -f .gitmodules --remove-section submodule.subname |
1073 | ' | |
1074 | ||
cc6658e7 | 1075 | test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' ' |
302ad7a9 JL |
1076 | git config --add -f .gitmodules submodule.subname.ignore none && |
1077 | git config --add -f .gitmodules submodule.subname.path sm && | |
aee9c7d6 JL |
1078 | git config --add submodule.subname.ignore dirty && |
1079 | git config --add submodule.subname.path sm && | |
cc6658e7 JH |
1080 | git status >output && |
1081 | test_i18ncmp expect output && | |
302ad7a9 JL |
1082 | git config --remove-section submodule.subname && |
1083 | git config -f .gitmodules --remove-section submodule.subname | |
aee9c7d6 JL |
1084 | ' |
1085 | ||
46a958b3 JL |
1086 | cat > expect << EOF |
1087 | # On branch master | |
aee9c7d6 JL |
1088 | # Changes to be committed: |
1089 | # (use "git reset HEAD <file>..." to unstage) | |
1090 | # | |
1091 | # modified: sm | |
1092 | # | |
8009d83c | 1093 | # Changes not staged for commit: |
46a958b3 JL |
1094 | # (use "git add <file>..." to update what will be committed) |
1095 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
1096 | # (commit or discard the untracked or modified content in submodules) | |
1097 | # | |
1098 | # modified: dir1/modified | |
1099 | # modified: sm (modified content) | |
1100 | # | |
aee9c7d6 JL |
1101 | # Submodule changes to be committed: |
1102 | # | |
1103 | # * sm $head...$new_head (1): | |
1104 | # > Add bar | |
1105 | # | |
46a958b3 JL |
1106 | # Untracked files: |
1107 | # (use "git add <file>..." to include in what will be committed) | |
1108 | # | |
aee9c7d6 | 1109 | # .gitmodules |
46a958b3 JL |
1110 | # dir1/untracked |
1111 | # dir2/modified | |
1112 | # dir2/untracked | |
1113 | # expect | |
1114 | # output | |
1115 | # untracked | |
46a958b3 JL |
1116 | EOF |
1117 | ||
cc6658e7 | 1118 | test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" ' |
46a958b3 | 1119 | git status --ignore-submodules=untracked > output && |
cc6658e7 | 1120 | test_i18ncmp expect output |
46a958b3 JL |
1121 | ' |
1122 | ||
cc6658e7 | 1123 | test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" ' |
302ad7a9 JL |
1124 | git config --add -f .gitmodules submodule.subname.ignore untracked && |
1125 | git config --add -f .gitmodules submodule.subname.path sm && | |
cc6658e7 JH |
1126 | git status >output && |
1127 | test_i18ncmp expect output && | |
302ad7a9 JL |
1128 | git config -f .gitmodules --remove-section submodule.subname |
1129 | ' | |
1130 | ||
cc6658e7 | 1131 | test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" ' |
302ad7a9 JL |
1132 | git config --add -f .gitmodules submodule.subname.ignore none && |
1133 | git config --add -f .gitmodules submodule.subname.path sm && | |
aee9c7d6 JL |
1134 | git config --add submodule.subname.ignore untracked && |
1135 | git config --add submodule.subname.path sm && | |
cc6658e7 JH |
1136 | git status >output && |
1137 | test_i18ncmp expect output && | |
302ad7a9 JL |
1138 | git config --remove-section submodule.subname && |
1139 | git config -f .gitmodules --remove-section submodule.subname | |
aee9c7d6 JL |
1140 | ' |
1141 | ||
46a958b3 JL |
1142 | head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD) |
1143 | ||
1144 | cat > expect << EOF | |
1145 | # On branch master | |
aee9c7d6 JL |
1146 | # Changes to be committed: |
1147 | # (use "git reset HEAD <file>..." to unstage) | |
1148 | # | |
1149 | # modified: sm | |
1150 | # | |
8009d83c | 1151 | # Changes not staged for commit: |
46a958b3 JL |
1152 | # (use "git add <file>..." to update what will be committed) |
1153 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
1154 | # | |
1155 | # modified: dir1/modified | |
1156 | # modified: sm (new commits) | |
1157 | # | |
aee9c7d6 JL |
1158 | # Submodule changes to be committed: |
1159 | # | |
1160 | # * sm $head...$new_head (1): | |
1161 | # > Add bar | |
1162 | # | |
46a958b3 JL |
1163 | # Submodules changed but not updated: |
1164 | # | |
aee9c7d6 | 1165 | # * sm $new_head...$head2 (1): |
46a958b3 JL |
1166 | # > 2nd commit |
1167 | # | |
1168 | # Untracked files: | |
1169 | # (use "git add <file>..." to include in what will be committed) | |
1170 | # | |
aee9c7d6 | 1171 | # .gitmodules |
46a958b3 JL |
1172 | # dir1/untracked |
1173 | # dir2/modified | |
1174 | # dir2/untracked | |
1175 | # expect | |
1176 | # output | |
1177 | # untracked | |
46a958b3 JL |
1178 | EOF |
1179 | ||
cc6658e7 | 1180 | test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" ' |
46a958b3 | 1181 | git status --ignore-submodules=untracked > output && |
cc6658e7 | 1182 | test_i18ncmp expect output |
46a958b3 JL |
1183 | ' |
1184 | ||
cc6658e7 | 1185 | test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" ' |
302ad7a9 JL |
1186 | git config --add -f .gitmodules submodule.subname.ignore untracked && |
1187 | git config --add -f .gitmodules submodule.subname.path sm && | |
cc6658e7 JH |
1188 | git status >output && |
1189 | test_i18ncmp expect output && | |
302ad7a9 JL |
1190 | git config -f .gitmodules --remove-section submodule.subname |
1191 | ' | |
1192 | ||
cc6658e7 | 1193 | test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" ' |
302ad7a9 JL |
1194 | git config --add -f .gitmodules submodule.subname.ignore none && |
1195 | git config --add -f .gitmodules submodule.subname.path sm && | |
aee9c7d6 JL |
1196 | git config --add submodule.subname.ignore untracked && |
1197 | git config --add submodule.subname.path sm && | |
cc6658e7 JH |
1198 | git status >output && |
1199 | test_i18ncmp expect output && | |
302ad7a9 JL |
1200 | git config --remove-section submodule.subname && |
1201 | git config -f .gitmodules --remove-section submodule.subname | |
aee9c7d6 JL |
1202 | ' |
1203 | ||
cc6658e7 | 1204 | test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" ' |
46a958b3 | 1205 | git status --ignore-submodules=dirty > output && |
cc6658e7 | 1206 | test_i18ncmp expect output |
46a958b3 | 1207 | ' |
cc6658e7 | 1208 | test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" ' |
302ad7a9 JL |
1209 | git config --add -f .gitmodules submodule.subname.ignore dirty && |
1210 | git config --add -f .gitmodules submodule.subname.path sm && | |
cc6658e7 JH |
1211 | git status >output && |
1212 | test_i18ncmp expect output && | |
302ad7a9 JL |
1213 | git config -f .gitmodules --remove-section submodule.subname |
1214 | ' | |
46a958b3 | 1215 | |
cc6658e7 | 1216 | test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" ' |
302ad7a9 JL |
1217 | git config --add -f .gitmodules submodule.subname.ignore none && |
1218 | git config --add -f .gitmodules submodule.subname.path sm && | |
aee9c7d6 JL |
1219 | git config --add submodule.subname.ignore dirty && |
1220 | git config --add submodule.subname.path sm && | |
cc6658e7 JH |
1221 | git status >output && |
1222 | test_i18ncmp expect output && | |
302ad7a9 JL |
1223 | git config --remove-section submodule.subname && |
1224 | git config -f .gitmodules --remove-section submodule.subname | |
aee9c7d6 JL |
1225 | ' |
1226 | ||
46a958b3 JL |
1227 | cat > expect << EOF |
1228 | # On branch master | |
8009d83c | 1229 | # Changes not staged for commit: |
46a958b3 JL |
1230 | # (use "git add <file>..." to update what will be committed) |
1231 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
1232 | # | |
1233 | # modified: dir1/modified | |
1234 | # | |
1235 | # Untracked files: | |
1236 | # (use "git add <file>..." to include in what will be committed) | |
1237 | # | |
aee9c7d6 | 1238 | # .gitmodules |
46a958b3 JL |
1239 | # dir1/untracked |
1240 | # dir2/modified | |
1241 | # dir2/untracked | |
1242 | # expect | |
1243 | # output | |
1244 | # untracked | |
1245 | no changes added to commit (use "git add" and/or "git commit -a") | |
1246 | EOF | |
1247 | ||
cc6658e7 | 1248 | test_expect_success "--ignore-submodules=all suppresses submodule summary" ' |
46a958b3 | 1249 | git status --ignore-submodules=all > output && |
cc6658e7 | 1250 | test_i18ncmp expect output |
46a958b3 JL |
1251 | ' |
1252 | ||
302ad7a9 JL |
1253 | test_expect_failure '.gitmodules ignore=all suppresses submodule summary' ' |
1254 | git config --add -f .gitmodules submodule.subname.ignore all && | |
1255 | git config --add -f .gitmodules submodule.subname.path sm && | |
1256 | git status > output && | |
1257 | test_cmp expect output && | |
1258 | git config -f .gitmodules --remove-section submodule.subname | |
1259 | ' | |
1260 | ||
aee9c7d6 | 1261 | test_expect_failure '.git/config ignore=all suppresses submodule summary' ' |
302ad7a9 JL |
1262 | git config --add -f .gitmodules submodule.subname.ignore none && |
1263 | git config --add -f .gitmodules submodule.subname.path sm && | |
aee9c7d6 JL |
1264 | git config --add submodule.subname.ignore all && |
1265 | git config --add submodule.subname.path sm && | |
1266 | git status > output && | |
1267 | test_cmp expect output && | |
302ad7a9 JL |
1268 | git config --remove-section submodule.subname && |
1269 | git config -f .gitmodules --remove-section submodule.subname | |
aee9c7d6 JL |
1270 | ' |
1271 | ||
367c9886 | 1272 | test_done |