Merge branch 'master' of git://repo.or.cz/alt-git
[git/mingw.git] / t / t7508-status.sh
blob5d1606661c871f4289ccff05c1eed495986e52f3
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='git status'
8 case $(uname -s) in
9 *MINGW*) GIT_TEST_CMP="diff -uw";;
10 esac
12 . ./test-lib.sh
14 test_expect_success 'status -h in broken repository' '
15 git config --global advice.statusuoption false &&
16 mkdir broken &&
17 test_when_finished "rm -fr broken" &&
19 cd broken &&
20 git init &&
21 echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
22 test_expect_code 129 git status -h >usage 2>&1
23 ) &&
24 test_i18ngrep "[Uu]sage" broken/usage
27 test_expect_success 'commit -h in broken repository' '
28 mkdir broken &&
29 test_when_finished "rm -fr broken" &&
31 cd broken &&
32 git init &&
33 echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
34 test_expect_code 129 git commit -h >usage 2>&1
35 ) &&
36 test_i18ngrep "[Uu]sage" broken/usage
39 test_expect_success 'setup' '
40 : >tracked &&
41 : >modified &&
42 mkdir dir1 &&
43 : >dir1/tracked &&
44 : >dir1/modified &&
45 mkdir dir2 &&
46 : >dir1/tracked &&
47 : >dir1/modified &&
48 git add . &&
50 git status >output &&
52 test_tick &&
53 git commit -m initial &&
54 : >untracked &&
55 : >dir1/untracked &&
56 : >dir2/untracked &&
57 echo 1 >dir1/modified &&
58 echo 2 >dir2/modified &&
59 echo 3 >dir2/added &&
60 git add dir2/added
63 test_expect_success 'status (1)' '
64 test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output
67 test_expect_success 'status --column' '
68 COLUMNS=50 git status --column="column dense" >output &&
69 cat >expect <<\EOF &&
70 # On branch master
71 # Changes to be committed:
72 # (use "git reset HEAD <file>..." to unstage)
74 # new file: dir2/added
76 # Changes not staged for commit:
77 # (use "git add <file>..." to update what will be committed)
78 # (use "git checkout -- <file>..." to discard changes in working directory)
80 # modified: dir1/modified
82 # Untracked files:
83 # (use "git add <file>..." to include in what will be committed)
85 # dir1/untracked dir2/untracked untracked
86 # dir2/modified output
87 EOF
88 test_i18ncmp expect output
91 cat >expect <<\EOF
92 # On branch master
93 # Changes to be committed:
94 # (use "git reset HEAD <file>..." to unstage)
96 # new file: dir2/added
98 # Changes not staged for commit:
99 # (use "git add <file>..." to update what will be committed)
100 # (use "git checkout -- <file>..." to discard changes in working directory)
102 # modified: dir1/modified
104 # Untracked files:
105 # (use "git add <file>..." to include in what will be committed)
107 # dir1/untracked
108 # dir2/modified
109 # dir2/untracked
110 # expect
111 # output
112 # untracked
115 test_expect_success 'status (2)' '
116 git status >output &&
117 test_i18ncmp expect output
120 cat >expect <<\EOF
121 # On branch master
122 # Changes to be committed:
123 # new file: dir2/added
125 # Changes not staged for commit:
126 # modified: dir1/modified
128 # Untracked files:
129 # dir1/untracked
130 # dir2/modified
131 # dir2/untracked
132 # expect
133 # output
134 # untracked
137 test_expect_success 'status (advice.statusHints false)' '
138 test_config advice.statusHints false &&
139 git status >output &&
140 test_i18ncmp expect output
144 cat >expect <<\EOF
145 M dir1/modified
146 A dir2/added
147 ?? dir1/untracked
148 ?? dir2/modified
149 ?? dir2/untracked
150 ?? expect
151 ?? output
152 ?? untracked
155 test_expect_success 'status -s' '
157 git status -s >output &&
158 test_cmp expect output
162 test_expect_success 'status with gitignore' '
164 echo ".gitignore" &&
165 echo "expect" &&
166 echo "output" &&
167 echo "untracked"
168 } >.gitignore &&
170 cat >expect <<-\EOF &&
171 M dir1/modified
172 A dir2/added
173 ?? dir2/modified
175 git status -s >output &&
176 test_cmp expect output &&
178 cat >expect <<-\EOF &&
179 M dir1/modified
180 A dir2/added
181 ?? dir2/modified
182 !! .gitignore
183 !! dir1/untracked
184 !! dir2/untracked
185 !! expect
186 !! output
187 !! untracked
189 git status -s --ignored >output &&
190 test_cmp expect output &&
192 cat >expect <<-\EOF &&
193 # On branch master
194 # Changes to be committed:
195 # (use "git reset HEAD <file>..." to unstage)
197 # new file: dir2/added
199 # Changes not staged for commit:
200 # (use "git add <file>..." to update what will be committed)
201 # (use "git checkout -- <file>..." to discard changes in working directory)
203 # modified: dir1/modified
205 # Untracked files:
206 # (use "git add <file>..." to include in what will be committed)
208 # dir2/modified
209 # Ignored files:
210 # (use "git add -f <file>..." to include in what will be committed)
212 # .gitignore
213 # dir1/untracked
214 # dir2/untracked
215 # expect
216 # output
217 # untracked
219 git status --ignored >output &&
220 test_i18ncmp expect output
223 test_expect_success 'status with gitignore (nothing untracked)' '
225 echo ".gitignore" &&
226 echo "expect" &&
227 echo "dir2/modified" &&
228 echo "output" &&
229 echo "untracked"
230 } >.gitignore &&
232 cat >expect <<-\EOF &&
233 M dir1/modified
234 A dir2/added
236 git status -s >output &&
237 test_cmp expect output &&
239 cat >expect <<-\EOF &&
240 M dir1/modified
241 A dir2/added
242 !! .gitignore
243 !! dir1/untracked
244 !! dir2/modified
245 !! dir2/untracked
246 !! expect
247 !! output
248 !! untracked
250 git status -s --ignored >output &&
251 test_cmp expect output &&
253 cat >expect <<-\EOF &&
254 # On branch master
255 # Changes to be committed:
256 # (use "git reset HEAD <file>..." to unstage)
258 # new file: dir2/added
260 # Changes not staged for commit:
261 # (use "git add <file>..." to update what will be committed)
262 # (use "git checkout -- <file>..." to discard changes in working directory)
264 # modified: dir1/modified
266 # Ignored files:
267 # (use "git add -f <file>..." to include in what will be committed)
269 # .gitignore
270 # dir1/untracked
271 # dir2/modified
272 # dir2/untracked
273 # expect
274 # output
275 # untracked
277 git status --ignored >output &&
278 test_i18ncmp expect output
281 rm -f .gitignore
283 cat >expect <<\EOF
284 ## master
285 M dir1/modified
286 A dir2/added
287 ?? dir1/untracked
288 ?? dir2/modified
289 ?? dir2/untracked
290 ?? expect
291 ?? output
292 ?? untracked
295 test_expect_success 'status -s -b' '
297 git status -s -b >output &&
298 test_cmp expect output
302 test_expect_success 'status -s -z -b' '
303 tr "\\n" Q <expect >expect.q &&
304 mv expect.q expect &&
305 git status -s -z -b >output &&
306 nul_to_q <output >output.q &&
307 mv output.q output &&
308 test_cmp expect output
311 test_expect_success 'setup dir3' '
312 mkdir dir3 &&
313 : >dir3/untracked1 &&
314 : >dir3/untracked2
317 cat >expect <<EOF
318 # On branch master
319 # Changes to be committed:
320 # (use "git reset HEAD <file>..." to unstage)
322 # new file: dir2/added
324 # Changes not staged for commit:
325 # (use "git add <file>..." to update what will be committed)
326 # (use "git checkout -- <file>..." to discard changes in working directory)
328 # modified: dir1/modified
330 # Untracked files not listed (use -u option to show untracked files)
332 test_expect_success 'status -uno' '
333 git status -uno >output &&
334 test_i18ncmp expect output
337 test_expect_success 'status (status.showUntrackedFiles no)' '
338 test_config status.showuntrackedfiles no &&
339 git status >output &&
340 test_i18ncmp expect output
343 cat >expect <<EOF
344 # On branch master
345 # Changes to be committed:
346 # new file: dir2/added
348 # Changes not staged for commit:
349 # modified: dir1/modified
351 # Untracked files not listed
353 test_expect_success 'status -uno (advice.statusHints false)' '
354 test_config advice.statusHints false &&
355 git status -uno >output &&
356 test_i18ncmp expect output
359 cat >expect << EOF
360 M dir1/modified
361 A dir2/added
363 test_expect_success 'status -s -uno' '
364 git status -s -uno >output &&
365 test_cmp expect output
368 test_expect_success 'status -s (status.showUntrackedFiles no)' '
369 git config status.showuntrackedfiles no
370 git status -s >output &&
371 test_cmp expect output
374 cat >expect <<EOF
375 # On branch master
376 # Changes to be committed:
377 # (use "git reset HEAD <file>..." to unstage)
379 # new file: dir2/added
381 # Changes not staged for commit:
382 # (use "git add <file>..." to update what will be committed)
383 # (use "git checkout -- <file>..." to discard changes in working directory)
385 # modified: dir1/modified
387 # Untracked files:
388 # (use "git add <file>..." to include in what will be committed)
390 # dir1/untracked
391 # dir2/modified
392 # dir2/untracked
393 # dir3/
394 # expect
395 # output
396 # untracked
398 test_expect_success 'status -unormal' '
399 git status -unormal >output &&
400 test_i18ncmp expect output
403 test_expect_success 'status (status.showUntrackedFiles normal)' '
404 test_config status.showuntrackedfiles normal
405 git status >output &&
406 test_i18ncmp expect output
409 cat >expect <<EOF
410 M dir1/modified
411 A dir2/added
412 ?? dir1/untracked
413 ?? dir2/modified
414 ?? dir2/untracked
415 ?? dir3/
416 ?? expect
417 ?? output
418 ?? untracked
420 test_expect_success 'status -s -unormal' '
421 git status -s -unormal >output &&
422 test_cmp expect output
425 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
426 git config status.showuntrackedfiles normal
427 git status -s >output &&
428 test_cmp expect output
431 cat >expect <<EOF
432 # On branch master
433 # Changes to be committed:
434 # (use "git reset HEAD <file>..." to unstage)
436 # new file: dir2/added
438 # Changes not staged for commit:
439 # (use "git add <file>..." to update what will be committed)
440 # (use "git checkout -- <file>..." to discard changes in working directory)
442 # modified: dir1/modified
444 # Untracked files:
445 # (use "git add <file>..." to include in what will be committed)
447 # dir1/untracked
448 # dir2/modified
449 # dir2/untracked
450 # dir3/untracked1
451 # dir3/untracked2
452 # expect
453 # output
454 # untracked
456 test_expect_success 'status -uall' '
457 git status -uall >output &&
458 test_i18ncmp expect output
461 test_expect_success 'status (status.showUntrackedFiles all)' '
462 test_config status.showuntrackedfiles all
463 git status >output &&
464 test_i18ncmp expect output
467 test_expect_success 'teardown dir3' '
468 rm -rf dir3
471 cat >expect <<EOF
472 M dir1/modified
473 A dir2/added
474 ?? dir1/untracked
475 ?? dir2/modified
476 ?? dir2/untracked
477 ?? expect
478 ?? output
479 ?? untracked
481 test_expect_success 'status -s -uall' '
482 git config --unset status.showuntrackedfiles
483 git status -s -uall >output &&
484 test_cmp expect output
486 test_expect_success 'status -s (status.showUntrackedFiles all)' '
487 test_config status.showuntrackedfiles all &&
488 git status -s >output &&
489 rm -rf dir3 &&
490 test_cmp expect output
493 cat >expect <<\EOF
494 # On branch master
495 # Changes to be committed:
496 # (use "git reset HEAD <file>..." to unstage)
498 # new file: ../dir2/added
500 # Changes not staged for commit:
501 # (use "git add <file>..." to update what will be committed)
502 # (use "git checkout -- <file>..." to discard changes in working directory)
504 # modified: modified
506 # Untracked files:
507 # (use "git add <file>..." to include in what will be committed)
509 # untracked
510 # ../dir2/modified
511 # ../dir2/untracked
512 # ../expect
513 # ../output
514 # ../untracked
517 test_expect_success 'status with relative paths' '
518 (cd dir1 && git status) >output &&
519 test_i18ncmp expect output
522 cat >expect <<\EOF
523 M modified
524 A ../dir2/added
525 ?? untracked
526 ?? ../dir2/modified
527 ?? ../dir2/untracked
528 ?? ../expect
529 ?? ../output
530 ?? ../untracked
532 test_expect_success 'status -s with relative paths' '
534 (cd dir1 && git status -s) >output &&
535 test_cmp expect output
539 cat >expect <<\EOF
540 M dir1/modified
541 A dir2/added
542 ?? dir1/untracked
543 ?? dir2/modified
544 ?? dir2/untracked
545 ?? expect
546 ?? output
547 ?? untracked
550 test_expect_success 'status --porcelain ignores relative paths setting' '
552 (cd dir1 && git status --porcelain) >output &&
553 test_cmp expect output
557 test_expect_success 'setup unique colors' '
559 git config status.color.untracked blue &&
560 git config status.color.branch green
564 cat >expect <<\EOF
565 # On branch <GREEN>master<RESET>
566 # Changes to be committed:
567 # (use "git reset HEAD <file>..." to unstage)
569 # <GREEN>new file: dir2/added<RESET>
571 # Changes not staged for commit:
572 # (use "git add <file>..." to update what will be committed)
573 # (use "git checkout -- <file>..." to discard changes in working directory)
575 # <RED>modified: dir1/modified<RESET>
577 # Untracked files:
578 # (use "git add <file>..." to include in what will be committed)
580 # <BLUE>dir1/untracked<RESET>
581 # <BLUE>dir2/modified<RESET>
582 # <BLUE>dir2/untracked<RESET>
583 # <BLUE>expect<RESET>
584 # <BLUE>output<RESET>
585 # <BLUE>untracked<RESET>
588 test_expect_success 'status with color.ui' '
589 test_config color.ui always &&
590 git status | test_decode_color >output &&
591 test_i18ncmp expect output
594 test_expect_success 'status with color.status' '
595 test_config color.status always &&
596 git status | test_decode_color >output &&
597 test_i18ncmp expect output
600 cat >expect <<\EOF
601 <RED>M<RESET> dir1/modified
602 <GREEN>A<RESET> dir2/added
603 <BLUE>??<RESET> dir1/untracked
604 <BLUE>??<RESET> dir2/modified
605 <BLUE>??<RESET> dir2/untracked
606 <BLUE>??<RESET> expect
607 <BLUE>??<RESET> output
608 <BLUE>??<RESET> untracked
611 test_expect_success 'status -s with color.ui' '
613 git config color.ui always &&
614 git status -s | test_decode_color >output &&
615 test_cmp expect output
619 test_expect_success 'status -s with color.status' '
621 git config --unset color.ui &&
622 git config color.status always &&
623 git status -s | test_decode_color >output &&
624 test_cmp expect output
628 cat >expect <<\EOF
629 ## <GREEN>master<RESET>
630 <RED>M<RESET> dir1/modified
631 <GREEN>A<RESET> dir2/added
632 <BLUE>??<RESET> dir1/untracked
633 <BLUE>??<RESET> dir2/modified
634 <BLUE>??<RESET> dir2/untracked
635 <BLUE>??<RESET> expect
636 <BLUE>??<RESET> output
637 <BLUE>??<RESET> untracked
640 test_expect_success 'status -s -b with color.status' '
642 git status -s -b | test_decode_color >output &&
643 test_cmp expect output
647 cat >expect <<\EOF
648 M dir1/modified
649 A dir2/added
650 ?? dir1/untracked
651 ?? dir2/modified
652 ?? dir2/untracked
653 ?? expect
654 ?? output
655 ?? untracked
658 test_expect_success 'status --porcelain ignores color.ui' '
660 git config --unset color.status &&
661 git config color.ui always &&
662 git status --porcelain | test_decode_color >output &&
663 test_cmp expect output
667 test_expect_success 'status --porcelain ignores color.status' '
669 git config --unset color.ui &&
670 git config color.status always &&
671 git status --porcelain | test_decode_color >output &&
672 test_cmp expect output
676 # recover unconditionally from color tests
677 git config --unset color.status
678 git config --unset color.ui
680 test_expect_success 'status --porcelain respects -b' '
682 git status --porcelain -b >output &&
684 echo "## master" &&
685 cat expect
686 } >tmp &&
687 mv tmp expect &&
688 test_cmp expect output
692 cat >expect <<\EOF
693 # On branch master
694 # Changes to be committed:
695 # (use "git reset HEAD <file>..." to unstage)
697 # new file: dir2/added
699 # Changes not staged for commit:
700 # (use "git add <file>..." to update what will be committed)
701 # (use "git checkout -- <file>..." to discard changes in working directory)
703 # modified: dir1/modified
705 # Untracked files:
706 # (use "git add <file>..." to include in what will be committed)
708 # dir1/untracked
709 # dir2/modified
710 # dir2/untracked
711 # expect
712 # output
713 # untracked
717 test_expect_success 'status without relative paths' '
719 test_config status.relativePaths false &&
720 (cd dir1 && git status) >output &&
721 test_i18ncmp expect output
725 cat >expect <<\EOF
726 M dir1/modified
727 A dir2/added
728 ?? dir1/untracked
729 ?? dir2/modified
730 ?? dir2/untracked
731 ?? expect
732 ?? output
733 ?? untracked
736 test_expect_success 'status -s without relative paths' '
738 test_config status.relativePaths false &&
739 (cd dir1 && git status -s) >output &&
740 test_cmp expect output
744 cat <<EOF >expect
745 # On branch master
746 # Changes to be committed:
747 # (use "git reset HEAD <file>..." to unstage)
749 # modified: dir1/modified
751 # Untracked files:
752 # (use "git add <file>..." to include in what will be committed)
754 # dir1/untracked
755 # dir2/
756 # expect
757 # output
758 # untracked
760 test_expect_success 'dry-run of partial commit excluding new file in index' '
761 git commit --dry-run dir1/modified >output &&
762 test_i18ncmp expect output
765 cat >expect <<EOF
766 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
768 test_expect_success 'status refreshes the index' '
769 touch dir2/added &&
770 git status &&
771 git diff-files >output &&
772 test_cmp expect output
775 test_expect_success 'setup status submodule summary' '
776 test_create_repo sm && (
777 cd sm &&
778 >foo &&
779 git add foo &&
780 git commit -m "Add foo"
781 ) &&
782 git add sm
785 cat >expect <<EOF
786 # On branch master
787 # Changes to be committed:
788 # (use "git reset HEAD <file>..." to unstage)
790 # new file: dir2/added
791 # new file: sm
793 # Changes not staged for commit:
794 # (use "git add <file>..." to update what will be committed)
795 # (use "git checkout -- <file>..." to discard changes in working directory)
797 # modified: dir1/modified
799 # Untracked files:
800 # (use "git add <file>..." to include in what will be committed)
802 # dir1/untracked
803 # dir2/modified
804 # dir2/untracked
805 # expect
806 # output
807 # untracked
809 test_expect_success 'status submodule summary is disabled by default' '
810 git status >output &&
811 test_i18ncmp expect output
814 # we expect the same as the previous test
815 test_expect_success 'status --untracked-files=all does not show submodule' '
816 git status --untracked-files=all >output &&
817 test_i18ncmp expect output
820 cat >expect <<EOF
821 M dir1/modified
822 A dir2/added
823 A sm
824 ?? dir1/untracked
825 ?? dir2/modified
826 ?? dir2/untracked
827 ?? expect
828 ?? output
829 ?? untracked
831 test_expect_success 'status -s submodule summary is disabled by default' '
832 git status -s >output &&
833 test_cmp expect output
836 # we expect the same as the previous test
837 test_expect_success 'status -s --untracked-files=all does not show submodule' '
838 git status -s --untracked-files=all >output &&
839 test_cmp expect output
842 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
844 cat >expect <<EOF
845 # On branch master
846 # Changes to be committed:
847 # (use "git reset HEAD <file>..." to unstage)
849 # new file: dir2/added
850 # new file: sm
852 # Changes not staged for commit:
853 # (use "git add <file>..." to update what will be committed)
854 # (use "git checkout -- <file>..." to discard changes in working directory)
856 # modified: dir1/modified
858 # Submodule changes to be committed:
860 # * sm 0000000...$head (1):
861 # > Add foo
863 # Untracked files:
864 # (use "git add <file>..." to include in what will be committed)
866 # dir1/untracked
867 # dir2/modified
868 # dir2/untracked
869 # expect
870 # output
871 # untracked
873 test_expect_success 'status submodule summary' '
874 git config status.submodulesummary 10 &&
875 git status >output &&
876 test_i18ncmp expect output
879 cat >expect <<EOF
880 M dir1/modified
881 A dir2/added
882 A sm
883 ?? dir1/untracked
884 ?? dir2/modified
885 ?? dir2/untracked
886 ?? expect
887 ?? output
888 ?? untracked
890 test_expect_success 'status -s submodule summary' '
891 git status -s >output &&
892 test_cmp expect output
895 cat >expect <<EOF
896 # On branch master
897 # Changes not staged for commit:
898 # (use "git add <file>..." to update what will be committed)
899 # (use "git checkout -- <file>..." to discard changes in working directory)
901 # modified: dir1/modified
903 # Untracked files:
904 # (use "git add <file>..." to include in what will be committed)
906 # dir1/untracked
907 # dir2/modified
908 # dir2/untracked
909 # expect
910 # output
911 # untracked
912 no changes added to commit (use "git add" and/or "git commit -a")
914 test_expect_success 'status submodule summary (clean submodule): commit' '
915 git commit -m "commit submodule" &&
916 git config status.submodulesummary 10 &&
917 test_must_fail git commit --dry-run >output &&
918 test_i18ncmp expect output &&
919 git status >output &&
920 test_i18ncmp expect output
923 cat >expect <<EOF
924 M dir1/modified
925 ?? dir1/untracked
926 ?? dir2/modified
927 ?? dir2/untracked
928 ?? expect
929 ?? output
930 ?? untracked
932 test_expect_success 'status -s submodule summary (clean submodule)' '
933 git status -s >output &&
934 test_cmp expect output
937 test_expect_success 'status -z implies porcelain' '
938 git status --porcelain |
939 "$PERL_PATH" -pe "s/\012/\000/g" >expect &&
940 git status -z >output &&
941 test_cmp expect output
944 cat >expect <<EOF
945 # On branch master
946 # Changes to be committed:
947 # (use "git reset HEAD^1 <file>..." to unstage)
949 # new file: dir2/added
950 # new file: sm
952 # Changes not staged for commit:
953 # (use "git add <file>..." to update what will be committed)
954 # (use "git checkout -- <file>..." to discard changes in working directory)
956 # modified: dir1/modified
958 # Submodule changes to be committed:
960 # * sm 0000000...$head (1):
961 # > Add foo
963 # Untracked files:
964 # (use "git add <file>..." to include in what will be committed)
966 # dir1/untracked
967 # dir2/modified
968 # dir2/untracked
969 # expect
970 # output
971 # untracked
973 test_expect_success 'commit --dry-run submodule summary (--amend)' '
974 git config status.submodulesummary 10 &&
975 git commit --dry-run --amend >output &&
976 test_i18ncmp expect output
979 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
981 chmod a-w .git &&
982 # make dir1/tracked stat-dirty
983 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
984 git status -s >output &&
985 ! grep dir1/tracked output &&
986 # make sure "status" succeeded without writing index out
987 git diff-files | grep dir1/tracked
989 status=$?
990 chmod 775 .git
991 (exit $status)
994 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
995 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
996 touch .gitmodules
998 cat > expect << EOF
999 # On branch master
1000 # Changes to be committed:
1001 # (use "git reset HEAD <file>..." to unstage)
1003 # modified: sm
1005 # Changes not staged for commit:
1006 # (use "git add <file>..." to update what will be committed)
1007 # (use "git checkout -- <file>..." to discard changes in working directory)
1009 # modified: dir1/modified
1011 # Submodule changes to be committed:
1013 # * sm $head...$new_head (1):
1014 # > Add bar
1016 # Untracked files:
1017 # (use "git add <file>..." to include in what will be committed)
1019 # .gitmodules
1020 # dir1/untracked
1021 # dir2/modified
1022 # dir2/untracked
1023 # expect
1024 # output
1025 # untracked
1028 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1029 echo modified sm/untracked &&
1030 git status --ignore-submodules=untracked >output &&
1031 test_i18ncmp expect output
1034 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1035 test_config diff.ignoreSubmodules dirty &&
1036 git status >output &&
1037 test_i18ncmp expect output &&
1038 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1039 git config --add -f .gitmodules submodule.subname.path sm &&
1040 git status >output &&
1041 test_i18ncmp expect output &&
1042 git config -f .gitmodules --remove-section submodule.subname
1045 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1046 git config --add -f .gitmodules submodule.subname.ignore none &&
1047 git config --add -f .gitmodules submodule.subname.path sm &&
1048 git config --add submodule.subname.ignore untracked &&
1049 git config --add submodule.subname.path sm &&
1050 git status >output &&
1051 test_i18ncmp expect output &&
1052 git config --remove-section submodule.subname &&
1053 git config --remove-section -f .gitmodules submodule.subname
1056 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1057 git status --ignore-submodules=dirty >output &&
1058 test_i18ncmp expect output
1061 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1062 test_config diff.ignoreSubmodules dirty &&
1063 git status >output &&
1064 ! test -s actual &&
1065 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1066 git config --add -f .gitmodules submodule.subname.path sm &&
1067 git status >output &&
1068 test_i18ncmp expect output &&
1069 git config -f .gitmodules --remove-section submodule.subname
1072 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1073 git config --add -f .gitmodules submodule.subname.ignore none &&
1074 git config --add -f .gitmodules submodule.subname.path sm &&
1075 git config --add submodule.subname.ignore dirty &&
1076 git config --add submodule.subname.path sm &&
1077 git status >output &&
1078 test_i18ncmp expect output &&
1079 git config --remove-section submodule.subname &&
1080 git config -f .gitmodules --remove-section submodule.subname
1083 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1084 echo modified >sm/foo &&
1085 git status --ignore-submodules=dirty >output &&
1086 test_i18ncmp expect output
1089 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
1090 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1091 git config --add -f .gitmodules submodule.subname.path sm &&
1092 git status >output &&
1093 test_i18ncmp expect output &&
1094 git config -f .gitmodules --remove-section submodule.subname
1097 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
1098 git config --add -f .gitmodules submodule.subname.ignore none &&
1099 git config --add -f .gitmodules submodule.subname.path sm &&
1100 git config --add submodule.subname.ignore dirty &&
1101 git config --add submodule.subname.path sm &&
1102 git status >output &&
1103 test_i18ncmp expect output &&
1104 git config --remove-section submodule.subname &&
1105 git config -f .gitmodules --remove-section submodule.subname
1108 cat > expect << EOF
1109 # On branch master
1110 # Changes to be committed:
1111 # (use "git reset HEAD <file>..." to unstage)
1113 # modified: sm
1115 # Changes not staged for commit:
1116 # (use "git add <file>..." to update what will be committed)
1117 # (use "git checkout -- <file>..." to discard changes in working directory)
1118 # (commit or discard the untracked or modified content in submodules)
1120 # modified: dir1/modified
1121 # modified: sm (modified content)
1123 # Submodule changes to be committed:
1125 # * sm $head...$new_head (1):
1126 # > Add bar
1128 # Untracked files:
1129 # (use "git add <file>..." to include in what will be committed)
1131 # .gitmodules
1132 # dir1/untracked
1133 # dir2/modified
1134 # dir2/untracked
1135 # expect
1136 # output
1137 # untracked
1140 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1141 git status --ignore-submodules=untracked > output &&
1142 test_i18ncmp expect output
1145 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
1146 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1147 git config --add -f .gitmodules submodule.subname.path sm &&
1148 git status >output &&
1149 test_i18ncmp expect output &&
1150 git config -f .gitmodules --remove-section submodule.subname
1153 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1154 git config --add -f .gitmodules submodule.subname.ignore none &&
1155 git config --add -f .gitmodules submodule.subname.path sm &&
1156 git config --add submodule.subname.ignore untracked &&
1157 git config --add submodule.subname.path sm &&
1158 git status >output &&
1159 test_i18ncmp expect output &&
1160 git config --remove-section submodule.subname &&
1161 git config -f .gitmodules --remove-section submodule.subname
1164 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1166 cat > expect << EOF
1167 # On branch master
1168 # Changes to be committed:
1169 # (use "git reset HEAD <file>..." to unstage)
1171 # modified: sm
1173 # Changes not staged for commit:
1174 # (use "git add <file>..." to update what will be committed)
1175 # (use "git checkout -- <file>..." to discard changes in working directory)
1177 # modified: dir1/modified
1178 # modified: sm (new commits)
1180 # Submodule changes to be committed:
1182 # * sm $head...$new_head (1):
1183 # > Add bar
1185 # Submodules changed but not updated:
1187 # * sm $new_head...$head2 (1):
1188 # > 2nd commit
1190 # Untracked files:
1191 # (use "git add <file>..." to include in what will be committed)
1193 # .gitmodules
1194 # dir1/untracked
1195 # dir2/modified
1196 # dir2/untracked
1197 # expect
1198 # output
1199 # untracked
1202 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1203 git status --ignore-submodules=untracked > output &&
1204 test_i18ncmp expect output
1207 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1208 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1209 git config --add -f .gitmodules submodule.subname.path sm &&
1210 git status >output &&
1211 test_i18ncmp expect output &&
1212 git config -f .gitmodules --remove-section submodule.subname
1215 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1216 git config --add -f .gitmodules submodule.subname.ignore none &&
1217 git config --add -f .gitmodules submodule.subname.path sm &&
1218 git config --add submodule.subname.ignore untracked &&
1219 git config --add submodule.subname.path sm &&
1220 git status >output &&
1221 test_i18ncmp expect output &&
1222 git config --remove-section submodule.subname &&
1223 git config -f .gitmodules --remove-section submodule.subname
1226 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1227 git status --ignore-submodules=dirty > output &&
1228 test_i18ncmp expect output
1230 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1231 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1232 git config --add -f .gitmodules submodule.subname.path sm &&
1233 git status >output &&
1234 test_i18ncmp expect output &&
1235 git config -f .gitmodules --remove-section submodule.subname
1238 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1239 git config --add -f .gitmodules submodule.subname.ignore none &&
1240 git config --add -f .gitmodules submodule.subname.path sm &&
1241 git config --add submodule.subname.ignore dirty &&
1242 git config --add submodule.subname.path sm &&
1243 git status >output &&
1244 test_i18ncmp expect output &&
1245 git config --remove-section submodule.subname &&
1246 git config -f .gitmodules --remove-section submodule.subname
1249 cat > expect << EOF
1250 ; On branch master
1251 ; Changes to be committed:
1252 ; (use "git reset HEAD <file>..." to unstage)
1254 ; modified: sm
1256 ; Changes not staged for commit:
1257 ; (use "git add <file>..." to update what will be committed)
1258 ; (use "git checkout -- <file>..." to discard changes in working directory)
1260 ; modified: dir1/modified
1261 ; modified: sm (new commits)
1263 ; Submodule changes to be committed:
1265 ; * sm $head...$new_head (1):
1266 ; > Add bar
1268 ; Submodules changed but not updated:
1270 ; * sm $new_head...$head2 (1):
1271 ; > 2nd commit
1273 ; Untracked files:
1274 ; (use "git add <file>..." to include in what will be committed)
1276 ; .gitmodules
1277 ; dir1/untracked
1278 ; dir2/modified
1279 ; dir2/untracked
1280 ; expect
1281 ; output
1282 ; untracked
1285 test_expect_success "status (core.commentchar with submodule summary)" '
1286 test_config core.commentchar ";" &&
1287 git status >output &&
1288 test_i18ncmp expect output
1291 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1292 test_config core.commentchar ";;" &&
1293 git status >output &&
1294 test_i18ncmp expect output
1297 cat > expect << EOF
1298 # On branch master
1299 # Changes not staged for commit:
1300 # (use "git add <file>..." to update what will be committed)
1301 # (use "git checkout -- <file>..." to discard changes in working directory)
1303 # modified: dir1/modified
1305 # Untracked files:
1306 # (use "git add <file>..." to include in what will be committed)
1308 # .gitmodules
1309 # dir1/untracked
1310 # dir2/modified
1311 # dir2/untracked
1312 # expect
1313 # output
1314 # untracked
1315 no changes added to commit (use "git add" and/or "git commit -a")
1318 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1319 git status --ignore-submodules=all > output &&
1320 test_i18ncmp expect output
1323 test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1324 git config --add -f .gitmodules submodule.subname.ignore all &&
1325 git config --add -f .gitmodules submodule.subname.path sm &&
1326 git status > output &&
1327 test_cmp expect output &&
1328 git config -f .gitmodules --remove-section submodule.subname
1331 test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1332 git config --add -f .gitmodules submodule.subname.ignore none &&
1333 git config --add -f .gitmodules submodule.subname.path sm &&
1334 git config --add submodule.subname.ignore all &&
1335 git config --add submodule.subname.path sm &&
1336 git status > output &&
1337 test_cmp expect output &&
1338 git config --remove-section submodule.subname &&
1339 git config -f .gitmodules --remove-section submodule.subname
1342 test_done