Merge branch 'master' of git://repo.or.cz/alt-git
[git/mingw.git] / t / t7508-status.sh
blob7dcb9741357e028b06afb76350493f9e97246b98
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 mkdir broken &&
16 test_when_finished "rm -fr broken" &&
18 cd broken &&
19 git init &&
20 echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
21 test_expect_code 129 git status -h >usage 2>&1
22 ) &&
23 test_i18ngrep "[Uu]sage" broken/usage
26 test_expect_success 'commit -h in broken repository' '
27 mkdir broken &&
28 test_when_finished "rm -fr broken" &&
30 cd broken &&
31 git init &&
32 echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
33 test_expect_code 129 git commit -h >usage 2>&1
34 ) &&
35 test_i18ngrep "[Uu]sage" broken/usage
38 test_expect_success 'setup' '
39 : >tracked &&
40 : >modified &&
41 mkdir dir1 &&
42 : >dir1/tracked &&
43 : >dir1/modified &&
44 mkdir dir2 &&
45 : >dir1/tracked &&
46 : >dir1/modified &&
47 git add . &&
49 git status >output &&
51 test_tick &&
52 git commit -m initial &&
53 : >untracked &&
54 : >dir1/untracked &&
55 : >dir2/untracked &&
56 echo 1 >dir1/modified &&
57 echo 2 >dir2/modified &&
58 echo 3 >dir2/added &&
59 git add dir2/added
62 test_expect_success 'status (1)' '
63 test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output
66 test_expect_success 'status --column' '
67 COLUMNS=50 git status --column="column dense" >output &&
68 cat >expect <<\EOF &&
69 # On branch master
70 # Changes to be committed:
71 # (use "git reset HEAD <file>..." to unstage)
73 # new file: dir2/added
75 # Changes not staged for commit:
76 # (use "git add <file>..." to update what will be committed)
77 # (use "git checkout -- <file>..." to discard changes in working directory)
79 # modified: dir1/modified
81 # Untracked files:
82 # (use "git add <file>..." to include in what will be committed)
84 # dir1/untracked dir2/untracked untracked
85 # dir2/modified output
86 EOF
87 test_i18ncmp expect output
90 cat >expect <<\EOF
91 # On branch master
92 # Changes to be committed:
93 # (use "git reset HEAD <file>..." to unstage)
95 # new file: dir2/added
97 # Changes not staged for commit:
98 # (use "git add <file>..." to update what will be committed)
99 # (use "git checkout -- <file>..." to discard changes in working directory)
101 # modified: dir1/modified
103 # Untracked files:
104 # (use "git add <file>..." to include in what will be committed)
106 # dir1/untracked
107 # dir2/modified
108 # dir2/untracked
109 # expect
110 # output
111 # untracked
114 test_expect_success 'status (2)' '
115 git status >output &&
116 test_i18ncmp expect output
119 cat >expect <<\EOF
120 # On branch master
121 # Changes to be committed:
122 # new file: dir2/added
124 # Changes not staged for commit:
125 # modified: dir1/modified
127 # Untracked files:
128 # dir1/untracked
129 # dir2/modified
130 # dir2/untracked
131 # expect
132 # output
133 # untracked
136 test_expect_success 'status (advice.statusHints false)' '
137 test_when_finished "git config --unset advice.statusHints" &&
138 git 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 git config status.showuntrackedfiles no
339 test_when_finished "git config --unset status.showuntrackedfiles" &&
340 git status >output &&
341 test_i18ncmp expect output
344 cat >expect <<EOF
345 # On branch master
346 # Changes to be committed:
347 # new file: dir2/added
349 # Changes not staged for commit:
350 # modified: dir1/modified
352 # Untracked files not listed
354 git config advice.statusHints false
355 test_expect_success 'status -uno (advice.statusHints false)' '
356 git status -uno >output &&
357 test_i18ncmp expect output
359 git config --unset advice.statusHints
361 cat >expect << EOF
362 M dir1/modified
363 A dir2/added
365 test_expect_success 'status -s -uno' '
366 git status -s -uno >output &&
367 test_cmp expect output
370 test_expect_success 'status -s (status.showUntrackedFiles no)' '
371 git config status.showuntrackedfiles no
372 git status -s >output &&
373 test_cmp expect output
376 cat >expect <<EOF
377 # On branch master
378 # Changes to be committed:
379 # (use "git reset HEAD <file>..." to unstage)
381 # new file: dir2/added
383 # Changes not staged for commit:
384 # (use "git add <file>..." to update what will be committed)
385 # (use "git checkout -- <file>..." to discard changes in working directory)
387 # modified: dir1/modified
389 # Untracked files:
390 # (use "git add <file>..." to include in what will be committed)
392 # dir1/untracked
393 # dir2/modified
394 # dir2/untracked
395 # dir3/
396 # expect
397 # output
398 # untracked
400 test_expect_success 'status -unormal' '
401 git status -unormal >output &&
402 test_i18ncmp expect output
405 test_expect_success 'status (status.showUntrackedFiles normal)' '
406 git config status.showuntrackedfiles normal
407 test_when_finished "git config --unset status.showuntrackedfiles" &&
408 git status >output &&
409 test_i18ncmp expect output
412 cat >expect <<EOF
413 M dir1/modified
414 A dir2/added
415 ?? dir1/untracked
416 ?? dir2/modified
417 ?? dir2/untracked
418 ?? dir3/
419 ?? expect
420 ?? output
421 ?? untracked
423 test_expect_success 'status -s -unormal' '
424 git status -s -unormal >output &&
425 test_cmp expect output
428 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
429 git config status.showuntrackedfiles normal
430 git status -s >output &&
431 test_cmp expect output
434 cat >expect <<EOF
435 # On branch master
436 # Changes to be committed:
437 # (use "git reset HEAD <file>..." to unstage)
439 # new file: dir2/added
441 # Changes not staged for commit:
442 # (use "git add <file>..." to update what will be committed)
443 # (use "git checkout -- <file>..." to discard changes in working directory)
445 # modified: dir1/modified
447 # Untracked files:
448 # (use "git add <file>..." to include in what will be committed)
450 # dir1/untracked
451 # dir2/modified
452 # dir2/untracked
453 # dir3/untracked1
454 # dir3/untracked2
455 # expect
456 # output
457 # untracked
459 test_expect_success 'status -uall' '
460 git status -uall >output &&
461 test_i18ncmp expect output
464 test_expect_success 'status (status.showUntrackedFiles all)' '
465 git config status.showuntrackedfiles all
466 test_when_finished "git config --unset status.showuntrackedfiles" &&
467 git status >output &&
468 test_i18ncmp expect output
471 test_expect_success 'teardown dir3' '
472 rm -rf dir3
475 cat >expect <<EOF
476 M dir1/modified
477 A dir2/added
478 ?? dir1/untracked
479 ?? dir2/modified
480 ?? dir2/untracked
481 ?? expect
482 ?? output
483 ?? untracked
485 test_expect_success 'status -s -uall' '
486 git config --unset status.showuntrackedfiles
487 git status -s -uall >output &&
488 test_cmp expect output
490 test_expect_success 'status -s (status.showUntrackedFiles all)' '
491 git config status.showuntrackedfiles all
492 git status -s >output &&
493 rm -rf dir3 &&
494 git config --unset status.showuntrackedfiles &&
495 test_cmp expect output
498 cat >expect <<\EOF
499 # On branch master
500 # Changes to be committed:
501 # (use "git reset HEAD <file>..." to unstage)
503 # new file: ../dir2/added
505 # Changes not staged for commit:
506 # (use "git add <file>..." to update what will be committed)
507 # (use "git checkout -- <file>..." to discard changes in working directory)
509 # modified: modified
511 # Untracked files:
512 # (use "git add <file>..." to include in what will be committed)
514 # untracked
515 # ../dir2/modified
516 # ../dir2/untracked
517 # ../expect
518 # ../output
519 # ../untracked
522 test_expect_success 'status with relative paths' '
523 (cd dir1 && git status) >output &&
524 test_i18ncmp expect output
527 cat >expect <<\EOF
528 M modified
529 A ../dir2/added
530 ?? untracked
531 ?? ../dir2/modified
532 ?? ../dir2/untracked
533 ?? ../expect
534 ?? ../output
535 ?? ../untracked
537 test_expect_success 'status -s with relative paths' '
539 (cd dir1 && git status -s) >output &&
540 test_cmp expect output
544 cat >expect <<\EOF
545 M dir1/modified
546 A dir2/added
547 ?? dir1/untracked
548 ?? dir2/modified
549 ?? dir2/untracked
550 ?? expect
551 ?? output
552 ?? untracked
555 test_expect_success 'status --porcelain ignores relative paths setting' '
557 (cd dir1 && git status --porcelain) >output &&
558 test_cmp expect output
562 test_expect_success 'setup unique colors' '
564 git config status.color.untracked blue &&
565 git config status.color.branch green
569 cat >expect <<\EOF
570 # On branch <GREEN>master<RESET>
571 # Changes to be committed:
572 # (use "git reset HEAD <file>..." to unstage)
574 # <GREEN>new file: dir2/added<RESET>
576 # Changes not staged for commit:
577 # (use "git add <file>..." to update what will be committed)
578 # (use "git checkout -- <file>..." to discard changes in working directory)
580 # <RED>modified: dir1/modified<RESET>
582 # Untracked files:
583 # (use "git add <file>..." to include in what will be committed)
585 # <BLUE>dir1/untracked<RESET>
586 # <BLUE>dir2/modified<RESET>
587 # <BLUE>dir2/untracked<RESET>
588 # <BLUE>expect<RESET>
589 # <BLUE>output<RESET>
590 # <BLUE>untracked<RESET>
593 test_expect_success 'status with color.ui' '
594 git config color.ui always &&
595 test_when_finished "git config --unset color.ui" &&
596 git status | test_decode_color >output &&
597 test_i18ncmp expect output
600 test_expect_success 'status with color.status' '
601 git config color.status always &&
602 test_when_finished "git config --unset color.status" &&
603 git status | test_decode_color >output &&
604 test_i18ncmp expect output
607 cat >expect <<\EOF
608 <RED>M<RESET> dir1/modified
609 <GREEN>A<RESET> dir2/added
610 <BLUE>??<RESET> dir1/untracked
611 <BLUE>??<RESET> dir2/modified
612 <BLUE>??<RESET> dir2/untracked
613 <BLUE>??<RESET> expect
614 <BLUE>??<RESET> output
615 <BLUE>??<RESET> untracked
618 test_expect_success 'status -s with color.ui' '
620 git config color.ui always &&
621 git status -s | test_decode_color >output &&
622 test_cmp expect output
626 test_expect_success 'status -s with color.status' '
628 git config --unset color.ui &&
629 git config color.status always &&
630 git status -s | test_decode_color >output &&
631 test_cmp expect output
635 cat >expect <<\EOF
636 ## <GREEN>master<RESET>
637 <RED>M<RESET> dir1/modified
638 <GREEN>A<RESET> dir2/added
639 <BLUE>??<RESET> dir1/untracked
640 <BLUE>??<RESET> dir2/modified
641 <BLUE>??<RESET> dir2/untracked
642 <BLUE>??<RESET> expect
643 <BLUE>??<RESET> output
644 <BLUE>??<RESET> untracked
647 test_expect_success 'status -s -b with color.status' '
649 git status -s -b | test_decode_color >output &&
650 test_cmp expect output
654 cat >expect <<\EOF
655 M dir1/modified
656 A dir2/added
657 ?? dir1/untracked
658 ?? dir2/modified
659 ?? dir2/untracked
660 ?? expect
661 ?? output
662 ?? untracked
665 test_expect_success 'status --porcelain ignores color.ui' '
667 git config --unset color.status &&
668 git config color.ui always &&
669 git status --porcelain | test_decode_color >output &&
670 test_cmp expect output
674 test_expect_success 'status --porcelain ignores color.status' '
676 git config --unset color.ui &&
677 git config color.status always &&
678 git status --porcelain | test_decode_color >output &&
679 test_cmp expect output
683 # recover unconditionally from color tests
684 git config --unset color.status
685 git config --unset color.ui
687 test_expect_success 'status --porcelain respects -b' '
689 git status --porcelain -b >output &&
691 echo "## master" &&
692 cat expect
693 } >tmp &&
694 mv tmp expect &&
695 test_cmp expect output
699 cat >expect <<\EOF
700 # On branch master
701 # Changes to be committed:
702 # (use "git reset HEAD <file>..." to unstage)
704 # new file: dir2/added
706 # Changes not staged for commit:
707 # (use "git add <file>..." to update what will be committed)
708 # (use "git checkout -- <file>..." to discard changes in working directory)
710 # modified: dir1/modified
712 # Untracked files:
713 # (use "git add <file>..." to include in what will be committed)
715 # dir1/untracked
716 # dir2/modified
717 # dir2/untracked
718 # expect
719 # output
720 # untracked
724 test_expect_success 'status without relative paths' '
726 git config status.relativePaths false &&
727 test_when_finished "git config --unset status.relativePaths" &&
728 (cd dir1 && git status) >output &&
729 test_i18ncmp expect output
733 cat >expect <<\EOF
734 M dir1/modified
735 A dir2/added
736 ?? dir1/untracked
737 ?? dir2/modified
738 ?? dir2/untracked
739 ?? expect
740 ?? output
741 ?? untracked
744 test_expect_success 'status -s without relative paths' '
746 git config status.relativePaths false &&
747 test_when_finished "git config --unset status.relativePaths" &&
748 (cd dir1 && git status -s) >output &&
749 test_cmp expect output
753 cat <<EOF >expect
754 # On branch master
755 # Changes to be committed:
756 # (use "git reset HEAD <file>..." to unstage)
758 # modified: dir1/modified
760 # Untracked files:
761 # (use "git add <file>..." to include in what will be committed)
763 # dir1/untracked
764 # dir2/
765 # expect
766 # output
767 # untracked
769 test_expect_success 'dry-run of partial commit excluding new file in index' '
770 git commit --dry-run dir1/modified >output &&
771 test_i18ncmp expect output
774 cat >expect <<EOF
775 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
777 test_expect_success 'status refreshes the index' '
778 touch dir2/added &&
779 git status &&
780 git diff-files >output &&
781 test_cmp expect output
784 test_expect_success 'setup status submodule summary' '
785 test_create_repo sm && (
786 cd sm &&
787 >foo &&
788 git add foo &&
789 git commit -m "Add foo"
790 ) &&
791 git add sm
794 cat >expect <<EOF
795 # On branch master
796 # Changes to be committed:
797 # (use "git reset HEAD <file>..." to unstage)
799 # new file: dir2/added
800 # new file: sm
802 # Changes not staged for commit:
803 # (use "git add <file>..." to update what will be committed)
804 # (use "git checkout -- <file>..." to discard changes in working directory)
806 # modified: dir1/modified
808 # Untracked files:
809 # (use "git add <file>..." to include in what will be committed)
811 # dir1/untracked
812 # dir2/modified
813 # dir2/untracked
814 # expect
815 # output
816 # untracked
818 test_expect_success 'status submodule summary is disabled by default' '
819 git status >output &&
820 test_i18ncmp expect output
823 # we expect the same as the previous test
824 test_expect_success 'status --untracked-files=all does not show submodule' '
825 git status --untracked-files=all >output &&
826 test_i18ncmp expect output
829 cat >expect <<EOF
830 M dir1/modified
831 A dir2/added
832 A sm
833 ?? dir1/untracked
834 ?? dir2/modified
835 ?? dir2/untracked
836 ?? expect
837 ?? output
838 ?? untracked
840 test_expect_success 'status -s submodule summary is disabled by default' '
841 git status -s >output &&
842 test_cmp expect output
845 # we expect the same as the previous test
846 test_expect_success 'status -s --untracked-files=all does not show submodule' '
847 git status -s --untracked-files=all >output &&
848 test_cmp expect output
851 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
853 cat >expect <<EOF
854 # On branch master
855 # Changes to be committed:
856 # (use "git reset HEAD <file>..." to unstage)
858 # new file: dir2/added
859 # new file: sm
861 # Changes not staged for commit:
862 # (use "git add <file>..." to update what will be committed)
863 # (use "git checkout -- <file>..." to discard changes in working directory)
865 # modified: dir1/modified
867 # Submodule changes to be committed:
869 # * sm 0000000...$head (1):
870 # > Add foo
872 # Untracked files:
873 # (use "git add <file>..." to include in what will be committed)
875 # dir1/untracked
876 # dir2/modified
877 # dir2/untracked
878 # expect
879 # output
880 # untracked
882 test_expect_success 'status submodule summary' '
883 git config status.submodulesummary 10 &&
884 git status >output &&
885 test_i18ncmp expect output
888 cat >expect <<EOF
889 M dir1/modified
890 A dir2/added
891 A sm
892 ?? dir1/untracked
893 ?? dir2/modified
894 ?? dir2/untracked
895 ?? expect
896 ?? output
897 ?? untracked
899 test_expect_success 'status -s submodule summary' '
900 git status -s >output &&
901 test_cmp expect output
904 cat >expect <<EOF
905 # On branch master
906 # Changes not staged for commit:
907 # (use "git add <file>..." to update what will be committed)
908 # (use "git checkout -- <file>..." to discard changes in working directory)
910 # modified: dir1/modified
912 # Untracked files:
913 # (use "git add <file>..." to include in what will be committed)
915 # dir1/untracked
916 # dir2/modified
917 # dir2/untracked
918 # expect
919 # output
920 # untracked
921 no changes added to commit (use "git add" and/or "git commit -a")
923 test_expect_success 'status submodule summary (clean submodule): commit' '
924 git commit -m "commit submodule" &&
925 git config status.submodulesummary 10 &&
926 test_must_fail git commit --dry-run >output &&
927 test_i18ncmp expect output &&
928 git status >output &&
929 test_i18ncmp expect output
932 cat >expect <<EOF
933 M dir1/modified
934 ?? dir1/untracked
935 ?? dir2/modified
936 ?? dir2/untracked
937 ?? expect
938 ?? output
939 ?? untracked
941 test_expect_success 'status -s submodule summary (clean submodule)' '
942 git status -s >output &&
943 test_cmp expect output
946 test_expect_success 'status -z implies porcelain' '
947 git status --porcelain |
948 "$PERL_PATH" -pe "s/\012/\000/g" >expect &&
949 git status -z >output &&
950 test_cmp expect output
953 cat >expect <<EOF
954 # On branch master
955 # Changes to be committed:
956 # (use "git reset HEAD^1 <file>..." to unstage)
958 # new file: dir2/added
959 # new file: sm
961 # Changes not staged for commit:
962 # (use "git add <file>..." to update what will be committed)
963 # (use "git checkout -- <file>..." to discard changes in working directory)
965 # modified: dir1/modified
967 # Submodule changes to be committed:
969 # * sm 0000000...$head (1):
970 # > Add foo
972 # Untracked files:
973 # (use "git add <file>..." to include in what will be committed)
975 # dir1/untracked
976 # dir2/modified
977 # dir2/untracked
978 # expect
979 # output
980 # untracked
982 test_expect_success 'commit --dry-run submodule summary (--amend)' '
983 git config status.submodulesummary 10 &&
984 git commit --dry-run --amend >output &&
985 test_i18ncmp expect output
988 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
990 chmod a-w .git &&
991 # make dir1/tracked stat-dirty
992 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
993 git status -s >output &&
994 ! grep dir1/tracked output &&
995 # make sure "status" succeeded without writing index out
996 git diff-files | grep dir1/tracked
998 status=$?
999 chmod 775 .git
1000 (exit $status)
1003 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
1004 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
1005 touch .gitmodules
1007 cat > expect << EOF
1008 # On branch master
1009 # Changes to be committed:
1010 # (use "git reset HEAD <file>..." to unstage)
1012 # modified: sm
1014 # Changes not staged for commit:
1015 # (use "git add <file>..." to update what will be committed)
1016 # (use "git checkout -- <file>..." to discard changes in working directory)
1018 # modified: dir1/modified
1020 # Submodule changes to be committed:
1022 # * sm $head...$new_head (1):
1023 # > Add bar
1025 # Untracked files:
1026 # (use "git add <file>..." to include in what will be committed)
1028 # .gitmodules
1029 # dir1/untracked
1030 # dir2/modified
1031 # dir2/untracked
1032 # expect
1033 # output
1034 # untracked
1037 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1038 echo modified sm/untracked &&
1039 git status --ignore-submodules=untracked >output &&
1040 test_i18ncmp expect output
1043 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1044 git config diff.ignoreSubmodules dirty &&
1045 git status >output &&
1046 test_i18ncmp expect output &&
1047 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1048 git config --add -f .gitmodules submodule.subname.path sm &&
1049 git status >output &&
1050 test_i18ncmp expect output &&
1051 git config -f .gitmodules --remove-section submodule.subname &&
1052 git config --unset diff.ignoreSubmodules
1055 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1056 git config --add -f .gitmodules submodule.subname.ignore none &&
1057 git config --add -f .gitmodules submodule.subname.path sm &&
1058 git config --add submodule.subname.ignore untracked &&
1059 git config --add submodule.subname.path sm &&
1060 git status >output &&
1061 test_i18ncmp expect output &&
1062 git config --remove-section submodule.subname &&
1063 git config --remove-section -f .gitmodules submodule.subname
1066 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1067 git status --ignore-submodules=dirty >output &&
1068 test_i18ncmp expect output
1071 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1072 git config diff.ignoreSubmodules dirty &&
1073 git status >output &&
1074 ! test -s actual &&
1075 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1076 git config --add -f .gitmodules submodule.subname.path sm &&
1077 git status >output &&
1078 test_i18ncmp expect output &&
1079 git config -f .gitmodules --remove-section submodule.subname &&
1080 git config --unset diff.ignoreSubmodules
1083 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1084 git config --add -f .gitmodules submodule.subname.ignore none &&
1085 git config --add -f .gitmodules submodule.subname.path sm &&
1086 git config --add submodule.subname.ignore dirty &&
1087 git config --add submodule.subname.path sm &&
1088 git status >output &&
1089 test_i18ncmp expect output &&
1090 git config --remove-section submodule.subname &&
1091 git config -f .gitmodules --remove-section submodule.subname
1094 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1095 echo modified >sm/foo &&
1096 git status --ignore-submodules=dirty >output &&
1097 test_i18ncmp expect output
1100 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
1101 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1102 git config --add -f .gitmodules submodule.subname.path sm &&
1103 git status >output &&
1104 test_i18ncmp expect output &&
1105 git config -f .gitmodules --remove-section submodule.subname
1108 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
1109 git config --add -f .gitmodules submodule.subname.ignore none &&
1110 git config --add -f .gitmodules submodule.subname.path sm &&
1111 git config --add submodule.subname.ignore dirty &&
1112 git config --add submodule.subname.path sm &&
1113 git status >output &&
1114 test_i18ncmp expect output &&
1115 git config --remove-section submodule.subname &&
1116 git config -f .gitmodules --remove-section submodule.subname
1119 cat > expect << EOF
1120 # On branch master
1121 # Changes to be committed:
1122 # (use "git reset HEAD <file>..." to unstage)
1124 # modified: sm
1126 # Changes not staged for commit:
1127 # (use "git add <file>..." to update what will be committed)
1128 # (use "git checkout -- <file>..." to discard changes in working directory)
1129 # (commit or discard the untracked or modified content in submodules)
1131 # modified: dir1/modified
1132 # modified: sm (modified content)
1134 # Submodule changes to be committed:
1136 # * sm $head...$new_head (1):
1137 # > Add bar
1139 # Untracked files:
1140 # (use "git add <file>..." to include in what will be committed)
1142 # .gitmodules
1143 # dir1/untracked
1144 # dir2/modified
1145 # dir2/untracked
1146 # expect
1147 # output
1148 # untracked
1151 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1152 git status --ignore-submodules=untracked > output &&
1153 test_i18ncmp expect output
1156 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
1157 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1158 git config --add -f .gitmodules submodule.subname.path sm &&
1159 git status >output &&
1160 test_i18ncmp expect output &&
1161 git config -f .gitmodules --remove-section submodule.subname
1164 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1165 git config --add -f .gitmodules submodule.subname.ignore none &&
1166 git config --add -f .gitmodules submodule.subname.path sm &&
1167 git config --add submodule.subname.ignore untracked &&
1168 git config --add submodule.subname.path sm &&
1169 git status >output &&
1170 test_i18ncmp expect output &&
1171 git config --remove-section submodule.subname &&
1172 git config -f .gitmodules --remove-section submodule.subname
1175 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1177 cat > expect << EOF
1178 # On branch master
1179 # Changes to be committed:
1180 # (use "git reset HEAD <file>..." to unstage)
1182 # modified: sm
1184 # Changes not staged for commit:
1185 # (use "git add <file>..." to update what will be committed)
1186 # (use "git checkout -- <file>..." to discard changes in working directory)
1188 # modified: dir1/modified
1189 # modified: sm (new commits)
1191 # Submodule changes to be committed:
1193 # * sm $head...$new_head (1):
1194 # > Add bar
1196 # Submodules changed but not updated:
1198 # * sm $new_head...$head2 (1):
1199 # > 2nd commit
1201 # Untracked files:
1202 # (use "git add <file>..." to include in what will be committed)
1204 # .gitmodules
1205 # dir1/untracked
1206 # dir2/modified
1207 # dir2/untracked
1208 # expect
1209 # output
1210 # untracked
1213 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1214 git status --ignore-submodules=untracked > output &&
1215 test_i18ncmp expect output
1218 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1219 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1220 git config --add -f .gitmodules submodule.subname.path sm &&
1221 git status >output &&
1222 test_i18ncmp expect output &&
1223 git config -f .gitmodules --remove-section submodule.subname
1226 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1227 git config --add -f .gitmodules submodule.subname.ignore none &&
1228 git config --add -f .gitmodules submodule.subname.path sm &&
1229 git config --add submodule.subname.ignore untracked &&
1230 git config --add submodule.subname.path sm &&
1231 git status >output &&
1232 test_i18ncmp expect output &&
1233 git config --remove-section submodule.subname &&
1234 git config -f .gitmodules --remove-section submodule.subname
1237 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1238 git status --ignore-submodules=dirty > output &&
1239 test_i18ncmp expect output
1241 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1242 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1243 git config --add -f .gitmodules submodule.subname.path sm &&
1244 git status >output &&
1245 test_i18ncmp expect output &&
1246 git config -f .gitmodules --remove-section submodule.subname
1249 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1250 git config --add -f .gitmodules submodule.subname.ignore none &&
1251 git config --add -f .gitmodules submodule.subname.path sm &&
1252 git config --add submodule.subname.ignore dirty &&
1253 git config --add submodule.subname.path sm &&
1254 git status >output &&
1255 test_i18ncmp expect output &&
1256 git config --remove-section submodule.subname &&
1257 git config -f .gitmodules --remove-section submodule.subname
1260 cat > expect << EOF
1261 # On branch master
1262 # Changes not staged for commit:
1263 # (use "git add <file>..." to update what will be committed)
1264 # (use "git checkout -- <file>..." to discard changes in working directory)
1266 # modified: dir1/modified
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
1278 no changes added to commit (use "git add" and/or "git commit -a")
1281 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1282 git status --ignore-submodules=all > output &&
1283 test_i18ncmp expect output
1286 test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1287 git config --add -f .gitmodules submodule.subname.ignore all &&
1288 git config --add -f .gitmodules submodule.subname.path sm &&
1289 git status > output &&
1290 test_cmp expect output &&
1291 git config -f .gitmodules --remove-section submodule.subname
1294 test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1295 git config --add -f .gitmodules submodule.subname.ignore none &&
1296 git config --add -f .gitmodules submodule.subname.path sm &&
1297 git config --add submodule.subname.ignore all &&
1298 git config --add submodule.subname.path sm &&
1299 git status > output &&
1300 test_cmp expect output &&
1301 git config --remove-section submodule.subname &&
1302 git config -f .gitmodules --remove-section submodule.subname
1305 test_done