Merge branch 'fa/maint-config-doc'
[git/jrn.git] / t / t7508-status.sh
blob8f5cfac33158f96d1397fecf965abcd43c119e8b
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 test_expect_success 'status --column' '
63 COLUMNS=50 git status --column="column dense" >output &&
64 cat >expect <<\EOF &&
65 # On branch master
66 # Changes to be committed:
67 # (use "git reset HEAD <file>..." to unstage)
69 # new file: dir2/added
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)
75 # modified: dir1/modified
77 # Untracked files:
78 # (use "git add <file>..." to include in what will be committed)
80 # dir1/untracked dir2/untracked untracked
81 # dir2/modified output
82 EOF
83 test_cmp expect output
86 cat >expect <<\EOF
87 # On branch master
88 # Changes to be committed:
89 # (use "git reset HEAD <file>..." to unstage)
91 # new file: dir2/added
93 # Changes not staged for commit:
94 # (use "git add <file>..." to update what will be committed)
95 # (use "git checkout -- <file>..." to discard changes in working directory)
97 # modified: dir1/modified
99 # Untracked files:
100 # (use "git add <file>..." to include in what will be committed)
102 # dir1/untracked
103 # dir2/modified
104 # dir2/untracked
105 # expect
106 # output
107 # untracked
110 test_expect_success 'status (2)' '
111 git status >output &&
112 test_i18ncmp expect output
115 cat >expect <<\EOF
116 # On branch master
117 # Changes to be committed:
118 # new file: dir2/added
120 # Changes not staged for commit:
121 # modified: dir1/modified
123 # Untracked files:
124 # dir1/untracked
125 # dir2/modified
126 # dir2/untracked
127 # expect
128 # output
129 # untracked
132 test_expect_success 'status (advice.statusHints false)' '
133 test_when_finished "git config --unset advice.statusHints" &&
134 git config advice.statusHints false &&
135 git status >output &&
136 test_i18ncmp expect output
140 cat >expect <<\EOF
141 M dir1/modified
142 A dir2/added
143 ?? dir1/untracked
144 ?? dir2/modified
145 ?? dir2/untracked
146 ?? expect
147 ?? output
148 ?? untracked
151 test_expect_success 'status -s' '
153 git status -s >output &&
154 test_cmp expect output
158 test_expect_success 'status with gitignore' '
160 echo ".gitignore" &&
161 echo "expect" &&
162 echo "output" &&
163 echo "untracked"
164 } >.gitignore &&
166 cat >expect <<-\EOF &&
167 M dir1/modified
168 A dir2/added
169 ?? dir2/modified
171 git status -s >output &&
172 test_cmp expect output &&
174 cat >expect <<-\EOF &&
175 M dir1/modified
176 A dir2/added
177 ?? dir2/modified
178 !! .gitignore
179 !! dir1/untracked
180 !! dir2/untracked
181 !! expect
182 !! output
183 !! untracked
185 git status -s --ignored >output &&
186 test_cmp expect output &&
188 cat >expect <<-\EOF &&
189 # On branch master
190 # Changes to be committed:
191 # (use "git reset HEAD <file>..." to unstage)
193 # new file: dir2/added
195 # Changes not staged for commit:
196 # (use "git add <file>..." to update what will be committed)
197 # (use "git checkout -- <file>..." to discard changes in working directory)
199 # modified: dir1/modified
201 # Untracked files:
202 # (use "git add <file>..." to include in what will be committed)
204 # dir2/modified
205 # Ignored files:
206 # (use "git add -f <file>..." to include in what will be committed)
208 # .gitignore
209 # dir1/untracked
210 # dir2/untracked
211 # expect
212 # output
213 # untracked
215 git status --ignored >output &&
216 test_i18ncmp expect output
219 test_expect_success 'status with gitignore (nothing untracked)' '
221 echo ".gitignore" &&
222 echo "expect" &&
223 echo "dir2/modified" &&
224 echo "output" &&
225 echo "untracked"
226 } >.gitignore &&
228 cat >expect <<-\EOF &&
229 M dir1/modified
230 A dir2/added
232 git status -s >output &&
233 test_cmp expect output &&
235 cat >expect <<-\EOF &&
236 M dir1/modified
237 A dir2/added
238 !! .gitignore
239 !! dir1/untracked
240 !! dir2/modified
241 !! dir2/untracked
242 !! expect
243 !! output
244 !! untracked
246 git status -s --ignored >output &&
247 test_cmp expect output &&
249 cat >expect <<-\EOF &&
250 # On branch master
251 # Changes to be committed:
252 # (use "git reset HEAD <file>..." to unstage)
254 # new file: dir2/added
256 # Changes not staged for commit:
257 # (use "git add <file>..." to update what will be committed)
258 # (use "git checkout -- <file>..." to discard changes in working directory)
260 # modified: dir1/modified
262 # Ignored files:
263 # (use "git add -f <file>..." to include in what will be committed)
265 # .gitignore
266 # dir1/untracked
267 # dir2/modified
268 # dir2/untracked
269 # expect
270 # output
271 # untracked
273 git status --ignored >output &&
274 test_i18ncmp expect output
277 rm -f .gitignore
279 cat >expect <<\EOF
280 ## master
281 M dir1/modified
282 A dir2/added
283 ?? dir1/untracked
284 ?? dir2/modified
285 ?? dir2/untracked
286 ?? expect
287 ?? output
288 ?? untracked
291 test_expect_success 'status -s -b' '
293 git status -s -b >output &&
294 test_cmp expect output
298 test_expect_success 'setup dir3' '
299 mkdir dir3 &&
300 : >dir3/untracked1 &&
301 : >dir3/untracked2
304 cat >expect <<EOF
305 # On branch master
306 # Changes to be committed:
307 # (use "git reset HEAD <file>..." to unstage)
309 # new file: dir2/added
311 # Changes not staged for commit:
312 # (use "git add <file>..." to update what will be committed)
313 # (use "git checkout -- <file>..." to discard changes in working directory)
315 # modified: dir1/modified
317 # Untracked files not listed (use -u option to show untracked files)
319 test_expect_success 'status -uno' '
320 git status -uno >output &&
321 test_i18ncmp expect output
324 test_expect_success 'status (status.showUntrackedFiles no)' '
325 git config status.showuntrackedfiles no
326 test_when_finished "git config --unset status.showuntrackedfiles" &&
327 git status >output &&
328 test_i18ncmp expect output
331 cat >expect <<EOF
332 # On branch master
333 # Changes to be committed:
334 # new file: dir2/added
336 # Changes not staged for commit:
337 # modified: dir1/modified
339 # Untracked files not listed
341 git config advice.statusHints false
342 test_expect_success 'status -uno (advice.statusHints false)' '
343 git status -uno >output &&
344 test_i18ncmp expect output
346 git config --unset advice.statusHints
348 cat >expect << EOF
349 M dir1/modified
350 A dir2/added
352 test_expect_success 'status -s -uno' '
353 git status -s -uno >output &&
354 test_cmp expect output
357 test_expect_success 'status -s (status.showUntrackedFiles no)' '
358 git config status.showuntrackedfiles no
359 git status -s >output &&
360 test_cmp expect output
363 cat >expect <<EOF
364 # On branch master
365 # Changes to be committed:
366 # (use "git reset HEAD <file>..." to unstage)
368 # new file: dir2/added
370 # Changes not staged for commit:
371 # (use "git add <file>..." to update what will be committed)
372 # (use "git checkout -- <file>..." to discard changes in working directory)
374 # modified: dir1/modified
376 # Untracked files:
377 # (use "git add <file>..." to include in what will be committed)
379 # dir1/untracked
380 # dir2/modified
381 # dir2/untracked
382 # dir3/
383 # expect
384 # output
385 # untracked
387 test_expect_success 'status -unormal' '
388 git status -unormal >output &&
389 test_i18ncmp expect output
392 test_expect_success 'status (status.showUntrackedFiles normal)' '
393 git config status.showuntrackedfiles normal
394 test_when_finished "git config --unset status.showuntrackedfiles" &&
395 git status >output &&
396 test_i18ncmp expect output
399 cat >expect <<EOF
400 M dir1/modified
401 A dir2/added
402 ?? dir1/untracked
403 ?? dir2/modified
404 ?? dir2/untracked
405 ?? dir3/
406 ?? expect
407 ?? output
408 ?? untracked
410 test_expect_success 'status -s -unormal' '
411 git status -s -unormal >output &&
412 test_cmp expect output
415 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
416 git config status.showuntrackedfiles normal
417 git status -s >output &&
418 test_cmp expect output
421 cat >expect <<EOF
422 # On branch master
423 # Changes to be committed:
424 # (use "git reset HEAD <file>..." to unstage)
426 # new file: dir2/added
428 # Changes not staged for commit:
429 # (use "git add <file>..." to update what will be committed)
430 # (use "git checkout -- <file>..." to discard changes in working directory)
432 # modified: dir1/modified
434 # Untracked files:
435 # (use "git add <file>..." to include in what will be committed)
437 # dir1/untracked
438 # dir2/modified
439 # dir2/untracked
440 # dir3/untracked1
441 # dir3/untracked2
442 # expect
443 # output
444 # untracked
446 test_expect_success 'status -uall' '
447 git status -uall >output &&
448 test_i18ncmp expect output
451 test_expect_success 'status (status.showUntrackedFiles all)' '
452 git config status.showuntrackedfiles all
453 test_when_finished "git config --unset status.showuntrackedfiles" &&
454 git status >output &&
455 test_i18ncmp expect output
458 test_expect_success 'teardown dir3' '
459 rm -rf dir3
462 cat >expect <<EOF
463 M dir1/modified
464 A dir2/added
465 ?? dir1/untracked
466 ?? dir2/modified
467 ?? dir2/untracked
468 ?? expect
469 ?? output
470 ?? untracked
472 test_expect_success 'status -s -uall' '
473 git config --unset status.showuntrackedfiles
474 git status -s -uall >output &&
475 test_cmp expect output
477 test_expect_success 'status -s (status.showUntrackedFiles all)' '
478 git config status.showuntrackedfiles all
479 git status -s >output &&
480 rm -rf dir3 &&
481 git config --unset status.showuntrackedfiles &&
482 test_cmp expect output
485 cat >expect <<\EOF
486 # On branch master
487 # Changes to be committed:
488 # (use "git reset HEAD <file>..." to unstage)
490 # new file: ../dir2/added
492 # Changes not staged for commit:
493 # (use "git add <file>..." to update what will be committed)
494 # (use "git checkout -- <file>..." to discard changes in working directory)
496 # modified: modified
498 # Untracked files:
499 # (use "git add <file>..." to include in what will be committed)
501 # untracked
502 # ../dir2/modified
503 # ../dir2/untracked
504 # ../expect
505 # ../output
506 # ../untracked
509 test_expect_success 'status with relative paths' '
510 (cd dir1 && git status) >output &&
511 test_i18ncmp expect output
514 cat >expect <<\EOF
515 M modified
516 A ../dir2/added
517 ?? untracked
518 ?? ../dir2/modified
519 ?? ../dir2/untracked
520 ?? ../expect
521 ?? ../output
522 ?? ../untracked
524 test_expect_success 'status -s with relative paths' '
526 (cd dir1 && git status -s) >output &&
527 test_cmp expect output
531 cat >expect <<\EOF
532 M dir1/modified
533 A dir2/added
534 ?? dir1/untracked
535 ?? dir2/modified
536 ?? dir2/untracked
537 ?? expect
538 ?? output
539 ?? untracked
542 test_expect_success 'status --porcelain ignores relative paths setting' '
544 (cd dir1 && git status --porcelain) >output &&
545 test_cmp expect output
549 test_expect_success 'setup unique colors' '
551 git config status.color.untracked blue &&
552 git config status.color.branch green
556 cat >expect <<\EOF
557 # On branch <GREEN>master<RESET>
558 # Changes to be committed:
559 # (use "git reset HEAD <file>..." to unstage)
561 # <GREEN>new file: dir2/added<RESET>
563 # Changes not staged for commit:
564 # (use "git add <file>..." to update what will be committed)
565 # (use "git checkout -- <file>..." to discard changes in working directory)
567 # <RED>modified: dir1/modified<RESET>
569 # Untracked files:
570 # (use "git add <file>..." to include in what will be committed)
572 # <BLUE>dir1/untracked<RESET>
573 # <BLUE>dir2/modified<RESET>
574 # <BLUE>dir2/untracked<RESET>
575 # <BLUE>expect<RESET>
576 # <BLUE>output<RESET>
577 # <BLUE>untracked<RESET>
580 test_expect_success 'status with color.ui' '
581 git config color.ui always &&
582 test_when_finished "git config --unset color.ui" &&
583 git status | test_decode_color >output &&
584 test_i18ncmp expect output
587 test_expect_success 'status with color.status' '
588 git config color.status always &&
589 test_when_finished "git config --unset color.status" &&
590 git status | test_decode_color >output &&
591 test_i18ncmp expect output
594 cat >expect <<\EOF
595 <RED>M<RESET> dir1/modified
596 <GREEN>A<RESET> dir2/added
597 <BLUE>??<RESET> dir1/untracked
598 <BLUE>??<RESET> dir2/modified
599 <BLUE>??<RESET> dir2/untracked
600 <BLUE>??<RESET> expect
601 <BLUE>??<RESET> output
602 <BLUE>??<RESET> untracked
605 test_expect_success 'status -s with color.ui' '
607 git config color.ui always &&
608 git status -s | test_decode_color >output &&
609 test_cmp expect output
613 test_expect_success 'status -s with color.status' '
615 git config --unset color.ui &&
616 git config color.status always &&
617 git status -s | test_decode_color >output &&
618 test_cmp expect output
622 cat >expect <<\EOF
623 ## <GREEN>master<RESET>
624 <RED>M<RESET> dir1/modified
625 <GREEN>A<RESET> dir2/added
626 <BLUE>??<RESET> dir1/untracked
627 <BLUE>??<RESET> dir2/modified
628 <BLUE>??<RESET> dir2/untracked
629 <BLUE>??<RESET> expect
630 <BLUE>??<RESET> output
631 <BLUE>??<RESET> untracked
634 test_expect_success 'status -s -b with color.status' '
636 git status -s -b | test_decode_color >output &&
637 test_cmp expect output
641 cat >expect <<\EOF
642 M dir1/modified
643 A dir2/added
644 ?? dir1/untracked
645 ?? dir2/modified
646 ?? dir2/untracked
647 ?? expect
648 ?? output
649 ?? untracked
652 test_expect_success 'status --porcelain ignores color.ui' '
654 git config --unset color.status &&
655 git config color.ui always &&
656 git status --porcelain | test_decode_color >output &&
657 test_cmp expect output
661 test_expect_success 'status --porcelain ignores color.status' '
663 git config --unset color.ui &&
664 git config color.status always &&
665 git status --porcelain | test_decode_color >output &&
666 test_cmp expect output
670 # recover unconditionally from color tests
671 git config --unset color.status
672 git config --unset color.ui
674 test_expect_success 'status --porcelain ignores -b' '
676 git status --porcelain -b >output &&
677 test_cmp expect output
681 cat >expect <<\EOF
682 # On branch master
683 # Changes to be committed:
684 # (use "git reset HEAD <file>..." to unstage)
686 # new file: dir2/added
688 # Changes not staged for commit:
689 # (use "git add <file>..." to update what will be committed)
690 # (use "git checkout -- <file>..." to discard changes in working directory)
692 # modified: dir1/modified
694 # Untracked files:
695 # (use "git add <file>..." to include in what will be committed)
697 # dir1/untracked
698 # dir2/modified
699 # dir2/untracked
700 # expect
701 # output
702 # untracked
706 test_expect_success 'status without relative paths' '
708 git config status.relativePaths false &&
709 test_when_finished "git config --unset status.relativePaths" &&
710 (cd dir1 && git status) >output &&
711 test_i18ncmp expect output
715 cat >expect <<\EOF
716 M dir1/modified
717 A dir2/added
718 ?? dir1/untracked
719 ?? dir2/modified
720 ?? dir2/untracked
721 ?? expect
722 ?? output
723 ?? untracked
726 test_expect_success 'status -s without relative paths' '
728 git config status.relativePaths false &&
729 test_when_finished "git config --unset status.relativePaths" &&
730 (cd dir1 && git status -s) >output &&
731 test_cmp expect output
735 cat <<EOF >expect
736 # On branch master
737 # Changes to be committed:
738 # (use "git reset HEAD <file>..." to unstage)
740 # modified: dir1/modified
742 # Untracked files:
743 # (use "git add <file>..." to include in what will be committed)
745 # dir1/untracked
746 # dir2/
747 # expect
748 # output
749 # untracked
751 test_expect_success 'dry-run of partial commit excluding new file in index' '
752 git commit --dry-run dir1/modified >output &&
753 test_i18ncmp expect output
756 cat >expect <<EOF
757 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
759 test_expect_success 'status refreshes the index' '
760 touch dir2/added &&
761 git status &&
762 git diff-files >output &&
763 test_cmp expect output
766 test_expect_success 'setup status submodule summary' '
767 test_create_repo sm && (
768 cd sm &&
769 >foo &&
770 git add foo &&
771 git commit -m "Add foo"
772 ) &&
773 git add sm
776 cat >expect <<EOF
777 # On branch master
778 # Changes to be committed:
779 # (use "git reset HEAD <file>..." to unstage)
781 # new file: dir2/added
782 # new file: sm
784 # Changes not staged for commit:
785 # (use "git add <file>..." to update what will be committed)
786 # (use "git checkout -- <file>..." to discard changes in working directory)
788 # modified: dir1/modified
790 # Untracked files:
791 # (use "git add <file>..." to include in what will be committed)
793 # dir1/untracked
794 # dir2/modified
795 # dir2/untracked
796 # expect
797 # output
798 # untracked
800 test_expect_success 'status submodule summary is disabled by default' '
801 git status >output &&
802 test_i18ncmp expect output
805 # we expect the same as the previous test
806 test_expect_success 'status --untracked-files=all does not show submodule' '
807 git status --untracked-files=all >output &&
808 test_i18ncmp expect output
811 cat >expect <<EOF
812 M dir1/modified
813 A dir2/added
814 A sm
815 ?? dir1/untracked
816 ?? dir2/modified
817 ?? dir2/untracked
818 ?? expect
819 ?? output
820 ?? untracked
822 test_expect_success 'status -s submodule summary is disabled by default' '
823 git status -s >output &&
824 test_cmp expect output
827 # we expect the same as the previous test
828 test_expect_success 'status -s --untracked-files=all does not show submodule' '
829 git status -s --untracked-files=all >output &&
830 test_cmp expect output
833 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
835 cat >expect <<EOF
836 # On branch master
837 # Changes to be committed:
838 # (use "git reset HEAD <file>..." to unstage)
840 # new file: dir2/added
841 # new file: sm
843 # Changes not staged for commit:
844 # (use "git add <file>..." to update what will be committed)
845 # (use "git checkout -- <file>..." to discard changes in working directory)
847 # modified: dir1/modified
849 # Submodule changes to be committed:
851 # * sm 0000000...$head (1):
852 # > Add foo
854 # Untracked files:
855 # (use "git add <file>..." to include in what will be committed)
857 # dir1/untracked
858 # dir2/modified
859 # dir2/untracked
860 # expect
861 # output
862 # untracked
864 test_expect_success 'status submodule summary' '
865 git config status.submodulesummary 10 &&
866 git status >output &&
867 test_i18ncmp expect output
870 cat >expect <<EOF
871 M dir1/modified
872 A dir2/added
873 A sm
874 ?? dir1/untracked
875 ?? dir2/modified
876 ?? dir2/untracked
877 ?? expect
878 ?? output
879 ?? untracked
881 test_expect_success 'status -s submodule summary' '
882 git status -s >output &&
883 test_cmp expect output
886 cat >expect <<EOF
887 # On branch master
888 # Changes not staged for commit:
889 # (use "git add <file>..." to update what will be committed)
890 # (use "git checkout -- <file>..." to discard changes in working directory)
892 # modified: dir1/modified
894 # Untracked files:
895 # (use "git add <file>..." to include in what will be committed)
897 # dir1/untracked
898 # dir2/modified
899 # dir2/untracked
900 # expect
901 # output
902 # untracked
903 no changes added to commit (use "git add" and/or "git commit -a")
905 test_expect_success 'status submodule summary (clean submodule): commit' '
906 git commit -m "commit submodule" &&
907 git config status.submodulesummary 10 &&
908 test_must_fail git commit --dry-run >output &&
909 test_i18ncmp expect output &&
910 git status >output &&
911 test_i18ncmp expect output
914 cat >expect <<EOF
915 M dir1/modified
916 ?? dir1/untracked
917 ?? dir2/modified
918 ?? dir2/untracked
919 ?? expect
920 ?? output
921 ?? untracked
923 test_expect_success 'status -s submodule summary (clean submodule)' '
924 git status -s >output &&
925 test_cmp expect output
928 test_expect_success 'status -z implies porcelain' '
929 git status --porcelain |
930 perl -pe "s/\012/\000/g" >expect &&
931 git status -z >output &&
932 test_cmp expect output
935 cat >expect <<EOF
936 # On branch master
937 # Changes to be committed:
938 # (use "git reset HEAD^1 <file>..." to unstage)
940 # new file: dir2/added
941 # new file: sm
943 # Changes not staged for commit:
944 # (use "git add <file>..." to update what will be committed)
945 # (use "git checkout -- <file>..." to discard changes in working directory)
947 # modified: dir1/modified
949 # Submodule changes to be committed:
951 # * sm 0000000...$head (1):
952 # > Add foo
954 # Untracked files:
955 # (use "git add <file>..." to include in what will be committed)
957 # dir1/untracked
958 # dir2/modified
959 # dir2/untracked
960 # expect
961 # output
962 # untracked
964 test_expect_success 'commit --dry-run submodule summary (--amend)' '
965 git config status.submodulesummary 10 &&
966 git commit --dry-run --amend >output &&
967 test_i18ncmp expect output
970 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
972 chmod a-w .git &&
973 # make dir1/tracked stat-dirty
974 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
975 git status -s >output &&
976 ! grep dir1/tracked output &&
977 # make sure "status" succeeded without writing index out
978 git diff-files | grep dir1/tracked
980 status=$?
981 chmod 775 .git
982 (exit $status)
985 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
986 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
987 touch .gitmodules
989 cat > expect << EOF
990 # On branch master
991 # Changes to be committed:
992 # (use "git reset HEAD <file>..." to unstage)
994 # modified: sm
996 # Changes not staged for commit:
997 # (use "git add <file>..." to update what will be committed)
998 # (use "git checkout -- <file>..." to discard changes in working directory)
1000 # modified: dir1/modified
1002 # Submodule changes to be committed:
1004 # * sm $head...$new_head (1):
1005 # > Add bar
1007 # Untracked files:
1008 # (use "git add <file>..." to include in what will be committed)
1010 # .gitmodules
1011 # dir1/untracked
1012 # dir2/modified
1013 # dir2/untracked
1014 # expect
1015 # output
1016 # untracked
1019 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1020 echo modified sm/untracked &&
1021 git status --ignore-submodules=untracked >output &&
1022 test_i18ncmp expect output
1025 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1026 git config diff.ignoreSubmodules dirty &&
1027 git status >output &&
1028 test_i18ncmp expect output &&
1029 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1030 git config --add -f .gitmodules submodule.subname.path sm &&
1031 git status >output &&
1032 test_i18ncmp expect output &&
1033 git config -f .gitmodules --remove-section submodule.subname &&
1034 git config --unset diff.ignoreSubmodules
1037 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1038 git config --add -f .gitmodules submodule.subname.ignore none &&
1039 git config --add -f .gitmodules submodule.subname.path sm &&
1040 git config --add submodule.subname.ignore untracked &&
1041 git config --add submodule.subname.path sm &&
1042 git status >output &&
1043 test_i18ncmp expect output &&
1044 git config --remove-section submodule.subname &&
1045 git config --remove-section -f .gitmodules submodule.subname
1048 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1049 git status --ignore-submodules=dirty >output &&
1050 test_i18ncmp expect output
1053 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1054 git config diff.ignoreSubmodules dirty &&
1055 git status >output &&
1056 ! test -s actual &&
1057 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1058 git config --add -f .gitmodules submodule.subname.path sm &&
1059 git status >output &&
1060 test_i18ncmp expect output &&
1061 git config -f .gitmodules --remove-section submodule.subname &&
1062 git config --unset diff.ignoreSubmodules
1065 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1066 git config --add -f .gitmodules submodule.subname.ignore none &&
1067 git config --add -f .gitmodules submodule.subname.path sm &&
1068 git config --add submodule.subname.ignore dirty &&
1069 git config --add submodule.subname.path sm &&
1070 git status >output &&
1071 test_i18ncmp expect output &&
1072 git config --remove-section submodule.subname &&
1073 git config -f .gitmodules --remove-section submodule.subname
1076 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1077 echo modified >sm/foo &&
1078 git status --ignore-submodules=dirty >output &&
1079 test_i18ncmp expect output
1082 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
1083 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1084 git config --add -f .gitmodules submodule.subname.path sm &&
1085 git status >output &&
1086 test_i18ncmp expect output &&
1087 git config -f .gitmodules --remove-section submodule.subname
1090 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
1091 git config --add -f .gitmodules submodule.subname.ignore none &&
1092 git config --add -f .gitmodules submodule.subname.path sm &&
1093 git config --add submodule.subname.ignore dirty &&
1094 git config --add submodule.subname.path sm &&
1095 git status >output &&
1096 test_i18ncmp expect output &&
1097 git config --remove-section submodule.subname &&
1098 git config -f .gitmodules --remove-section submodule.subname
1101 cat > expect << EOF
1102 # On branch master
1103 # Changes to be committed:
1104 # (use "git reset HEAD <file>..." to unstage)
1106 # modified: sm
1108 # Changes not staged for commit:
1109 # (use "git add <file>..." to update what will be committed)
1110 # (use "git checkout -- <file>..." to discard changes in working directory)
1111 # (commit or discard the untracked or modified content in submodules)
1113 # modified: dir1/modified
1114 # modified: sm (modified content)
1116 # Submodule changes to be committed:
1118 # * sm $head...$new_head (1):
1119 # > Add bar
1121 # Untracked files:
1122 # (use "git add <file>..." to include in what will be committed)
1124 # .gitmodules
1125 # dir1/untracked
1126 # dir2/modified
1127 # dir2/untracked
1128 # expect
1129 # output
1130 # untracked
1133 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1134 git status --ignore-submodules=untracked > output &&
1135 test_i18ncmp expect output
1138 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
1139 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1140 git config --add -f .gitmodules submodule.subname.path sm &&
1141 git status >output &&
1142 test_i18ncmp expect output &&
1143 git config -f .gitmodules --remove-section submodule.subname
1146 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1147 git config --add -f .gitmodules submodule.subname.ignore none &&
1148 git config --add -f .gitmodules submodule.subname.path sm &&
1149 git config --add submodule.subname.ignore untracked &&
1150 git config --add submodule.subname.path sm &&
1151 git status >output &&
1152 test_i18ncmp expect output &&
1153 git config --remove-section submodule.subname &&
1154 git config -f .gitmodules --remove-section submodule.subname
1157 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1159 cat > expect << EOF
1160 # On branch master
1161 # Changes to be committed:
1162 # (use "git reset HEAD <file>..." to unstage)
1164 # modified: sm
1166 # Changes not staged for commit:
1167 # (use "git add <file>..." to update what will be committed)
1168 # (use "git checkout -- <file>..." to discard changes in working directory)
1170 # modified: dir1/modified
1171 # modified: sm (new commits)
1173 # Submodule changes to be committed:
1175 # * sm $head...$new_head (1):
1176 # > Add bar
1178 # Submodules changed but not updated:
1180 # * sm $new_head...$head2 (1):
1181 # > 2nd commit
1183 # Untracked files:
1184 # (use "git add <file>..." to include in what will be committed)
1186 # .gitmodules
1187 # dir1/untracked
1188 # dir2/modified
1189 # dir2/untracked
1190 # expect
1191 # output
1192 # untracked
1195 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1196 git status --ignore-submodules=untracked > output &&
1197 test_i18ncmp expect output
1200 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1201 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1202 git config --add -f .gitmodules submodule.subname.path sm &&
1203 git status >output &&
1204 test_i18ncmp expect output &&
1205 git config -f .gitmodules --remove-section submodule.subname
1208 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1209 git config --add -f .gitmodules submodule.subname.ignore none &&
1210 git config --add -f .gitmodules submodule.subname.path sm &&
1211 git config --add submodule.subname.ignore untracked &&
1212 git config --add submodule.subname.path sm &&
1213 git status >output &&
1214 test_i18ncmp expect output &&
1215 git config --remove-section submodule.subname &&
1216 git config -f .gitmodules --remove-section submodule.subname
1219 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1220 git status --ignore-submodules=dirty > output &&
1221 test_i18ncmp expect output
1223 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1224 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1225 git config --add -f .gitmodules submodule.subname.path sm &&
1226 git status >output &&
1227 test_i18ncmp expect output &&
1228 git config -f .gitmodules --remove-section submodule.subname
1231 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1232 git config --add -f .gitmodules submodule.subname.ignore none &&
1233 git config --add -f .gitmodules submodule.subname.path sm &&
1234 git config --add submodule.subname.ignore dirty &&
1235 git config --add submodule.subname.path sm &&
1236 git status >output &&
1237 test_i18ncmp expect output &&
1238 git config --remove-section submodule.subname &&
1239 git config -f .gitmodules --remove-section submodule.subname
1242 cat > expect << EOF
1243 # On branch master
1244 # Changes not staged for commit:
1245 # (use "git add <file>..." to update what will be committed)
1246 # (use "git checkout -- <file>..." to discard changes in working directory)
1248 # modified: dir1/modified
1250 # Untracked files:
1251 # (use "git add <file>..." to include in what will be committed)
1253 # .gitmodules
1254 # dir1/untracked
1255 # dir2/modified
1256 # dir2/untracked
1257 # expect
1258 # output
1259 # untracked
1260 no changes added to commit (use "git add" and/or "git commit -a")
1263 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1264 git status --ignore-submodules=all > output &&
1265 test_i18ncmp expect output
1268 test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1269 git config --add -f .gitmodules submodule.subname.ignore all &&
1270 git config --add -f .gitmodules submodule.subname.path sm &&
1271 git status > output &&
1272 test_cmp expect output &&
1273 git config -f .gitmodules --remove-section submodule.subname
1276 test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1277 git config --add -f .gitmodules submodule.subname.ignore none &&
1278 git config --add -f .gitmodules submodule.subname.path sm &&
1279 git config --add submodule.subname.ignore all &&
1280 git config --add submodule.subname.path sm &&
1281 git status > output &&
1282 test_cmp expect output &&
1283 git config --remove-section submodule.subname &&
1284 git config -f .gitmodules --remove-section submodule.subname
1287 test_done