Merge branch 'instaweb' of git://bogomips.org/git-svn
[git.git] / t / t7508-status.sh
blob1fdfbd38654a83771f677f2219403e3713abef51
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='git status'
8 . ./test-lib.sh
10 test_expect_success 'status -h in broken repository' '
11 mkdir broken &&
12 test_when_finished "rm -fr broken" &&
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 test_i18ngrep "[Uu]sage" broken/usage
22 test_expect_success 'commit -h in broken repository' '
23 mkdir broken &&
24 test_when_finished "rm -fr broken" &&
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 test_i18ngrep "[Uu]sage" broken/usage
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 . &&
45 git status >output &&
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
58 test_expect_success 'status (1)' '
59 test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output
62 cat >expect <<\EOF
63 # On branch master
64 # Changes to be committed:
65 # (use "git reset HEAD <file>..." to unstage)
67 # new file: dir2/added
69 # Changes not staged for commit:
70 # (use "git add <file>..." to update what will be committed)
71 # (use "git checkout -- <file>..." to discard changes in working directory)
73 # modified: dir1/modified
75 # Untracked files:
76 # (use "git add <file>..." to include in what will be committed)
78 # dir1/untracked
79 # dir2/modified
80 # dir2/untracked
81 # expect
82 # output
83 # untracked
84 EOF
86 test_expect_success 'status (2)' '
87 git status >output &&
88 test_i18ncmp expect output
91 cat >expect <<\EOF
92 # On branch master
93 # Changes to be committed:
94 # new file: dir2/added
96 # Changes not staged for commit:
97 # modified: dir1/modified
99 # Untracked files:
100 # dir1/untracked
101 # dir2/modified
102 # dir2/untracked
103 # expect
104 # output
105 # untracked
108 test_expect_success 'status (advice.statusHints false)' '
109 test_when_finished "git config --unset advice.statusHints" &&
110 git config advice.statusHints false &&
111 git status >output &&
112 test_i18ncmp expect output
116 cat >expect <<\EOF
117 M dir1/modified
118 A dir2/added
119 ?? dir1/untracked
120 ?? dir2/modified
121 ?? dir2/untracked
122 ?? expect
123 ?? output
124 ?? untracked
127 test_expect_success 'status -s' '
129 git status -s >output &&
130 test_cmp expect output
134 cat >expect <<\EOF
135 ## master
136 M dir1/modified
137 A dir2/added
138 ?? dir1/untracked
139 ?? dir2/modified
140 ?? dir2/untracked
141 ?? expect
142 ?? output
143 ?? untracked
146 test_expect_success 'status -s -b' '
148 git status -s -b >output &&
149 test_cmp expect output
153 test_expect_success 'setup dir3' '
154 mkdir dir3 &&
155 : >dir3/untracked1 &&
156 : >dir3/untracked2
159 cat >expect <<EOF
160 # On branch master
161 # Changes to be committed:
162 # (use "git reset HEAD <file>..." to unstage)
164 # new file: dir2/added
166 # Changes not staged for commit:
167 # (use "git add <file>..." to update what will be committed)
168 # (use "git checkout -- <file>..." to discard changes in working directory)
170 # modified: dir1/modified
172 # Untracked files not listed (use -u option to show untracked files)
174 test_expect_success 'status -uno' '
175 git status -uno >output &&
176 test_i18ncmp expect output
179 test_expect_success 'status (status.showUntrackedFiles no)' '
180 git config status.showuntrackedfiles no
181 test_when_finished "git config --unset status.showuntrackedfiles" &&
182 git status >output &&
183 test_i18ncmp expect output
186 cat >expect <<EOF
187 # On branch master
188 # Changes to be committed:
189 # new file: dir2/added
191 # Changes not staged for commit:
192 # modified: dir1/modified
194 # Untracked files not listed
196 git config advice.statusHints false
197 test_expect_success 'status -uno (advice.statusHints false)' '
198 git status -uno >output &&
199 test_i18ncmp expect output
201 git config --unset advice.statusHints
203 cat >expect << EOF
204 M dir1/modified
205 A dir2/added
207 test_expect_success 'status -s -uno' '
208 git status -s -uno >output &&
209 test_cmp expect output
212 test_expect_success 'status -s (status.showUntrackedFiles no)' '
213 git config status.showuntrackedfiles no
214 git status -s >output &&
215 test_cmp expect output
218 cat >expect <<EOF
219 # On branch master
220 # Changes to be committed:
221 # (use "git reset HEAD <file>..." to unstage)
223 # new file: dir2/added
225 # Changes not staged for commit:
226 # (use "git add <file>..." to update what will be committed)
227 # (use "git checkout -- <file>..." to discard changes in working directory)
229 # modified: dir1/modified
231 # Untracked files:
232 # (use "git add <file>..." to include in what will be committed)
234 # dir1/untracked
235 # dir2/modified
236 # dir2/untracked
237 # dir3/
238 # expect
239 # output
240 # untracked
242 test_expect_success 'status -unormal' '
243 git status -unormal >output &&
244 test_i18ncmp expect output
247 test_expect_success 'status (status.showUntrackedFiles normal)' '
248 git config status.showuntrackedfiles normal
249 test_when_finished "git config --unset status.showuntrackedfiles" &&
250 git status >output &&
251 test_i18ncmp expect output
254 cat >expect <<EOF
255 M dir1/modified
256 A dir2/added
257 ?? dir1/untracked
258 ?? dir2/modified
259 ?? dir2/untracked
260 ?? dir3/
261 ?? expect
262 ?? output
263 ?? untracked
265 test_expect_success 'status -s -unormal' '
266 git status -s -unormal >output &&
267 test_cmp expect output
270 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
271 git config status.showuntrackedfiles normal
272 git status -s >output &&
273 test_cmp expect output
276 cat >expect <<EOF
277 # On branch master
278 # Changes to be committed:
279 # (use "git reset HEAD <file>..." to unstage)
281 # new file: dir2/added
283 # Changes not staged for commit:
284 # (use "git add <file>..." to update what will be committed)
285 # (use "git checkout -- <file>..." to discard changes in working directory)
287 # modified: dir1/modified
289 # Untracked files:
290 # (use "git add <file>..." to include in what will be committed)
292 # dir1/untracked
293 # dir2/modified
294 # dir2/untracked
295 # dir3/untracked1
296 # dir3/untracked2
297 # expect
298 # output
299 # untracked
301 test_expect_success 'status -uall' '
302 git status -uall >output &&
303 test_i18ncmp expect output
306 test_expect_success 'status (status.showUntrackedFiles all)' '
307 git config status.showuntrackedfiles all
308 test_when_finished "git config --unset status.showuntrackedfiles" &&
309 git status >output &&
310 test_i18ncmp expect output
313 test_expect_success 'teardown dir3' '
314 rm -rf dir3
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
327 test_expect_success 'status -s -uall' '
328 git config --unset status.showuntrackedfiles
329 git status -s -uall >output &&
330 test_cmp expect output
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
340 cat >expect <<\EOF
341 # On branch master
342 # Changes to be committed:
343 # (use "git reset HEAD <file>..." to unstage)
345 # new file: ../dir2/added
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)
351 # modified: modified
353 # Untracked files:
354 # (use "git add <file>..." to include in what will be committed)
356 # untracked
357 # ../dir2/modified
358 # ../dir2/untracked
359 # ../expect
360 # ../output
361 # ../untracked
364 test_expect_success 'status with relative paths' '
365 (cd dir1 && git status) >output &&
366 test_i18ncmp expect output
369 cat >expect <<\EOF
370 M modified
371 A ../dir2/added
372 ?? untracked
373 ?? ../dir2/modified
374 ?? ../dir2/untracked
375 ?? ../expect
376 ?? ../output
377 ?? ../untracked
379 test_expect_success 'status -s with relative paths' '
381 (cd dir1 && git status -s) >output &&
382 test_cmp expect output
386 cat >expect <<\EOF
387 M dir1/modified
388 A dir2/added
389 ?? dir1/untracked
390 ?? dir2/modified
391 ?? dir2/untracked
392 ?? expect
393 ?? output
394 ?? untracked
397 test_expect_success 'status --porcelain ignores relative paths setting' '
399 (cd dir1 && git status --porcelain) >output &&
400 test_cmp expect output
404 test_expect_success 'setup unique colors' '
406 git config status.color.untracked blue &&
407 git config status.color.branch green
411 cat >expect <<\EOF
412 # On branch <GREEN>master<RESET>
413 # Changes to be committed:
414 # (use "git reset HEAD <file>..." to unstage)
416 # <GREEN>new file: dir2/added<RESET>
418 # Changes not staged for commit:
419 # (use "git add <file>..." to update what will be committed)
420 # (use "git checkout -- <file>..." to discard changes in working directory)
422 # <RED>modified: dir1/modified<RESET>
424 # Untracked files:
425 # (use "git add <file>..." to include in what will be committed)
427 # <BLUE>dir1/untracked<RESET>
428 # <BLUE>dir2/modified<RESET>
429 # <BLUE>dir2/untracked<RESET>
430 # <BLUE>expect<RESET>
431 # <BLUE>output<RESET>
432 # <BLUE>untracked<RESET>
435 test_expect_success 'status with color.ui' '
436 git config color.ui always &&
437 test_when_finished "git config --unset color.ui" &&
438 git status | test_decode_color >output &&
439 test_i18ncmp expect output
442 test_expect_success 'status with color.status' '
443 git config color.status always &&
444 test_when_finished "git config --unset color.status" &&
445 git status | test_decode_color >output &&
446 test_i18ncmp expect output
449 cat >expect <<\EOF
450 <RED>M<RESET> dir1/modified
451 <GREEN>A<RESET> dir2/added
452 <BLUE>??<RESET> dir1/untracked
453 <BLUE>??<RESET> dir2/modified
454 <BLUE>??<RESET> dir2/untracked
455 <BLUE>??<RESET> expect
456 <BLUE>??<RESET> output
457 <BLUE>??<RESET> untracked
460 test_expect_success 'status -s with color.ui' '
462 git config color.ui always &&
463 git status -s | test_decode_color >output &&
464 test_cmp expect output
468 test_expect_success 'status -s with color.status' '
470 git config --unset color.ui &&
471 git config color.status always &&
472 git status -s | test_decode_color >output &&
473 test_cmp expect output
477 cat >expect <<\EOF
478 ## <GREEN>master<RESET>
479 <RED>M<RESET> dir1/modified
480 <GREEN>A<RESET> dir2/added
481 <BLUE>??<RESET> dir1/untracked
482 <BLUE>??<RESET> dir2/modified
483 <BLUE>??<RESET> dir2/untracked
484 <BLUE>??<RESET> expect
485 <BLUE>??<RESET> output
486 <BLUE>??<RESET> untracked
489 test_expect_success 'status -s -b with color.status' '
491 git status -s -b | test_decode_color >output &&
492 test_cmp expect output
496 cat >expect <<\EOF
497 M dir1/modified
498 A dir2/added
499 ?? dir1/untracked
500 ?? dir2/modified
501 ?? dir2/untracked
502 ?? expect
503 ?? output
504 ?? untracked
507 test_expect_success 'status --porcelain ignores color.ui' '
509 git config --unset color.status &&
510 git config color.ui always &&
511 git status --porcelain | test_decode_color >output &&
512 test_cmp expect output
516 test_expect_success 'status --porcelain ignores color.status' '
518 git config --unset color.ui &&
519 git config color.status always &&
520 git status --porcelain | test_decode_color >output &&
521 test_cmp expect output
525 # recover unconditionally from color tests
526 git config --unset color.status
527 git config --unset color.ui
529 test_expect_success 'status --porcelain ignores -b' '
531 git status --porcelain -b >output &&
532 test_cmp expect output
536 cat >expect <<\EOF
537 # On branch master
538 # Changes to be committed:
539 # (use "git reset HEAD <file>..." to unstage)
541 # new file: dir2/added
543 # Changes not staged for commit:
544 # (use "git add <file>..." to update what will be committed)
545 # (use "git checkout -- <file>..." to discard changes in working directory)
547 # modified: dir1/modified
549 # Untracked files:
550 # (use "git add <file>..." to include in what will be committed)
552 # dir1/untracked
553 # dir2/modified
554 # dir2/untracked
555 # expect
556 # output
557 # untracked
561 test_expect_success 'status without relative paths' '
563 git config status.relativePaths false &&
564 test_when_finished "git config --unset status.relativePaths" &&
565 (cd dir1 && git status) >output &&
566 test_i18ncmp expect output
570 cat >expect <<\EOF
571 M dir1/modified
572 A dir2/added
573 ?? dir1/untracked
574 ?? dir2/modified
575 ?? dir2/untracked
576 ?? expect
577 ?? output
578 ?? untracked
581 test_expect_success 'status -s without relative paths' '
583 git config status.relativePaths false &&
584 test_when_finished "git config --unset status.relativePaths" &&
585 (cd dir1 && git status -s) >output &&
586 test_cmp expect output
590 cat <<EOF >expect
591 # On branch master
592 # Changes to be committed:
593 # (use "git reset HEAD <file>..." to unstage)
595 # modified: dir1/modified
597 # Untracked files:
598 # (use "git add <file>..." to include in what will be committed)
600 # dir1/untracked
601 # dir2/
602 # expect
603 # output
604 # untracked
606 test_expect_success 'dry-run of partial commit excluding new file in index' '
607 git commit --dry-run dir1/modified >output &&
608 test_i18ncmp expect output
611 cat >expect <<EOF
612 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
614 test_expect_success 'status refreshes the index' '
615 touch dir2/added &&
616 git status &&
617 git diff-files >output &&
618 test_cmp expect output
621 test_expect_success 'setup status submodule summary' '
622 test_create_repo sm && (
623 cd sm &&
624 >foo &&
625 git add foo &&
626 git commit -m "Add foo"
627 ) &&
628 git add sm
631 cat >expect <<EOF
632 # On branch master
633 # Changes to be committed:
634 # (use "git reset HEAD <file>..." to unstage)
636 # new file: dir2/added
637 # new file: sm
639 # Changes not staged for commit:
640 # (use "git add <file>..." to update what will be committed)
641 # (use "git checkout -- <file>..." to discard changes in working directory)
643 # modified: dir1/modified
645 # Untracked files:
646 # (use "git add <file>..." to include in what will be committed)
648 # dir1/untracked
649 # dir2/modified
650 # dir2/untracked
651 # expect
652 # output
653 # untracked
655 test_expect_success 'status submodule summary is disabled by default' '
656 git status >output &&
657 test_i18ncmp expect output
660 # we expect the same as the previous test
661 test_expect_success 'status --untracked-files=all does not show submodule' '
662 git status --untracked-files=all >output &&
663 test_i18ncmp expect output
666 cat >expect <<EOF
667 M dir1/modified
668 A dir2/added
669 A sm
670 ?? dir1/untracked
671 ?? dir2/modified
672 ?? dir2/untracked
673 ?? expect
674 ?? output
675 ?? untracked
677 test_expect_success 'status -s submodule summary is disabled by default' '
678 git status -s >output &&
679 test_cmp expect output
682 # we expect the same as the previous test
683 test_expect_success 'status -s --untracked-files=all does not show submodule' '
684 git status -s --untracked-files=all >output &&
685 test_cmp expect output
688 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
690 cat >expect <<EOF
691 # On branch master
692 # Changes to be committed:
693 # (use "git reset HEAD <file>..." to unstage)
695 # new file: dir2/added
696 # new file: sm
698 # Changes not staged for commit:
699 # (use "git add <file>..." to update what will be committed)
700 # (use "git checkout -- <file>..." to discard changes in working directory)
702 # modified: dir1/modified
704 # Submodule changes to be committed:
706 # * sm 0000000...$head (1):
707 # > Add foo
709 # Untracked files:
710 # (use "git add <file>..." to include in what will be committed)
712 # dir1/untracked
713 # dir2/modified
714 # dir2/untracked
715 # expect
716 # output
717 # untracked
719 test_expect_success 'status submodule summary' '
720 git config status.submodulesummary 10 &&
721 git status >output &&
722 test_i18ncmp expect output
725 cat >expect <<EOF
726 M dir1/modified
727 A dir2/added
728 A sm
729 ?? dir1/untracked
730 ?? dir2/modified
731 ?? dir2/untracked
732 ?? expect
733 ?? output
734 ?? untracked
736 test_expect_success 'status -s submodule summary' '
737 git status -s >output &&
738 test_cmp expect output
741 cat >expect <<EOF
742 # On branch master
743 # Changes not staged for commit:
744 # (use "git add <file>..." to update what will be committed)
745 # (use "git checkout -- <file>..." to discard changes in working directory)
747 # modified: dir1/modified
749 # Untracked files:
750 # (use "git add <file>..." to include in what will be committed)
752 # dir1/untracked
753 # dir2/modified
754 # dir2/untracked
755 # expect
756 # output
757 # untracked
758 no changes added to commit (use "git add" and/or "git commit -a")
760 test_expect_success 'status submodule summary (clean submodule): commit' '
761 git commit -m "commit submodule" &&
762 git config status.submodulesummary 10 &&
763 test_must_fail git commit --dry-run >output &&
764 test_i18ncmp expect output &&
765 git status >output &&
766 test_i18ncmp expect output
769 cat >expect <<EOF
770 M dir1/modified
771 ?? dir1/untracked
772 ?? dir2/modified
773 ?? dir2/untracked
774 ?? expect
775 ?? output
776 ?? untracked
778 test_expect_success 'status -s submodule summary (clean submodule)' '
779 git status -s >output &&
780 test_cmp expect output
783 test_expect_success 'status -z implies porcelain' '
784 git status --porcelain |
785 perl -pe "s/\012/\000/g" >expect &&
786 git status -z >output &&
787 test_cmp expect output
790 cat >expect <<EOF
791 # On branch master
792 # Changes to be committed:
793 # (use "git reset HEAD^1 <file>..." to unstage)
795 # new file: dir2/added
796 # new file: sm
798 # Changes not staged for commit:
799 # (use "git add <file>..." to update what will be committed)
800 # (use "git checkout -- <file>..." to discard changes in working directory)
802 # modified: dir1/modified
804 # Submodule changes to be committed:
806 # * sm 0000000...$head (1):
807 # > Add foo
809 # Untracked files:
810 # (use "git add <file>..." to include in what will be committed)
812 # dir1/untracked
813 # dir2/modified
814 # dir2/untracked
815 # expect
816 # output
817 # untracked
819 test_expect_success 'commit --dry-run submodule summary (--amend)' '
820 git config status.submodulesummary 10 &&
821 git commit --dry-run --amend >output &&
822 test_i18ncmp expect output
825 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
827 chmod a-w .git &&
828 # make dir1/tracked stat-dirty
829 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
830 git status -s >output &&
831 ! grep dir1/tracked output &&
832 # make sure "status" succeeded without writing index out
833 git diff-files | grep dir1/tracked
835 status=$?
836 chmod 775 .git
837 (exit $status)
840 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
841 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
842 touch .gitmodules
844 cat > expect << EOF
845 # On branch master
846 # Changes to be committed:
847 # (use "git reset HEAD <file>..." to unstage)
849 # modified: sm
851 # Changes not staged for commit:
852 # (use "git add <file>..." to update what will be committed)
853 # (use "git checkout -- <file>..." to discard changes in working directory)
855 # modified: dir1/modified
857 # Submodule changes to be committed:
859 # * sm $head...$new_head (1):
860 # > Add bar
862 # Untracked files:
863 # (use "git add <file>..." to include in what will be committed)
865 # .gitmodules
866 # dir1/untracked
867 # dir2/modified
868 # dir2/untracked
869 # expect
870 # output
871 # untracked
874 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
875 echo modified sm/untracked &&
876 git status --ignore-submodules=untracked >output &&
877 test_i18ncmp expect output
880 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
881 git config diff.ignoreSubmodules dirty &&
882 git status >output &&
883 test_i18ncmp expect output &&
884 git config --add -f .gitmodules submodule.subname.ignore untracked &&
885 git config --add -f .gitmodules submodule.subname.path sm &&
886 git status >output &&
887 test_i18ncmp expect output &&
888 git config -f .gitmodules --remove-section submodule.subname &&
889 git config --unset diff.ignoreSubmodules
892 test_expect_success '.git/config ignore=untracked 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 untracked &&
896 git config --add submodule.subname.path sm &&
897 git status >output &&
898 test_i18ncmp expect output &&
899 git config --remove-section submodule.subname &&
900 git config --remove-section -f .gitmodules submodule.subname
903 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
904 git status --ignore-submodules=dirty >output &&
905 test_i18ncmp expect output
908 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
909 git config diff.ignoreSubmodules dirty &&
910 git status >output &&
911 ! test -s actual &&
912 git config --add -f .gitmodules submodule.subname.ignore dirty &&
913 git config --add -f .gitmodules submodule.subname.path sm &&
914 git status >output &&
915 test_i18ncmp expect output &&
916 git config -f .gitmodules --remove-section submodule.subname &&
917 git config --unset diff.ignoreSubmodules
920 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
921 git config --add -f .gitmodules submodule.subname.ignore none &&
922 git config --add -f .gitmodules submodule.subname.path sm &&
923 git config --add submodule.subname.ignore dirty &&
924 git config --add submodule.subname.path sm &&
925 git status >output &&
926 test_i18ncmp expect output &&
927 git config --remove-section submodule.subname &&
928 git config -f .gitmodules --remove-section submodule.subname
931 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
932 echo modified >sm/foo &&
933 git status --ignore-submodules=dirty >output &&
934 test_i18ncmp expect output
937 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
938 git config --add -f .gitmodules submodule.subname.ignore dirty &&
939 git config --add -f .gitmodules submodule.subname.path sm &&
940 git status >output &&
941 test_i18ncmp expect output &&
942 git config -f .gitmodules --remove-section submodule.subname
945 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
946 git config --add -f .gitmodules submodule.subname.ignore none &&
947 git config --add -f .gitmodules submodule.subname.path sm &&
948 git config --add submodule.subname.ignore dirty &&
949 git config --add submodule.subname.path sm &&
950 git status >output &&
951 test_i18ncmp expect output &&
952 git config --remove-section submodule.subname &&
953 git config -f .gitmodules --remove-section submodule.subname
956 cat > expect << EOF
957 # On branch master
958 # Changes to be committed:
959 # (use "git reset HEAD <file>..." to unstage)
961 # modified: sm
963 # Changes not staged for commit:
964 # (use "git add <file>..." to update what will be committed)
965 # (use "git checkout -- <file>..." to discard changes in working directory)
966 # (commit or discard the untracked or modified content in submodules)
968 # modified: dir1/modified
969 # modified: sm (modified content)
971 # Submodule changes to be committed:
973 # * sm $head...$new_head (1):
974 # > Add bar
976 # Untracked files:
977 # (use "git add <file>..." to include in what will be committed)
979 # .gitmodules
980 # dir1/untracked
981 # dir2/modified
982 # dir2/untracked
983 # expect
984 # output
985 # untracked
988 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
989 git status --ignore-submodules=untracked > output &&
990 test_i18ncmp expect output
993 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
994 git config --add -f .gitmodules submodule.subname.ignore untracked &&
995 git config --add -f .gitmodules submodule.subname.path sm &&
996 git status >output &&
997 test_i18ncmp expect output &&
998 git config -f .gitmodules --remove-section submodule.subname
1001 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1002 git config --add -f .gitmodules submodule.subname.ignore none &&
1003 git config --add -f .gitmodules submodule.subname.path sm &&
1004 git config --add submodule.subname.ignore untracked &&
1005 git config --add submodule.subname.path sm &&
1006 git status >output &&
1007 test_i18ncmp expect output &&
1008 git config --remove-section submodule.subname &&
1009 git config -f .gitmodules --remove-section submodule.subname
1012 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1014 cat > expect << EOF
1015 # On branch master
1016 # Changes to be committed:
1017 # (use "git reset HEAD <file>..." to unstage)
1019 # modified: sm
1021 # Changes not staged for commit:
1022 # (use "git add <file>..." to update what will be committed)
1023 # (use "git checkout -- <file>..." to discard changes in working directory)
1025 # modified: dir1/modified
1026 # modified: sm (new commits)
1028 # Submodule changes to be committed:
1030 # * sm $head...$new_head (1):
1031 # > Add bar
1033 # Submodules changed but not updated:
1035 # * sm $new_head...$head2 (1):
1036 # > 2nd commit
1038 # Untracked files:
1039 # (use "git add <file>..." to include in what will be committed)
1041 # .gitmodules
1042 # dir1/untracked
1043 # dir2/modified
1044 # dir2/untracked
1045 # expect
1046 # output
1047 # untracked
1050 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1051 git status --ignore-submodules=untracked > output &&
1052 test_i18ncmp expect output
1055 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1056 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1057 git config --add -f .gitmodules submodule.subname.path sm &&
1058 git status >output &&
1059 test_i18ncmp expect output &&
1060 git config -f .gitmodules --remove-section submodule.subname
1063 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1064 git config --add -f .gitmodules submodule.subname.ignore none &&
1065 git config --add -f .gitmodules submodule.subname.path sm &&
1066 git config --add submodule.subname.ignore untracked &&
1067 git config --add submodule.subname.path sm &&
1068 git status >output &&
1069 test_i18ncmp expect output &&
1070 git config --remove-section submodule.subname &&
1071 git config -f .gitmodules --remove-section submodule.subname
1074 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1075 git status --ignore-submodules=dirty > output &&
1076 test_i18ncmp expect output
1078 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1079 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1080 git config --add -f .gitmodules submodule.subname.path sm &&
1081 git status >output &&
1082 test_i18ncmp expect output &&
1083 git config -f .gitmodules --remove-section submodule.subname
1086 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1087 git config --add -f .gitmodules submodule.subname.ignore none &&
1088 git config --add -f .gitmodules submodule.subname.path sm &&
1089 git config --add submodule.subname.ignore dirty &&
1090 git config --add submodule.subname.path sm &&
1091 git status >output &&
1092 test_i18ncmp expect output &&
1093 git config --remove-section submodule.subname &&
1094 git config -f .gitmodules --remove-section submodule.subname
1097 cat > expect << EOF
1098 # On branch master
1099 # Changes not staged for commit:
1100 # (use "git add <file>..." to update what will be committed)
1101 # (use "git checkout -- <file>..." to discard changes in working directory)
1103 # modified: dir1/modified
1105 # Untracked files:
1106 # (use "git add <file>..." to include in what will be committed)
1108 # .gitmodules
1109 # dir1/untracked
1110 # dir2/modified
1111 # dir2/untracked
1112 # expect
1113 # output
1114 # untracked
1115 no changes added to commit (use "git add" and/or "git commit -a")
1118 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1119 git status --ignore-submodules=all > output &&
1120 test_i18ncmp expect output
1123 test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1124 git config --add -f .gitmodules submodule.subname.ignore all &&
1125 git config --add -f .gitmodules submodule.subname.path sm &&
1126 git status > output &&
1127 test_cmp expect output &&
1128 git config -f .gitmodules --remove-section submodule.subname
1131 test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1132 git config --add -f .gitmodules submodule.subname.ignore none &&
1133 git config --add -f .gitmodules submodule.subname.path sm &&
1134 git config --add submodule.subname.ignore all &&
1135 git config --add submodule.subname.path sm &&
1136 git status > output &&
1137 test_cmp expect output &&
1138 git config --remove-section submodule.subname &&
1139 git config -f .gitmodules --remove-section submodule.subname
1142 test_done