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