status: show branchname with a configurable color
[git/jrn.git] / t / t7508-status.sh
blobba36d72661c59611583a8e74059ad2db1d353760
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='git status'
8 . ./test-lib.sh
10 test_expect_success 'setup' '
11 : >tracked &&
12 : >modified &&
13 mkdir dir1 &&
14 : >dir1/tracked &&
15 : >dir1/modified &&
16 mkdir dir2 &&
17 : >dir1/tracked &&
18 : >dir1/modified &&
19 git add . &&
21 git status >output &&
23 test_tick &&
24 git commit -m initial &&
25 : >untracked &&
26 : >dir1/untracked &&
27 : >dir2/untracked &&
28 echo 1 >dir1/modified &&
29 echo 2 >dir2/modified &&
30 echo 3 >dir2/added &&
31 git add dir2/added
34 test_expect_success 'status (1)' '
36 grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
40 cat >expect <<\EOF
41 # On branch master
42 # Changes to be committed:
43 # (use "git reset HEAD <file>..." to unstage)
45 # new file: dir2/added
47 # Changes not staged for commit:
48 # (use "git add <file>..." to update what will be committed)
49 # (use "git checkout -- <file>..." to discard changes in working directory)
51 # modified: dir1/modified
53 # Untracked files:
54 # (use "git add <file>..." to include in what will be committed)
56 # dir1/untracked
57 # dir2/modified
58 # dir2/untracked
59 # expect
60 # output
61 # untracked
62 EOF
64 test_expect_success 'status (2)' '
66 git status >output &&
67 test_cmp expect output
71 cat >expect <<\EOF
72 # On branch master
73 # Changes to be committed:
74 # new file: dir2/added
76 # Changes not staged for commit:
77 # modified: dir1/modified
79 # Untracked files:
80 # dir1/untracked
81 # dir2/modified
82 # dir2/untracked
83 # expect
84 # output
85 # untracked
86 EOF
88 git config advice.statusHints false
90 test_expect_success 'status (advice.statusHints false)' '
92 git status >output &&
93 test_cmp expect output
97 git config --unset advice.statusHints
99 cat >expect <<\EOF
100 M dir1/modified
101 A dir2/added
102 ?? dir1/untracked
103 ?? dir2/modified
104 ?? dir2/untracked
105 ?? expect
106 ?? output
107 ?? untracked
110 test_expect_success 'status -s' '
112 git status -s >output &&
113 test_cmp expect output
117 cat >expect <<\EOF
118 ## master
119 M dir1/modified
120 A dir2/added
121 ?? dir1/untracked
122 ?? dir2/modified
123 ?? dir2/untracked
124 ?? expect
125 ?? output
126 ?? untracked
129 test_expect_success 'status -s -b' '
131 git status -s -b >output &&
132 test_cmp expect output
136 cat >expect <<EOF
137 # On branch master
138 # Changes to be committed:
139 # (use "git reset HEAD <file>..." to unstage)
141 # new file: dir2/added
143 # Changes not staged for commit:
144 # (use "git add <file>..." to update what will be committed)
145 # (use "git checkout -- <file>..." to discard changes in working directory)
147 # modified: dir1/modified
149 # Untracked files not listed (use -u option to show untracked files)
151 test_expect_success 'status -uno' '
152 mkdir dir3 &&
153 : >dir3/untracked1 &&
154 : >dir3/untracked2 &&
155 git status -uno >output &&
156 test_cmp expect output
159 test_expect_success 'status (status.showUntrackedFiles no)' '
160 git config status.showuntrackedfiles no
161 git status >output &&
162 test_cmp expect output
165 cat >expect <<EOF
166 # On branch master
167 # Changes to be committed:
168 # new file: dir2/added
170 # Changes not staged for commit:
171 # modified: dir1/modified
173 # Untracked files not listed
175 git config advice.statusHints false
176 test_expect_success 'status -uno (advice.statusHints false)' '
177 git status -uno >output &&
178 test_cmp expect output
180 git config --unset advice.statusHints
182 cat >expect << EOF
183 M dir1/modified
184 A dir2/added
186 test_expect_success 'status -s -uno' '
187 git config --unset status.showuntrackedfiles
188 git status -s -uno >output &&
189 test_cmp expect output
192 test_expect_success 'status -s (status.showUntrackedFiles no)' '
193 git config status.showuntrackedfiles no
194 git status -s >output &&
195 test_cmp expect output
198 cat >expect <<EOF
199 # On branch master
200 # Changes to be committed:
201 # (use "git reset HEAD <file>..." to unstage)
203 # new file: dir2/added
205 # Changes not staged for commit:
206 # (use "git add <file>..." to update what will be committed)
207 # (use "git checkout -- <file>..." to discard changes in working directory)
209 # modified: dir1/modified
211 # Untracked files:
212 # (use "git add <file>..." to include in what will be committed)
214 # dir1/untracked
215 # dir2/modified
216 # dir2/untracked
217 # dir3/
218 # expect
219 # output
220 # untracked
222 test_expect_success 'status -unormal' '
223 git status -unormal >output &&
224 test_cmp expect output
227 test_expect_success 'status (status.showUntrackedFiles normal)' '
228 git config status.showuntrackedfiles normal
229 git status >output &&
230 test_cmp expect output
233 cat >expect <<EOF
234 M dir1/modified
235 A dir2/added
236 ?? dir1/untracked
237 ?? dir2/modified
238 ?? dir2/untracked
239 ?? dir3/
240 ?? expect
241 ?? output
242 ?? untracked
244 test_expect_success 'status -s -unormal' '
245 git config --unset status.showuntrackedfiles
246 git status -s -unormal >output &&
247 test_cmp expect output
250 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
251 git config status.showuntrackedfiles normal
252 git status -s >output &&
253 test_cmp expect output
256 cat >expect <<EOF
257 # On branch master
258 # Changes to be committed:
259 # (use "git reset HEAD <file>..." to unstage)
261 # new file: dir2/added
263 # Changes not staged for commit:
264 # (use "git add <file>..." to update what will be committed)
265 # (use "git checkout -- <file>..." to discard changes in working directory)
267 # modified: dir1/modified
269 # Untracked files:
270 # (use "git add <file>..." to include in what will be committed)
272 # dir1/untracked
273 # dir2/modified
274 # dir2/untracked
275 # dir3/untracked1
276 # dir3/untracked2
277 # expect
278 # output
279 # untracked
281 test_expect_success 'status -uall' '
282 git status -uall >output &&
283 test_cmp expect output
285 test_expect_success 'status (status.showUntrackedFiles all)' '
286 git config status.showuntrackedfiles all
287 git status >output &&
288 rm -rf dir3 &&
289 git config --unset status.showuntrackedfiles &&
290 test_cmp expect output
293 cat >expect <<EOF
294 M dir1/modified
295 A dir2/added
296 ?? dir1/untracked
297 ?? dir2/modified
298 ?? dir2/untracked
299 ?? expect
300 ?? output
301 ?? untracked
303 test_expect_success 'status -s -uall' '
304 git config --unset status.showuntrackedfiles
305 git status -s -uall >output &&
306 test_cmp expect output
308 test_expect_success 'status -s (status.showUntrackedFiles all)' '
309 git config status.showuntrackedfiles all
310 git status -s >output &&
311 rm -rf dir3 &&
312 git config --unset status.showuntrackedfiles &&
313 test_cmp expect output
316 cat >expect <<\EOF
317 # On branch master
318 # Changes to be committed:
319 # (use "git reset HEAD <file>..." to unstage)
321 # new file: ../dir2/added
323 # Changes not staged for commit:
324 # (use "git add <file>..." to update what will be committed)
325 # (use "git checkout -- <file>..." to discard changes in working directory)
327 # modified: modified
329 # Untracked files:
330 # (use "git add <file>..." to include in what will be committed)
332 # untracked
333 # ../dir2/modified
334 # ../dir2/untracked
335 # ../expect
336 # ../output
337 # ../untracked
340 test_expect_success 'status with relative paths' '
342 (cd dir1 && git status) >output &&
343 test_cmp expect output
347 cat >expect <<\EOF
348 M modified
349 A ../dir2/added
350 ?? untracked
351 ?? ../dir2/modified
352 ?? ../dir2/untracked
353 ?? ../expect
354 ?? ../output
355 ?? ../untracked
357 test_expect_success 'status -s with relative paths' '
359 (cd dir1 && git status -s) >output &&
360 test_cmp expect output
364 cat >expect <<\EOF
365 M dir1/modified
366 A dir2/added
367 ?? dir1/untracked
368 ?? dir2/modified
369 ?? dir2/untracked
370 ?? expect
371 ?? output
372 ?? untracked
375 test_expect_success 'status --porcelain ignores relative paths setting' '
377 (cd dir1 && git status --porcelain) >output &&
378 test_cmp expect output
382 test_expect_success 'setup unique colors' '
384 git config status.color.untracked blue &&
385 git config status.color.branch green
389 cat >expect <<\EOF
390 # On branch <GREEN>master<RESET>
391 # Changes to be committed:
392 # (use "git reset HEAD <file>..." to unstage)
394 # <GREEN>new file: dir2/added<RESET>
396 # Changes not staged for commit:
397 # (use "git add <file>..." to update what will be committed)
398 # (use "git checkout -- <file>..." to discard changes in working directory)
400 # <RED>modified: dir1/modified<RESET>
402 # Untracked files:
403 # (use "git add <file>..." to include in what will be committed)
405 # <BLUE>dir1/untracked<RESET>
406 # <BLUE>dir2/modified<RESET>
407 # <BLUE>dir2/untracked<RESET>
408 # <BLUE>expect<RESET>
409 # <BLUE>output<RESET>
410 # <BLUE>untracked<RESET>
413 test_expect_success 'status with color.ui' '
415 git config color.ui always &&
416 git status | test_decode_color >output &&
417 test_cmp expect output
421 test_expect_success 'status with color.status' '
423 git config --unset color.ui &&
424 git config color.status always &&
425 git status | test_decode_color >output &&
426 test_cmp expect output
430 cat >expect <<\EOF
431 <RED>M<RESET> dir1/modified
432 <GREEN>A<RESET> dir2/added
433 <BLUE>??<RESET> dir1/untracked
434 <BLUE>??<RESET> dir2/modified
435 <BLUE>??<RESET> dir2/untracked
436 <BLUE>??<RESET> expect
437 <BLUE>??<RESET> output
438 <BLUE>??<RESET> untracked
441 test_expect_success 'status -s with color.ui' '
443 git config --unset color.status &&
444 git config color.ui always &&
445 git status -s | test_decode_color >output &&
446 test_cmp expect output
450 test_expect_success 'status -s with color.status' '
452 git config --unset color.ui &&
453 git config color.status always &&
454 git status -s | test_decode_color >output &&
455 test_cmp expect output
459 cat >expect <<\EOF
460 ## <GREEN>master<RESET>
461 <RED>M<RESET> dir1/modified
462 <GREEN>A<RESET> dir2/added
463 <BLUE>??<RESET> dir1/untracked
464 <BLUE>??<RESET> dir2/modified
465 <BLUE>??<RESET> dir2/untracked
466 <BLUE>??<RESET> expect
467 <BLUE>??<RESET> output
468 <BLUE>??<RESET> untracked
471 test_expect_success 'status -s -b with color.status' '
473 git status -s -b | test_decode_color >output &&
474 test_cmp expect output
478 cat >expect <<\EOF
479 M dir1/modified
480 A dir2/added
481 ?? dir1/untracked
482 ?? dir2/modified
483 ?? dir2/untracked
484 ?? expect
485 ?? output
486 ?? untracked
489 test_expect_success 'status --porcelain ignores color.ui' '
491 git config --unset color.status &&
492 git config color.ui always &&
493 git status --porcelain | test_decode_color >output &&
494 test_cmp expect output
498 test_expect_success 'status --porcelain ignores color.status' '
500 git config --unset color.ui &&
501 git config color.status always &&
502 git status --porcelain | test_decode_color >output &&
503 test_cmp expect output
507 # recover unconditionally from color tests
508 git config --unset color.status
509 git config --unset color.ui
511 test_expect_success 'status --porcelain ignores -b' '
513 git status --porcelain -b >output &&
514 test_cmp expect output
518 cat >expect <<\EOF
519 # On branch master
520 # Changes to be committed:
521 # (use "git reset HEAD <file>..." to unstage)
523 # new file: dir2/added
525 # Changes not staged for commit:
526 # (use "git add <file>..." to update what will be committed)
527 # (use "git checkout -- <file>..." to discard changes in working directory)
529 # modified: dir1/modified
531 # Untracked files:
532 # (use "git add <file>..." to include in what will be committed)
534 # dir1/untracked
535 # dir2/modified
536 # dir2/untracked
537 # expect
538 # output
539 # untracked
543 test_expect_success 'status without relative paths' '
545 git config status.relativePaths false
546 (cd dir1 && git status) >output &&
547 test_cmp expect output
551 cat >expect <<\EOF
552 M dir1/modified
553 A dir2/added
554 ?? dir1/untracked
555 ?? dir2/modified
556 ?? dir2/untracked
557 ?? expect
558 ?? output
559 ?? untracked
562 test_expect_success 'status -s without relative paths' '
564 (cd dir1 && git status -s) >output &&
565 test_cmp expect output
569 cat <<EOF >expect
570 # On branch master
571 # Changes to be committed:
572 # (use "git reset HEAD <file>..." to unstage)
574 # modified: dir1/modified
576 # Untracked files:
577 # (use "git add <file>..." to include in what will be committed)
579 # dir1/untracked
580 # dir2/
581 # expect
582 # output
583 # untracked
585 test_expect_success 'dry-run of partial commit excluding new file in index' '
586 git commit --dry-run dir1/modified >output &&
587 test_cmp expect output
590 cat >expect <<EOF
591 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
593 test_expect_success 'status refreshes the index' '
594 touch dir2/added &&
595 git status &&
596 git diff-files >output &&
597 test_cmp expect output
600 test_expect_success 'setup status submodule summary' '
601 test_create_repo sm && (
602 cd sm &&
603 >foo &&
604 git add foo &&
605 git commit -m "Add foo"
606 ) &&
607 git add sm
610 cat >expect <<EOF
611 # On branch master
612 # Changes to be committed:
613 # (use "git reset HEAD <file>..." to unstage)
615 # new file: dir2/added
616 # new file: sm
618 # Changes not staged for commit:
619 # (use "git add <file>..." to update what will be committed)
620 # (use "git checkout -- <file>..." to discard changes in working directory)
622 # modified: dir1/modified
624 # Untracked files:
625 # (use "git add <file>..." to include in what will be committed)
627 # dir1/untracked
628 # dir2/modified
629 # dir2/untracked
630 # expect
631 # output
632 # untracked
634 test_expect_success 'status submodule summary is disabled by default' '
635 git status >output &&
636 test_cmp expect output
639 # we expect the same as the previous test
640 test_expect_success 'status --untracked-files=all does not show submodule' '
641 git status --untracked-files=all >output &&
642 test_cmp expect output
645 cat >expect <<EOF
646 M dir1/modified
647 A dir2/added
648 A sm
649 ?? dir1/untracked
650 ?? dir2/modified
651 ?? dir2/untracked
652 ?? expect
653 ?? output
654 ?? untracked
656 test_expect_success 'status -s submodule summary is disabled by default' '
657 git status -s >output &&
658 test_cmp expect output
661 # we expect the same as the previous test
662 test_expect_success 'status -s --untracked-files=all does not show submodule' '
663 git status -s --untracked-files=all >output &&
664 test_cmp expect output
667 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
669 cat >expect <<EOF
670 # On branch master
671 # Changes to be committed:
672 # (use "git reset HEAD <file>..." to unstage)
674 # new file: dir2/added
675 # new file: sm
677 # Changes not staged for commit:
678 # (use "git add <file>..." to update what will be committed)
679 # (use "git checkout -- <file>..." to discard changes in working directory)
681 # modified: dir1/modified
683 # Submodule changes to be committed:
685 # * sm 0000000...$head (1):
686 # > Add foo
688 # Untracked files:
689 # (use "git add <file>..." to include in what will be committed)
691 # dir1/untracked
692 # dir2/modified
693 # dir2/untracked
694 # expect
695 # output
696 # untracked
698 test_expect_success 'status submodule summary' '
699 git config status.submodulesummary 10 &&
700 git status >output &&
701 test_cmp expect output
704 cat >expect <<EOF
705 M dir1/modified
706 A dir2/added
707 A sm
708 ?? dir1/untracked
709 ?? dir2/modified
710 ?? dir2/untracked
711 ?? expect
712 ?? output
713 ?? untracked
715 test_expect_success 'status -s submodule summary' '
716 git status -s >output &&
717 test_cmp expect output
720 cat >expect <<EOF
721 # On branch master
722 # Changes not staged for commit:
723 # (use "git add <file>..." to update what will be committed)
724 # (use "git checkout -- <file>..." to discard changes in working directory)
726 # modified: dir1/modified
728 # Untracked files:
729 # (use "git add <file>..." to include in what will be committed)
731 # dir1/untracked
732 # dir2/modified
733 # dir2/untracked
734 # expect
735 # output
736 # untracked
737 no changes added to commit (use "git add" and/or "git commit -a")
739 test_expect_success 'status submodule summary (clean submodule)' '
740 git commit -m "commit submodule" &&
741 git config status.submodulesummary 10 &&
742 test_must_fail git commit --dry-run >output &&
743 test_cmp expect output &&
744 git status >output &&
745 test_cmp expect output
748 cat >expect <<EOF
749 M dir1/modified
750 ?? dir1/untracked
751 ?? dir2/modified
752 ?? dir2/untracked
753 ?? expect
754 ?? output
755 ?? untracked
757 test_expect_success 'status -s submodule summary (clean submodule)' '
758 git status -s >output &&
759 test_cmp expect output
762 cat >expect <<EOF
763 # On branch master
764 # Changes to be committed:
765 # (use "git reset HEAD^1 <file>..." to unstage)
767 # new file: dir2/added
768 # new file: sm
770 # Changes not staged for commit:
771 # (use "git add <file>..." to update what will be committed)
772 # (use "git checkout -- <file>..." to discard changes in working directory)
774 # modified: dir1/modified
776 # Submodule changes to be committed:
778 # * sm 0000000...$head (1):
779 # > Add foo
781 # Untracked files:
782 # (use "git add <file>..." to include in what will be committed)
784 # dir1/untracked
785 # dir2/modified
786 # dir2/untracked
787 # expect
788 # output
789 # untracked
791 test_expect_success 'commit --dry-run submodule summary (--amend)' '
792 git config status.submodulesummary 10 &&
793 git commit --dry-run --amend >output &&
794 test_cmp expect output
797 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
799 chmod a-w .git &&
800 # make dir1/tracked stat-dirty
801 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
802 git status -s >output &&
803 ! grep dir1/tracked output &&
804 # make sure "status" succeeded without writing index out
805 git diff-files | grep dir1/tracked
807 status=$?
808 chmod 775 .git
809 (exit $status)
812 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
813 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
814 touch .gitmodules
816 cat > expect << EOF
817 # On branch master
818 # Changes to be committed:
819 # (use "git reset HEAD <file>..." to unstage)
821 # modified: sm
823 # Changes not staged for commit:
824 # (use "git add <file>..." to update what will be committed)
825 # (use "git checkout -- <file>..." to discard changes in working directory)
827 # modified: dir1/modified
829 # Submodule changes to be committed:
831 # * sm $head...$new_head (1):
832 # > Add bar
834 # Untracked files:
835 # (use "git add <file>..." to include in what will be committed)
837 # .gitmodules
838 # dir1/untracked
839 # dir2/modified
840 # dir2/untracked
841 # expect
842 # output
843 # untracked
846 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
847 echo modified > sm/untracked &&
848 git status --ignore-submodules=untracked > output &&
849 test_cmp expect output
852 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
853 git config diff.ignoreSubmodules dirty &&
854 git status >output &&
855 test_cmp expect output &&
856 git config --add -f .gitmodules submodule.subname.ignore untracked &&
857 git config --add -f .gitmodules submodule.subname.path sm &&
858 git status > output &&
859 test_cmp expect output &&
860 git config -f .gitmodules --remove-section submodule.subname &&
861 git config --unset diff.ignoreSubmodules
864 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
865 git config --add -f .gitmodules submodule.subname.ignore none &&
866 git config --add -f .gitmodules submodule.subname.path sm &&
867 git config --add submodule.subname.ignore untracked &&
868 git config --add submodule.subname.path sm &&
869 git status > output &&
870 test_cmp expect output &&
871 git config --remove-section submodule.subname &&
872 git config --remove-section -f .gitmodules submodule.subname
875 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
876 git status --ignore-submodules=dirty > output &&
877 test_cmp expect output
880 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
881 git config diff.ignoreSubmodules dirty &&
882 git status >output &&
883 ! test -s actual &&
884 git config --add -f .gitmodules submodule.subname.ignore dirty &&
885 git config --add -f .gitmodules submodule.subname.path sm &&
886 git status > output &&
887 test_cmp expect output &&
888 git config -f .gitmodules --remove-section submodule.subname &&
889 git config --unset diff.ignoreSubmodules
892 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
893 git config --add -f .gitmodules submodule.subname.ignore none &&
894 git config --add -f .gitmodules submodule.subname.path sm &&
895 git config --add submodule.subname.ignore dirty &&
896 git config --add submodule.subname.path sm &&
897 git status > output &&
898 test_cmp expect output &&
899 git config --remove-section submodule.subname &&
900 git config -f .gitmodules --remove-section submodule.subname
903 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
904 echo modified > sm/foo &&
905 git status --ignore-submodules=dirty > output &&
906 test_cmp expect output
909 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
910 git config --add -f .gitmodules submodule.subname.ignore dirty &&
911 git config --add -f .gitmodules submodule.subname.path sm &&
912 git status > output &&
913 test_cmp expect output &&
914 git config -f .gitmodules --remove-section submodule.subname
917 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
918 git config --add -f .gitmodules submodule.subname.ignore none &&
919 git config --add -f .gitmodules submodule.subname.path sm &&
920 git config --add submodule.subname.ignore dirty &&
921 git config --add submodule.subname.path sm &&
922 git status > output &&
923 test_cmp expect output &&
924 git config --remove-section submodule.subname &&
925 git config -f .gitmodules --remove-section submodule.subname
928 cat > expect << EOF
929 # On branch master
930 # Changes to be committed:
931 # (use "git reset HEAD <file>..." to unstage)
933 # modified: sm
935 # Changes not staged for commit:
936 # (use "git add <file>..." to update what will be committed)
937 # (use "git checkout -- <file>..." to discard changes in working directory)
938 # (commit or discard the untracked or modified content in submodules)
940 # modified: dir1/modified
941 # modified: sm (modified content)
943 # Submodule changes to be committed:
945 # * sm $head...$new_head (1):
946 # > Add bar
948 # Untracked files:
949 # (use "git add <file>..." to include in what will be committed)
951 # .gitmodules
952 # dir1/untracked
953 # dir2/modified
954 # dir2/untracked
955 # expect
956 # output
957 # untracked
960 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
961 git status --ignore-submodules=untracked > output &&
962 test_cmp expect output
965 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
966 git config --add -f .gitmodules submodule.subname.ignore untracked &&
967 git config --add -f .gitmodules submodule.subname.path sm &&
968 git status > output &&
969 test_cmp expect output &&
970 git config -f .gitmodules --remove-section submodule.subname
973 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
974 git config --add -f .gitmodules submodule.subname.ignore none &&
975 git config --add -f .gitmodules submodule.subname.path sm &&
976 git config --add submodule.subname.ignore untracked &&
977 git config --add submodule.subname.path sm &&
978 git status > output &&
979 test_cmp expect output &&
980 git config --remove-section submodule.subname &&
981 git config -f .gitmodules --remove-section submodule.subname
984 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
986 cat > expect << EOF
987 # On branch master
988 # Changes to be committed:
989 # (use "git reset HEAD <file>..." to unstage)
991 # modified: sm
993 # Changes not staged for commit:
994 # (use "git add <file>..." to update what will be committed)
995 # (use "git checkout -- <file>..." to discard changes in working directory)
997 # modified: dir1/modified
998 # modified: sm (new commits)
1000 # Submodule changes to be committed:
1002 # * sm $head...$new_head (1):
1003 # > Add bar
1005 # Submodules changed but not updated:
1007 # * sm $new_head...$head2 (1):
1008 # > 2nd commit
1010 # Untracked files:
1011 # (use "git add <file>..." to include in what will be committed)
1013 # .gitmodules
1014 # dir1/untracked
1015 # dir2/modified
1016 # dir2/untracked
1017 # expect
1018 # output
1019 # untracked
1022 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1023 git status --ignore-submodules=untracked > output &&
1024 test_cmp expect output
1027 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1028 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1029 git config --add -f .gitmodules submodule.subname.path sm &&
1030 git status > output &&
1031 test_cmp expect output &&
1032 git config -f .gitmodules --remove-section submodule.subname
1035 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1036 git config --add -f .gitmodules submodule.subname.ignore none &&
1037 git config --add -f .gitmodules submodule.subname.path sm &&
1038 git config --add submodule.subname.ignore untracked &&
1039 git config --add submodule.subname.path sm &&
1040 git status > output &&
1041 test_cmp expect output &&
1042 git config --remove-section submodule.subname &&
1043 git config -f .gitmodules --remove-section submodule.subname
1046 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1047 git status --ignore-submodules=dirty > output &&
1048 test_cmp expect output
1050 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1051 git config --add -f .gitmodules submodule.subname.ignore dirty &&
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
1058 test_expect_success ".git/config ignore=dirty 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 dirty &&
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
1069 cat > expect << EOF
1070 # On branch master
1071 # Changes not staged for commit:
1072 # (use "git add <file>..." to update what will be committed)
1073 # (use "git checkout -- <file>..." to discard changes in working directory)
1075 # modified: dir1/modified
1077 # Untracked files:
1078 # (use "git add <file>..." to include in what will be committed)
1080 # .gitmodules
1081 # dir1/untracked
1082 # dir2/modified
1083 # dir2/untracked
1084 # expect
1085 # output
1086 # untracked
1087 no changes added to commit (use "git add" and/or "git commit -a")
1090 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1091 git status --ignore-submodules=all > output &&
1092 test_cmp expect output
1095 test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1096 git config --add -f .gitmodules submodule.subname.ignore all &&
1097 git config --add -f .gitmodules submodule.subname.path sm &&
1098 git status > output &&
1099 test_cmp expect output &&
1100 git config -f .gitmodules --remove-section submodule.subname
1103 test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1104 git config --add -f .gitmodules submodule.subname.ignore none &&
1105 git config --add -f .gitmodules submodule.subname.path sm &&
1106 git config --add submodule.subname.ignore all &&
1107 git config --add submodule.subname.path sm &&
1108 git status > output &&
1109 test_cmp expect output &&
1110 git config --remove-section submodule.subname &&
1111 git config -f .gitmodules --remove-section submodule.subname
1114 test_done