t7508: use test_config to set/unset git config variables
[git/mingw.git] / t / t7508-status.sh
blob55ecd260863d239750bc55f288befe7ec25d242b
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_i18ncmp 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_config advice.statusHints false &&
134 git status >output &&
135 test_i18ncmp expect output
139 cat >expect <<\EOF
140 M dir1/modified
141 A dir2/added
142 ?? dir1/untracked
143 ?? dir2/modified
144 ?? dir2/untracked
145 ?? expect
146 ?? output
147 ?? untracked
150 test_expect_success 'status -s' '
152 git status -s >output &&
153 test_cmp expect output
157 test_expect_success 'status with gitignore' '
159 echo ".gitignore" &&
160 echo "expect" &&
161 echo "output" &&
162 echo "untracked"
163 } >.gitignore &&
165 cat >expect <<-\EOF &&
166 M dir1/modified
167 A dir2/added
168 ?? dir2/modified
170 git status -s >output &&
171 test_cmp expect output &&
173 cat >expect <<-\EOF &&
174 M dir1/modified
175 A dir2/added
176 ?? dir2/modified
177 !! .gitignore
178 !! dir1/untracked
179 !! dir2/untracked
180 !! expect
181 !! output
182 !! untracked
184 git status -s --ignored >output &&
185 test_cmp expect output &&
187 cat >expect <<-\EOF &&
188 # On branch master
189 # Changes to be committed:
190 # (use "git reset HEAD <file>..." to unstage)
192 # new file: dir2/added
194 # Changes not staged for commit:
195 # (use "git add <file>..." to update what will be committed)
196 # (use "git checkout -- <file>..." to discard changes in working directory)
198 # modified: dir1/modified
200 # Untracked files:
201 # (use "git add <file>..." to include in what will be committed)
203 # dir2/modified
204 # Ignored files:
205 # (use "git add -f <file>..." to include in what will be committed)
207 # .gitignore
208 # dir1/untracked
209 # dir2/untracked
210 # expect
211 # output
212 # untracked
214 git status --ignored >output &&
215 test_i18ncmp expect output
218 test_expect_success 'status with gitignore (nothing untracked)' '
220 echo ".gitignore" &&
221 echo "expect" &&
222 echo "dir2/modified" &&
223 echo "output" &&
224 echo "untracked"
225 } >.gitignore &&
227 cat >expect <<-\EOF &&
228 M dir1/modified
229 A dir2/added
231 git status -s >output &&
232 test_cmp expect output &&
234 cat >expect <<-\EOF &&
235 M dir1/modified
236 A dir2/added
237 !! .gitignore
238 !! dir1/untracked
239 !! dir2/modified
240 !! dir2/untracked
241 !! expect
242 !! output
243 !! untracked
245 git status -s --ignored >output &&
246 test_cmp expect output &&
248 cat >expect <<-\EOF &&
249 # On branch master
250 # Changes to be committed:
251 # (use "git reset HEAD <file>..." to unstage)
253 # new file: dir2/added
255 # Changes not staged for commit:
256 # (use "git add <file>..." to update what will be committed)
257 # (use "git checkout -- <file>..." to discard changes in working directory)
259 # modified: dir1/modified
261 # Ignored files:
262 # (use "git add -f <file>..." to include in what will be committed)
264 # .gitignore
265 # dir1/untracked
266 # dir2/modified
267 # dir2/untracked
268 # expect
269 # output
270 # untracked
272 git status --ignored >output &&
273 test_i18ncmp expect output
276 rm -f .gitignore
278 cat >expect <<\EOF
279 ## master
280 M dir1/modified
281 A dir2/added
282 ?? dir1/untracked
283 ?? dir2/modified
284 ?? dir2/untracked
285 ?? expect
286 ?? output
287 ?? untracked
290 test_expect_success 'status -s -b' '
292 git status -s -b >output &&
293 test_cmp expect output
297 test_expect_success 'status -s -z -b' '
298 tr "\\n" Q <expect >expect.q &&
299 mv expect.q expect &&
300 git status -s -z -b >output &&
301 nul_to_q <output >output.q &&
302 mv output.q output &&
303 test_cmp expect output
306 test_expect_success 'setup dir3' '
307 mkdir dir3 &&
308 : >dir3/untracked1 &&
309 : >dir3/untracked2
312 cat >expect <<EOF
313 # On branch master
314 # Changes to be committed:
315 # (use "git reset HEAD <file>..." to unstage)
317 # new file: dir2/added
319 # Changes not staged for commit:
320 # (use "git add <file>..." to update what will be committed)
321 # (use "git checkout -- <file>..." to discard changes in working directory)
323 # modified: dir1/modified
325 # Untracked files not listed (use -u option to show untracked files)
327 test_expect_success 'status -uno' '
328 git status -uno >output &&
329 test_i18ncmp expect output
332 test_expect_success 'status (status.showUntrackedFiles no)' '
333 test_config status.showuntrackedfiles no &&
334 git status >output &&
335 test_i18ncmp expect output
338 cat >expect <<EOF
339 # On branch master
340 # Changes to be committed:
341 # new file: dir2/added
343 # Changes not staged for commit:
344 # modified: dir1/modified
346 # Untracked files not listed
348 test_expect_success 'status -uno (advice.statusHints false)' '
349 test_config advice.statusHints false &&
350 git status -uno >output &&
351 test_i18ncmp expect output
354 cat >expect << EOF
355 M dir1/modified
356 A dir2/added
358 test_expect_success 'status -s -uno' '
359 git status -s -uno >output &&
360 test_cmp expect output
363 test_expect_success 'status -s (status.showUntrackedFiles no)' '
364 git config status.showuntrackedfiles no
365 git status -s >output &&
366 test_cmp expect output
369 cat >expect <<EOF
370 # On branch master
371 # Changes to be committed:
372 # (use "git reset HEAD <file>..." to unstage)
374 # new file: dir2/added
376 # Changes not staged for commit:
377 # (use "git add <file>..." to update what will be committed)
378 # (use "git checkout -- <file>..." to discard changes in working directory)
380 # modified: dir1/modified
382 # Untracked files:
383 # (use "git add <file>..." to include in what will be committed)
385 # dir1/untracked
386 # dir2/modified
387 # dir2/untracked
388 # dir3/
389 # expect
390 # output
391 # untracked
393 test_expect_success 'status -unormal' '
394 git status -unormal >output &&
395 test_i18ncmp expect output
398 test_expect_success 'status (status.showUntrackedFiles normal)' '
399 test_config status.showuntrackedfiles normal
400 git status >output &&
401 test_i18ncmp expect output
404 cat >expect <<EOF
405 M dir1/modified
406 A dir2/added
407 ?? dir1/untracked
408 ?? dir2/modified
409 ?? dir2/untracked
410 ?? dir3/
411 ?? expect
412 ?? output
413 ?? untracked
415 test_expect_success 'status -s -unormal' '
416 git status -s -unormal >output &&
417 test_cmp expect output
420 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
421 git config status.showuntrackedfiles normal
422 git status -s >output &&
423 test_cmp expect output
426 cat >expect <<EOF
427 # On branch master
428 # Changes to be committed:
429 # (use "git reset HEAD <file>..." to unstage)
431 # new file: dir2/added
433 # Changes not staged for commit:
434 # (use "git add <file>..." to update what will be committed)
435 # (use "git checkout -- <file>..." to discard changes in working directory)
437 # modified: dir1/modified
439 # Untracked files:
440 # (use "git add <file>..." to include in what will be committed)
442 # dir1/untracked
443 # dir2/modified
444 # dir2/untracked
445 # dir3/untracked1
446 # dir3/untracked2
447 # expect
448 # output
449 # untracked
451 test_expect_success 'status -uall' '
452 git status -uall >output &&
453 test_i18ncmp expect output
456 test_expect_success 'status (status.showUntrackedFiles all)' '
457 test_config status.showuntrackedfiles all
458 git status >output &&
459 test_i18ncmp expect output
462 test_expect_success 'teardown dir3' '
463 rm -rf dir3
466 cat >expect <<EOF
467 M dir1/modified
468 A dir2/added
469 ?? dir1/untracked
470 ?? dir2/modified
471 ?? dir2/untracked
472 ?? expect
473 ?? output
474 ?? untracked
476 test_expect_success 'status -s -uall' '
477 git config --unset status.showuntrackedfiles
478 git status -s -uall >output &&
479 test_cmp expect output
481 test_expect_success 'status -s (status.showUntrackedFiles all)' '
482 test_config status.showuntrackedfiles all &&
483 git status -s >output &&
484 rm -rf dir3 &&
485 test_cmp expect output
488 cat >expect <<\EOF
489 # On branch master
490 # Changes to be committed:
491 # (use "git reset HEAD <file>..." to unstage)
493 # new file: ../dir2/added
495 # Changes not staged for commit:
496 # (use "git add <file>..." to update what will be committed)
497 # (use "git checkout -- <file>..." to discard changes in working directory)
499 # modified: modified
501 # Untracked files:
502 # (use "git add <file>..." to include in what will be committed)
504 # untracked
505 # ../dir2/modified
506 # ../dir2/untracked
507 # ../expect
508 # ../output
509 # ../untracked
512 test_expect_success 'status with relative paths' '
513 (cd dir1 && git status) >output &&
514 test_i18ncmp expect output
517 cat >expect <<\EOF
518 M modified
519 A ../dir2/added
520 ?? untracked
521 ?? ../dir2/modified
522 ?? ../dir2/untracked
523 ?? ../expect
524 ?? ../output
525 ?? ../untracked
527 test_expect_success 'status -s with relative paths' '
529 (cd dir1 && git status -s) >output &&
530 test_cmp expect output
534 cat >expect <<\EOF
535 M dir1/modified
536 A dir2/added
537 ?? dir1/untracked
538 ?? dir2/modified
539 ?? dir2/untracked
540 ?? expect
541 ?? output
542 ?? untracked
545 test_expect_success 'status --porcelain ignores relative paths setting' '
547 (cd dir1 && git status --porcelain) >output &&
548 test_cmp expect output
552 test_expect_success 'setup unique colors' '
554 git config status.color.untracked blue &&
555 git config status.color.branch green
559 cat >expect <<\EOF
560 # On branch <GREEN>master<RESET>
561 # Changes to be committed:
562 # (use "git reset HEAD <file>..." to unstage)
564 # <GREEN>new file: dir2/added<RESET>
566 # Changes not staged for commit:
567 # (use "git add <file>..." to update what will be committed)
568 # (use "git checkout -- <file>..." to discard changes in working directory)
570 # <RED>modified: dir1/modified<RESET>
572 # Untracked files:
573 # (use "git add <file>..." to include in what will be committed)
575 # <BLUE>dir1/untracked<RESET>
576 # <BLUE>dir2/modified<RESET>
577 # <BLUE>dir2/untracked<RESET>
578 # <BLUE>expect<RESET>
579 # <BLUE>output<RESET>
580 # <BLUE>untracked<RESET>
583 test_expect_success 'status with color.ui' '
584 test_config color.ui always &&
585 git status | test_decode_color >output &&
586 test_i18ncmp expect output
589 test_expect_success 'status with color.status' '
590 test_config color.status always &&
591 git status | test_decode_color >output &&
592 test_i18ncmp expect output
595 cat >expect <<\EOF
596 <RED>M<RESET> dir1/modified
597 <GREEN>A<RESET> dir2/added
598 <BLUE>??<RESET> dir1/untracked
599 <BLUE>??<RESET> dir2/modified
600 <BLUE>??<RESET> dir2/untracked
601 <BLUE>??<RESET> expect
602 <BLUE>??<RESET> output
603 <BLUE>??<RESET> untracked
606 test_expect_success 'status -s with color.ui' '
608 git config color.ui always &&
609 git status -s | test_decode_color >output &&
610 test_cmp expect output
614 test_expect_success 'status -s with color.status' '
616 git config --unset color.ui &&
617 git config color.status always &&
618 git status -s | test_decode_color >output &&
619 test_cmp expect output
623 cat >expect <<\EOF
624 ## <GREEN>master<RESET>
625 <RED>M<RESET> dir1/modified
626 <GREEN>A<RESET> dir2/added
627 <BLUE>??<RESET> dir1/untracked
628 <BLUE>??<RESET> dir2/modified
629 <BLUE>??<RESET> dir2/untracked
630 <BLUE>??<RESET> expect
631 <BLUE>??<RESET> output
632 <BLUE>??<RESET> untracked
635 test_expect_success 'status -s -b with color.status' '
637 git status -s -b | test_decode_color >output &&
638 test_cmp expect output
642 cat >expect <<\EOF
643 M dir1/modified
644 A dir2/added
645 ?? dir1/untracked
646 ?? dir2/modified
647 ?? dir2/untracked
648 ?? expect
649 ?? output
650 ?? untracked
653 test_expect_success 'status --porcelain ignores color.ui' '
655 git config --unset color.status &&
656 git config color.ui always &&
657 git status --porcelain | test_decode_color >output &&
658 test_cmp expect output
662 test_expect_success 'status --porcelain ignores color.status' '
664 git config --unset color.ui &&
665 git config color.status always &&
666 git status --porcelain | test_decode_color >output &&
667 test_cmp expect output
671 # recover unconditionally from color tests
672 git config --unset color.status
673 git config --unset color.ui
675 test_expect_success 'status --porcelain respects -b' '
677 git status --porcelain -b >output &&
679 echo "## master" &&
680 cat expect
681 } >tmp &&
682 mv tmp expect &&
683 test_cmp expect output
687 cat >expect <<\EOF
688 # On branch master
689 # Changes to be committed:
690 # (use "git reset HEAD <file>..." to unstage)
692 # new file: dir2/added
694 # Changes not staged for commit:
695 # (use "git add <file>..." to update what will be committed)
696 # (use "git checkout -- <file>..." to discard changes in working directory)
698 # modified: dir1/modified
700 # Untracked files:
701 # (use "git add <file>..." to include in what will be committed)
703 # dir1/untracked
704 # dir2/modified
705 # dir2/untracked
706 # expect
707 # output
708 # untracked
712 test_expect_success 'status without relative paths' '
714 test_config status.relativePaths false &&
715 (cd dir1 && git status) >output &&
716 test_i18ncmp expect output
720 cat >expect <<\EOF
721 M dir1/modified
722 A dir2/added
723 ?? dir1/untracked
724 ?? dir2/modified
725 ?? dir2/untracked
726 ?? expect
727 ?? output
728 ?? untracked
731 test_expect_success 'status -s without relative paths' '
733 test_config status.relativePaths false &&
734 (cd dir1 && git status -s) >output &&
735 test_cmp expect output
739 cat <<EOF >expect
740 # On branch master
741 # Changes to be committed:
742 # (use "git reset HEAD <file>..." to unstage)
744 # modified: dir1/modified
746 # Untracked files:
747 # (use "git add <file>..." to include in what will be committed)
749 # dir1/untracked
750 # dir2/
751 # expect
752 # output
753 # untracked
755 test_expect_success 'dry-run of partial commit excluding new file in index' '
756 git commit --dry-run dir1/modified >output &&
757 test_i18ncmp expect output
760 cat >expect <<EOF
761 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
763 test_expect_success 'status refreshes the index' '
764 touch dir2/added &&
765 git status &&
766 git diff-files >output &&
767 test_cmp expect output
770 test_expect_success 'setup status submodule summary' '
771 test_create_repo sm && (
772 cd sm &&
773 >foo &&
774 git add foo &&
775 git commit -m "Add foo"
776 ) &&
777 git add sm
780 cat >expect <<EOF
781 # On branch master
782 # Changes to be committed:
783 # (use "git reset HEAD <file>..." to unstage)
785 # new file: dir2/added
786 # new file: sm
788 # Changes not staged for commit:
789 # (use "git add <file>..." to update what will be committed)
790 # (use "git checkout -- <file>..." to discard changes in working directory)
792 # modified: dir1/modified
794 # Untracked files:
795 # (use "git add <file>..." to include in what will be committed)
797 # dir1/untracked
798 # dir2/modified
799 # dir2/untracked
800 # expect
801 # output
802 # untracked
804 test_expect_success 'status submodule summary is disabled by default' '
805 git status >output &&
806 test_i18ncmp expect output
809 # we expect the same as the previous test
810 test_expect_success 'status --untracked-files=all does not show submodule' '
811 git status --untracked-files=all >output &&
812 test_i18ncmp expect output
815 cat >expect <<EOF
816 M dir1/modified
817 A dir2/added
818 A sm
819 ?? dir1/untracked
820 ?? dir2/modified
821 ?? dir2/untracked
822 ?? expect
823 ?? output
824 ?? untracked
826 test_expect_success 'status -s submodule summary is disabled by default' '
827 git status -s >output &&
828 test_cmp expect output
831 # we expect the same as the previous test
832 test_expect_success 'status -s --untracked-files=all does not show submodule' '
833 git status -s --untracked-files=all >output &&
834 test_cmp expect output
837 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
839 cat >expect <<EOF
840 # On branch master
841 # Changes to be committed:
842 # (use "git reset HEAD <file>..." to unstage)
844 # new file: dir2/added
845 # new file: sm
847 # Changes not staged for commit:
848 # (use "git add <file>..." to update what will be committed)
849 # (use "git checkout -- <file>..." to discard changes in working directory)
851 # modified: dir1/modified
853 # Submodule changes to be committed:
855 # * sm 0000000...$head (1):
856 # > Add foo
858 # Untracked files:
859 # (use "git add <file>..." to include in what will be committed)
861 # dir1/untracked
862 # dir2/modified
863 # dir2/untracked
864 # expect
865 # output
866 # untracked
868 test_expect_success 'status submodule summary' '
869 git config status.submodulesummary 10 &&
870 git status >output &&
871 test_i18ncmp expect output
874 cat >expect <<EOF
875 M dir1/modified
876 A dir2/added
877 A sm
878 ?? dir1/untracked
879 ?? dir2/modified
880 ?? dir2/untracked
881 ?? expect
882 ?? output
883 ?? untracked
885 test_expect_success 'status -s submodule summary' '
886 git status -s >output &&
887 test_cmp expect output
890 cat >expect <<EOF
891 # On branch master
892 # Changes not staged for commit:
893 # (use "git add <file>..." to update what will be committed)
894 # (use "git checkout -- <file>..." to discard changes in working directory)
896 # modified: dir1/modified
898 # Untracked files:
899 # (use "git add <file>..." to include in what will be committed)
901 # dir1/untracked
902 # dir2/modified
903 # dir2/untracked
904 # expect
905 # output
906 # untracked
907 no changes added to commit (use "git add" and/or "git commit -a")
909 test_expect_success 'status submodule summary (clean submodule): commit' '
910 git commit -m "commit submodule" &&
911 git config status.submodulesummary 10 &&
912 test_must_fail git commit --dry-run >output &&
913 test_i18ncmp expect output &&
914 git status >output &&
915 test_i18ncmp expect output
918 cat >expect <<EOF
919 M dir1/modified
920 ?? dir1/untracked
921 ?? dir2/modified
922 ?? dir2/untracked
923 ?? expect
924 ?? output
925 ?? untracked
927 test_expect_success 'status -s submodule summary (clean submodule)' '
928 git status -s >output &&
929 test_cmp expect output
932 test_expect_success 'status -z implies porcelain' '
933 git status --porcelain |
934 "$PERL_PATH" -pe "s/\012/\000/g" >expect &&
935 git status -z >output &&
936 test_cmp expect output
939 cat >expect <<EOF
940 # On branch master
941 # Changes to be committed:
942 # (use "git reset HEAD^1 <file>..." to unstage)
944 # new file: dir2/added
945 # new file: sm
947 # Changes not staged for commit:
948 # (use "git add <file>..." to update what will be committed)
949 # (use "git checkout -- <file>..." to discard changes in working directory)
951 # modified: dir1/modified
953 # Submodule changes to be committed:
955 # * sm 0000000...$head (1):
956 # > Add foo
958 # Untracked files:
959 # (use "git add <file>..." to include in what will be committed)
961 # dir1/untracked
962 # dir2/modified
963 # dir2/untracked
964 # expect
965 # output
966 # untracked
968 test_expect_success 'commit --dry-run submodule summary (--amend)' '
969 git config status.submodulesummary 10 &&
970 git commit --dry-run --amend >output &&
971 test_i18ncmp expect output
974 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
976 chmod a-w .git &&
977 # make dir1/tracked stat-dirty
978 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
979 git status -s >output &&
980 ! grep dir1/tracked output &&
981 # make sure "status" succeeded without writing index out
982 git diff-files | grep dir1/tracked
984 status=$?
985 chmod 775 .git
986 (exit $status)
989 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
990 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
991 touch .gitmodules
993 cat > expect << EOF
994 # On branch master
995 # Changes to be committed:
996 # (use "git reset HEAD <file>..." to unstage)
998 # modified: sm
1000 # Changes not staged for commit:
1001 # (use "git add <file>..." to update what will be committed)
1002 # (use "git checkout -- <file>..." to discard changes in working directory)
1004 # modified: dir1/modified
1006 # Submodule changes to be committed:
1008 # * sm $head...$new_head (1):
1009 # > Add bar
1011 # Untracked files:
1012 # (use "git add <file>..." to include in what will be committed)
1014 # .gitmodules
1015 # dir1/untracked
1016 # dir2/modified
1017 # dir2/untracked
1018 # expect
1019 # output
1020 # untracked
1023 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1024 echo modified sm/untracked &&
1025 git status --ignore-submodules=untracked >output &&
1026 test_i18ncmp expect output
1029 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1030 test_config diff.ignoreSubmodules dirty &&
1031 git status >output &&
1032 test_i18ncmp expect output &&
1033 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1034 git config --add -f .gitmodules submodule.subname.path sm &&
1035 git status >output &&
1036 test_i18ncmp expect output &&
1037 git config -f .gitmodules --remove-section submodule.subname
1040 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1041 git config --add -f .gitmodules submodule.subname.ignore none &&
1042 git config --add -f .gitmodules submodule.subname.path sm &&
1043 git config --add submodule.subname.ignore untracked &&
1044 git config --add submodule.subname.path sm &&
1045 git status >output &&
1046 test_i18ncmp expect output &&
1047 git config --remove-section submodule.subname &&
1048 git config --remove-section -f .gitmodules submodule.subname
1051 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1052 git status --ignore-submodules=dirty >output &&
1053 test_i18ncmp expect output
1056 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1057 test_config diff.ignoreSubmodules dirty &&
1058 git status >output &&
1059 ! test -s actual &&
1060 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1061 git config --add -f .gitmodules submodule.subname.path sm &&
1062 git status >output &&
1063 test_i18ncmp expect output &&
1064 git config -f .gitmodules --remove-section submodule.subname
1067 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1068 git config --add -f .gitmodules submodule.subname.ignore none &&
1069 git config --add -f .gitmodules submodule.subname.path sm &&
1070 git config --add submodule.subname.ignore dirty &&
1071 git config --add submodule.subname.path sm &&
1072 git status >output &&
1073 test_i18ncmp expect output &&
1074 git config --remove-section submodule.subname &&
1075 git config -f .gitmodules --remove-section submodule.subname
1078 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1079 echo modified >sm/foo &&
1080 git status --ignore-submodules=dirty >output &&
1081 test_i18ncmp expect output
1084 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
1085 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1086 git config --add -f .gitmodules submodule.subname.path sm &&
1087 git status >output &&
1088 test_i18ncmp expect output &&
1089 git config -f .gitmodules --remove-section submodule.subname
1092 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
1093 git config --add -f .gitmodules submodule.subname.ignore none &&
1094 git config --add -f .gitmodules submodule.subname.path sm &&
1095 git config --add submodule.subname.ignore dirty &&
1096 git config --add submodule.subname.path sm &&
1097 git status >output &&
1098 test_i18ncmp expect output &&
1099 git config --remove-section submodule.subname &&
1100 git config -f .gitmodules --remove-section submodule.subname
1103 cat > expect << EOF
1104 # On branch master
1105 # Changes to be committed:
1106 # (use "git reset HEAD <file>..." to unstage)
1108 # modified: sm
1110 # Changes not staged for commit:
1111 # (use "git add <file>..." to update what will be committed)
1112 # (use "git checkout -- <file>..." to discard changes in working directory)
1113 # (commit or discard the untracked or modified content in submodules)
1115 # modified: dir1/modified
1116 # modified: sm (modified content)
1118 # Submodule changes to be committed:
1120 # * sm $head...$new_head (1):
1121 # > Add bar
1123 # Untracked files:
1124 # (use "git add <file>..." to include in what will be committed)
1126 # .gitmodules
1127 # dir1/untracked
1128 # dir2/modified
1129 # dir2/untracked
1130 # expect
1131 # output
1132 # untracked
1135 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1136 git status --ignore-submodules=untracked > output &&
1137 test_i18ncmp expect output
1140 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
1141 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1142 git config --add -f .gitmodules submodule.subname.path sm &&
1143 git status >output &&
1144 test_i18ncmp expect output &&
1145 git config -f .gitmodules --remove-section submodule.subname
1148 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1149 git config --add -f .gitmodules submodule.subname.ignore none &&
1150 git config --add -f .gitmodules submodule.subname.path sm &&
1151 git config --add submodule.subname.ignore untracked &&
1152 git config --add submodule.subname.path sm &&
1153 git status >output &&
1154 test_i18ncmp expect output &&
1155 git config --remove-section submodule.subname &&
1156 git config -f .gitmodules --remove-section submodule.subname
1159 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1161 cat > expect << EOF
1162 # On branch master
1163 # Changes to be committed:
1164 # (use "git reset HEAD <file>..." to unstage)
1166 # modified: sm
1168 # Changes not staged for commit:
1169 # (use "git add <file>..." to update what will be committed)
1170 # (use "git checkout -- <file>..." to discard changes in working directory)
1172 # modified: dir1/modified
1173 # modified: sm (new commits)
1175 # Submodule changes to be committed:
1177 # * sm $head...$new_head (1):
1178 # > Add bar
1180 # Submodules changed but not updated:
1182 # * sm $new_head...$head2 (1):
1183 # > 2nd commit
1185 # Untracked files:
1186 # (use "git add <file>..." to include in what will be committed)
1188 # .gitmodules
1189 # dir1/untracked
1190 # dir2/modified
1191 # dir2/untracked
1192 # expect
1193 # output
1194 # untracked
1197 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1198 git status --ignore-submodules=untracked > output &&
1199 test_i18ncmp expect output
1202 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1203 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1204 git config --add -f .gitmodules submodule.subname.path sm &&
1205 git status >output &&
1206 test_i18ncmp expect output &&
1207 git config -f .gitmodules --remove-section submodule.subname
1210 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1211 git config --add -f .gitmodules submodule.subname.ignore none &&
1212 git config --add -f .gitmodules submodule.subname.path sm &&
1213 git config --add submodule.subname.ignore untracked &&
1214 git config --add submodule.subname.path sm &&
1215 git status >output &&
1216 test_i18ncmp expect output &&
1217 git config --remove-section submodule.subname &&
1218 git config -f .gitmodules --remove-section submodule.subname
1221 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1222 git status --ignore-submodules=dirty > output &&
1223 test_i18ncmp expect output
1225 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1226 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1227 git config --add -f .gitmodules submodule.subname.path sm &&
1228 git status >output &&
1229 test_i18ncmp expect output &&
1230 git config -f .gitmodules --remove-section submodule.subname
1233 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1234 git config --add -f .gitmodules submodule.subname.ignore none &&
1235 git config --add -f .gitmodules submodule.subname.path sm &&
1236 git config --add submodule.subname.ignore dirty &&
1237 git config --add submodule.subname.path sm &&
1238 git status >output &&
1239 test_i18ncmp expect output &&
1240 git config --remove-section submodule.subname &&
1241 git config -f .gitmodules --remove-section submodule.subname
1244 cat > expect << EOF
1245 ; On branch master
1246 ; Changes to be committed:
1247 ; (use "git reset HEAD <file>..." to unstage)
1249 ; modified: sm
1251 ; Changes not staged for commit:
1252 ; (use "git add <file>..." to update what will be committed)
1253 ; (use "git checkout -- <file>..." to discard changes in working directory)
1255 ; modified: dir1/modified
1256 ; modified: sm (new commits)
1258 ; Submodule changes to be committed:
1260 ; * sm $head...$new_head (1):
1261 ; > Add bar
1263 ; Submodules changed but not updated:
1265 ; * sm $new_head...$head2 (1):
1266 ; > 2nd commit
1268 ; Untracked files:
1269 ; (use "git add <file>..." to include in what will be committed)
1271 ; .gitmodules
1272 ; dir1/untracked
1273 ; dir2/modified
1274 ; dir2/untracked
1275 ; expect
1276 ; output
1277 ; untracked
1280 test_expect_success "status (core.commentchar with submodule summary)" '
1281 test_config core.commentchar ";" &&
1282 git status >output &&
1283 test_i18ncmp expect output
1286 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1287 test_config core.commentchar ";;" &&
1288 git status >output &&
1289 test_i18ncmp expect output
1292 cat > expect << EOF
1293 # On branch master
1294 # Changes not staged for commit:
1295 # (use "git add <file>..." to update what will be committed)
1296 # (use "git checkout -- <file>..." to discard changes in working directory)
1298 # modified: dir1/modified
1300 # Untracked files:
1301 # (use "git add <file>..." to include in what will be committed)
1303 # .gitmodules
1304 # dir1/untracked
1305 # dir2/modified
1306 # dir2/untracked
1307 # expect
1308 # output
1309 # untracked
1310 no changes added to commit (use "git add" and/or "git commit -a")
1313 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1314 git status --ignore-submodules=all > output &&
1315 test_i18ncmp expect output
1318 test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1319 git config --add -f .gitmodules submodule.subname.ignore all &&
1320 git config --add -f .gitmodules submodule.subname.path sm &&
1321 git status > output &&
1322 test_cmp expect output &&
1323 git config -f .gitmodules --remove-section submodule.subname
1326 test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1327 git config --add -f .gitmodules submodule.subname.ignore none &&
1328 git config --add -f .gitmodules submodule.subname.path sm &&
1329 git config --add submodule.subname.ignore all &&
1330 git config --add submodule.subname.path sm &&
1331 git status > output &&
1332 test_cmp expect output &&
1333 git config --remove-section submodule.subname &&
1334 git config -f .gitmodules --remove-section submodule.subname
1337 test_done