stash: fix accidental apply of non-existent stashes
[git/jnareb-git.git] / t / t7508-status.sh
blobf1dc5c3b6a36507e664e624bf9cebb1634bce335
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 grep "[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 grep "[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)' '
60 grep "use \"git rm --cached <file>\.\.\.\" to unstage" 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
81 # dir2/modified
82 # dir2/untracked
83 # expect
84 # output
85 # untracked
86 EOF
88 test_expect_success 'status (2)' '
90 git status >output &&
91 test_cmp expect output
95 cat >expect <<\EOF
96 # On branch master
97 # Changes to be committed:
98 # new file: dir2/added
100 # Changes not staged for commit:
101 # modified: dir1/modified
103 # Untracked files:
104 # dir1/untracked
105 # dir2/modified
106 # dir2/untracked
107 # expect
108 # output
109 # untracked
112 git config advice.statusHints false
114 test_expect_success 'status (advice.statusHints false)' '
116 git status >output &&
117 test_cmp expect output
121 git config --unset advice.statusHints
123 cat >expect <<\EOF
124 M dir1/modified
125 A dir2/added
126 ?? dir1/untracked
127 ?? dir2/modified
128 ?? dir2/untracked
129 ?? expect
130 ?? output
131 ?? untracked
134 test_expect_success 'status -s' '
136 git status -s >output &&
137 test_cmp expect output
141 cat >expect <<\EOF
142 ## master
143 M dir1/modified
144 A dir2/added
145 ?? dir1/untracked
146 ?? dir2/modified
147 ?? dir2/untracked
148 ?? expect
149 ?? output
150 ?? untracked
153 test_expect_success 'status -s -b' '
155 git status -s -b >output &&
156 test_cmp expect output
160 cat >expect <<EOF
161 # On branch master
162 # Changes to be committed:
163 # (use "git reset HEAD <file>..." to unstage)
165 # new file: dir2/added
167 # Changes not staged for commit:
168 # (use "git add <file>..." to update what will be committed)
169 # (use "git checkout -- <file>..." to discard changes in working directory)
171 # modified: dir1/modified
173 # Untracked files not listed (use -u option to show untracked files)
175 test_expect_success 'status -uno' '
176 mkdir dir3 &&
177 : >dir3/untracked1 &&
178 : >dir3/untracked2 &&
179 git status -uno >output &&
180 test_cmp expect output
183 test_expect_success 'status (status.showUntrackedFiles no)' '
184 git config status.showuntrackedfiles no
185 git status >output &&
186 test_cmp expect output
189 cat >expect <<EOF
190 # On branch master
191 # Changes to be committed:
192 # new file: dir2/added
194 # Changes not staged for commit:
195 # modified: dir1/modified
197 # Untracked files not listed
199 git config advice.statusHints false
200 test_expect_success 'status -uno (advice.statusHints false)' '
201 git status -uno >output &&
202 test_cmp expect output
204 git config --unset advice.statusHints
206 cat >expect << EOF
207 M dir1/modified
208 A dir2/added
210 test_expect_success 'status -s -uno' '
211 git config --unset status.showuntrackedfiles
212 git status -s -uno >output &&
213 test_cmp expect output
216 test_expect_success 'status -s (status.showUntrackedFiles no)' '
217 git config status.showuntrackedfiles no
218 git status -s >output &&
219 test_cmp expect output
222 cat >expect <<EOF
223 # On branch master
224 # Changes to be committed:
225 # (use "git reset HEAD <file>..." to unstage)
227 # new file: dir2/added
229 # Changes not staged for commit:
230 # (use "git add <file>..." to update what will be committed)
231 # (use "git checkout -- <file>..." to discard changes in working directory)
233 # modified: dir1/modified
235 # Untracked files:
236 # (use "git add <file>..." to include in what will be committed)
238 # dir1/untracked
239 # dir2/modified
240 # dir2/untracked
241 # dir3/
242 # expect
243 # output
244 # untracked
246 test_expect_success 'status -unormal' '
247 git status -unormal >output &&
248 test_cmp expect output
251 test_expect_success 'status (status.showUntrackedFiles normal)' '
252 git config status.showuntrackedfiles normal
253 git status >output &&
254 test_cmp expect output
257 cat >expect <<EOF
258 M dir1/modified
259 A dir2/added
260 ?? dir1/untracked
261 ?? dir2/modified
262 ?? dir2/untracked
263 ?? dir3/
264 ?? expect
265 ?? output
266 ?? untracked
268 test_expect_success 'status -s -unormal' '
269 git config --unset status.showuntrackedfiles
270 git status -s -unormal >output &&
271 test_cmp expect output
274 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
275 git config status.showuntrackedfiles normal
276 git status -s >output &&
277 test_cmp expect output
280 cat >expect <<EOF
281 # On branch master
282 # Changes to be committed:
283 # (use "git reset HEAD <file>..." to unstage)
285 # new file: dir2/added
287 # Changes not staged for commit:
288 # (use "git add <file>..." to update what will be committed)
289 # (use "git checkout -- <file>..." to discard changes in working directory)
291 # modified: dir1/modified
293 # Untracked files:
294 # (use "git add <file>..." to include in what will be committed)
296 # dir1/untracked
297 # dir2/modified
298 # dir2/untracked
299 # dir3/untracked1
300 # dir3/untracked2
301 # expect
302 # output
303 # untracked
305 test_expect_success 'status -uall' '
306 git status -uall >output &&
307 test_cmp expect output
309 test_expect_success 'status (status.showUntrackedFiles all)' '
310 git config status.showuntrackedfiles all
311 git status >output &&
312 rm -rf dir3 &&
313 git config --unset status.showuntrackedfiles &&
314 test_cmp expect output
317 cat >expect <<EOF
318 M dir1/modified
319 A dir2/added
320 ?? dir1/untracked
321 ?? dir2/modified
322 ?? dir2/untracked
323 ?? expect
324 ?? output
325 ?? untracked
327 test_expect_success 'status -s -uall' '
328 git config --unset status.showuntrackedfiles
329 git status -s -uall >output &&
330 test_cmp expect output
332 test_expect_success 'status -s (status.showUntrackedFiles all)' '
333 git config status.showuntrackedfiles all
334 git status -s >output &&
335 rm -rf dir3 &&
336 git config --unset status.showuntrackedfiles &&
337 test_cmp expect output
340 cat >expect <<\EOF
341 # On branch master
342 # Changes to be committed:
343 # (use "git reset HEAD <file>..." to unstage)
345 # new file: ../dir2/added
347 # Changes not staged for commit:
348 # (use "git add <file>..." to update what will be committed)
349 # (use "git checkout -- <file>..." to discard changes in working directory)
351 # modified: modified
353 # Untracked files:
354 # (use "git add <file>..." to include in what will be committed)
356 # untracked
357 # ../dir2/modified
358 # ../dir2/untracked
359 # ../expect
360 # ../output
361 # ../untracked
364 test_expect_success 'status with relative paths' '
366 (cd dir1 && git status) >output &&
367 test_cmp expect output
371 cat >expect <<\EOF
372 M modified
373 A ../dir2/added
374 ?? untracked
375 ?? ../dir2/modified
376 ?? ../dir2/untracked
377 ?? ../expect
378 ?? ../output
379 ?? ../untracked
381 test_expect_success 'status -s with relative paths' '
383 (cd dir1 && git status -s) >output &&
384 test_cmp expect output
388 cat >expect <<\EOF
389 M dir1/modified
390 A dir2/added
391 ?? dir1/untracked
392 ?? dir2/modified
393 ?? dir2/untracked
394 ?? expect
395 ?? output
396 ?? untracked
399 test_expect_success 'status --porcelain ignores relative paths setting' '
401 (cd dir1 && git status --porcelain) >output &&
402 test_cmp expect output
406 test_expect_success 'setup unique colors' '
408 git config status.color.untracked blue &&
409 git config status.color.branch green
413 cat >expect <<\EOF
414 # On branch <GREEN>master<RESET>
415 # Changes to be committed:
416 # (use "git reset HEAD <file>..." to unstage)
418 # <GREEN>new file: dir2/added<RESET>
420 # Changes not staged for commit:
421 # (use "git add <file>..." to update what will be committed)
422 # (use "git checkout -- <file>..." to discard changes in working directory)
424 # <RED>modified: dir1/modified<RESET>
426 # Untracked files:
427 # (use "git add <file>..." to include in what will be committed)
429 # <BLUE>dir1/untracked<RESET>
430 # <BLUE>dir2/modified<RESET>
431 # <BLUE>dir2/untracked<RESET>
432 # <BLUE>expect<RESET>
433 # <BLUE>output<RESET>
434 # <BLUE>untracked<RESET>
437 test_expect_success 'status with color.ui' '
439 git config color.ui always &&
440 git status | test_decode_color >output &&
441 test_cmp expect output
445 test_expect_success 'status with color.status' '
447 git config --unset color.ui &&
448 git config color.status always &&
449 git status | test_decode_color >output &&
450 test_cmp expect output
454 cat >expect <<\EOF
455 <RED>M<RESET> dir1/modified
456 <GREEN>A<RESET> dir2/added
457 <BLUE>??<RESET> dir1/untracked
458 <BLUE>??<RESET> dir2/modified
459 <BLUE>??<RESET> dir2/untracked
460 <BLUE>??<RESET> expect
461 <BLUE>??<RESET> output
462 <BLUE>??<RESET> untracked
465 test_expect_success 'status -s with color.ui' '
467 git config --unset color.status &&
468 git config color.ui always &&
469 git status -s | test_decode_color >output &&
470 test_cmp expect output
474 test_expect_success 'status -s with color.status' '
476 git config --unset color.ui &&
477 git config color.status always &&
478 git status -s | test_decode_color >output &&
479 test_cmp expect output
483 cat >expect <<\EOF
484 ## <GREEN>master<RESET>
485 <RED>M<RESET> dir1/modified
486 <GREEN>A<RESET> dir2/added
487 <BLUE>??<RESET> dir1/untracked
488 <BLUE>??<RESET> dir2/modified
489 <BLUE>??<RESET> dir2/untracked
490 <BLUE>??<RESET> expect
491 <BLUE>??<RESET> output
492 <BLUE>??<RESET> untracked
495 test_expect_success 'status -s -b with color.status' '
497 git status -s -b | test_decode_color >output &&
498 test_cmp expect output
502 cat >expect <<\EOF
503 M dir1/modified
504 A dir2/added
505 ?? dir1/untracked
506 ?? dir2/modified
507 ?? dir2/untracked
508 ?? expect
509 ?? output
510 ?? untracked
513 test_expect_success 'status --porcelain ignores color.ui' '
515 git config --unset color.status &&
516 git config color.ui always &&
517 git status --porcelain | test_decode_color >output &&
518 test_cmp expect output
522 test_expect_success 'status --porcelain ignores color.status' '
524 git config --unset color.ui &&
525 git config color.status always &&
526 git status --porcelain | test_decode_color >output &&
527 test_cmp expect output
531 # recover unconditionally from color tests
532 git config --unset color.status
533 git config --unset color.ui
535 test_expect_success 'status --porcelain ignores -b' '
537 git status --porcelain -b >output &&
538 test_cmp expect output
542 cat >expect <<\EOF
543 # On branch master
544 # Changes to be committed:
545 # (use "git reset HEAD <file>..." to unstage)
547 # new file: dir2/added
549 # Changes not staged for commit:
550 # (use "git add <file>..." to update what will be committed)
551 # (use "git checkout -- <file>..." to discard changes in working directory)
553 # modified: dir1/modified
555 # Untracked files:
556 # (use "git add <file>..." to include in what will be committed)
558 # dir1/untracked
559 # dir2/modified
560 # dir2/untracked
561 # expect
562 # output
563 # untracked
567 test_expect_success 'status without relative paths' '
569 git config status.relativePaths false
570 (cd dir1 && git status) >output &&
571 test_cmp expect output
575 cat >expect <<\EOF
576 M dir1/modified
577 A dir2/added
578 ?? dir1/untracked
579 ?? dir2/modified
580 ?? dir2/untracked
581 ?? expect
582 ?? output
583 ?? untracked
586 test_expect_success 'status -s without relative paths' '
588 (cd dir1 && git status -s) >output &&
589 test_cmp expect output
593 cat <<EOF >expect
594 # On branch master
595 # Changes to be committed:
596 # (use "git reset HEAD <file>..." to unstage)
598 # modified: dir1/modified
600 # Untracked files:
601 # (use "git add <file>..." to include in what will be committed)
603 # dir1/untracked
604 # dir2/
605 # expect
606 # output
607 # untracked
609 test_expect_success 'dry-run of partial commit excluding new file in index' '
610 git commit --dry-run dir1/modified >output &&
611 test_cmp expect output
614 cat >expect <<EOF
615 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
617 test_expect_success 'status refreshes the index' '
618 touch dir2/added &&
619 git status &&
620 git diff-files >output &&
621 test_cmp expect output
624 test_expect_success 'setup status submodule summary' '
625 test_create_repo sm && (
626 cd sm &&
627 >foo &&
628 git add foo &&
629 git commit -m "Add foo"
630 ) &&
631 git add sm
634 cat >expect <<EOF
635 # On branch master
636 # Changes to be committed:
637 # (use "git reset HEAD <file>..." to unstage)
639 # new file: dir2/added
640 # new file: sm
642 # Changes not staged for commit:
643 # (use "git add <file>..." to update what will be committed)
644 # (use "git checkout -- <file>..." to discard changes in working directory)
646 # modified: dir1/modified
648 # Untracked files:
649 # (use "git add <file>..." to include in what will be committed)
651 # dir1/untracked
652 # dir2/modified
653 # dir2/untracked
654 # expect
655 # output
656 # untracked
658 test_expect_success 'status submodule summary is disabled by default' '
659 git status >output &&
660 test_cmp expect output
663 # we expect the same as the previous test
664 test_expect_success 'status --untracked-files=all does not show submodule' '
665 git status --untracked-files=all >output &&
666 test_cmp expect output
669 cat >expect <<EOF
670 M dir1/modified
671 A dir2/added
672 A sm
673 ?? dir1/untracked
674 ?? dir2/modified
675 ?? dir2/untracked
676 ?? expect
677 ?? output
678 ?? untracked
680 test_expect_success 'status -s submodule summary is disabled by default' '
681 git status -s >output &&
682 test_cmp expect output
685 # we expect the same as the previous test
686 test_expect_success 'status -s --untracked-files=all does not show submodule' '
687 git status -s --untracked-files=all >output &&
688 test_cmp expect output
691 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
693 cat >expect <<EOF
694 # On branch master
695 # Changes to be committed:
696 # (use "git reset HEAD <file>..." to unstage)
698 # new file: dir2/added
699 # new file: sm
701 # Changes not staged for commit:
702 # (use "git add <file>..." to update what will be committed)
703 # (use "git checkout -- <file>..." to discard changes in working directory)
705 # modified: dir1/modified
707 # Submodule changes to be committed:
709 # * sm 0000000...$head (1):
710 # > Add foo
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
722 test_expect_success 'status submodule summary' '
723 git config status.submodulesummary 10 &&
724 git status >output &&
725 test_cmp expect output
728 cat >expect <<EOF
729 M dir1/modified
730 A dir2/added
731 A sm
732 ?? dir1/untracked
733 ?? dir2/modified
734 ?? dir2/untracked
735 ?? expect
736 ?? output
737 ?? untracked
739 test_expect_success 'status -s submodule summary' '
740 git status -s >output &&
741 test_cmp expect output
744 cat >expect <<EOF
745 # On branch master
746 # Changes not staged for commit:
747 # (use "git add <file>..." to update what will be committed)
748 # (use "git checkout -- <file>..." to discard changes in working directory)
750 # modified: dir1/modified
752 # Untracked files:
753 # (use "git add <file>..." to include in what will be committed)
755 # dir1/untracked
756 # dir2/modified
757 # dir2/untracked
758 # expect
759 # output
760 # untracked
761 no changes added to commit (use "git add" and/or "git commit -a")
763 test_expect_success 'status submodule summary (clean submodule)' '
764 git commit -m "commit submodule" &&
765 git config status.submodulesummary 10 &&
766 test_must_fail git commit --dry-run >output &&
767 test_cmp expect output &&
768 git status >output &&
769 test_cmp expect output
772 cat >expect <<EOF
773 M dir1/modified
774 ?? dir1/untracked
775 ?? dir2/modified
776 ?? dir2/untracked
777 ?? expect
778 ?? output
779 ?? untracked
781 test_expect_success 'status -s submodule summary (clean submodule)' '
782 git status -s >output &&
783 test_cmp expect output
786 cat >expect <<EOF
787 # On branch master
788 # Changes to be committed:
789 # (use "git reset HEAD^1 <file>..." to unstage)
791 # new file: dir2/added
792 # new file: sm
794 # Changes not staged for commit:
795 # (use "git add <file>..." to update what will be committed)
796 # (use "git checkout -- <file>..." to discard changes in working directory)
798 # modified: dir1/modified
800 # Submodule changes to be committed:
802 # * sm 0000000...$head (1):
803 # > Add foo
805 # Untracked files:
806 # (use "git add <file>..." to include in what will be committed)
808 # dir1/untracked
809 # dir2/modified
810 # dir2/untracked
811 # expect
812 # output
813 # untracked
815 test_expect_success 'commit --dry-run submodule summary (--amend)' '
816 git config status.submodulesummary 10 &&
817 git commit --dry-run --amend >output &&
818 test_cmp expect output
821 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
823 chmod a-w .git &&
824 # make dir1/tracked stat-dirty
825 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
826 git status -s >output &&
827 ! grep dir1/tracked output &&
828 # make sure "status" succeeded without writing index out
829 git diff-files | grep dir1/tracked
831 status=$?
832 chmod 775 .git
833 (exit $status)
836 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
837 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
838 touch .gitmodules
840 cat > expect << EOF
841 # On branch master
842 # Changes to be committed:
843 # (use "git reset HEAD <file>..." to unstage)
845 # modified: 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 $head...$new_head (1):
856 # > Add bar
858 # Untracked files:
859 # (use "git add <file>..." to include in what will be committed)
861 # .gitmodules
862 # dir1/untracked
863 # dir2/modified
864 # dir2/untracked
865 # expect
866 # output
867 # untracked
870 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
871 echo modified > sm/untracked &&
872 git status --ignore-submodules=untracked > output &&
873 test_cmp expect output
876 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
877 git config diff.ignoreSubmodules dirty &&
878 git status >output &&
879 test_cmp expect output &&
880 git config --add -f .gitmodules submodule.subname.ignore untracked &&
881 git config --add -f .gitmodules submodule.subname.path sm &&
882 git status > output &&
883 test_cmp expect output &&
884 git config -f .gitmodules --remove-section submodule.subname &&
885 git config --unset diff.ignoreSubmodules
888 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
889 git config --add -f .gitmodules submodule.subname.ignore none &&
890 git config --add -f .gitmodules submodule.subname.path sm &&
891 git config --add submodule.subname.ignore untracked &&
892 git config --add submodule.subname.path sm &&
893 git status > output &&
894 test_cmp expect output &&
895 git config --remove-section submodule.subname &&
896 git config --remove-section -f .gitmodules submodule.subname
899 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
900 git status --ignore-submodules=dirty > output &&
901 test_cmp expect output
904 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
905 git config diff.ignoreSubmodules dirty &&
906 git status >output &&
907 ! test -s actual &&
908 git config --add -f .gitmodules submodule.subname.ignore dirty &&
909 git config --add -f .gitmodules submodule.subname.path sm &&
910 git status > output &&
911 test_cmp expect output &&
912 git config -f .gitmodules --remove-section submodule.subname &&
913 git config --unset diff.ignoreSubmodules
916 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
917 git config --add -f .gitmodules submodule.subname.ignore none &&
918 git config --add -f .gitmodules submodule.subname.path sm &&
919 git config --add submodule.subname.ignore dirty &&
920 git config --add submodule.subname.path sm &&
921 git status > output &&
922 test_cmp expect output &&
923 git config --remove-section submodule.subname &&
924 git config -f .gitmodules --remove-section submodule.subname
927 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
928 echo modified > sm/foo &&
929 git status --ignore-submodules=dirty > output &&
930 test_cmp expect output
933 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
934 git config --add -f .gitmodules submodule.subname.ignore dirty &&
935 git config --add -f .gitmodules submodule.subname.path sm &&
936 git status > output &&
937 test_cmp expect output &&
938 git config -f .gitmodules --remove-section submodule.subname
941 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
942 git config --add -f .gitmodules submodule.subname.ignore none &&
943 git config --add -f .gitmodules submodule.subname.path sm &&
944 git config --add submodule.subname.ignore dirty &&
945 git config --add submodule.subname.path sm &&
946 git status > output &&
947 test_cmp expect output &&
948 git config --remove-section submodule.subname &&
949 git config -f .gitmodules --remove-section submodule.subname
952 cat > expect << EOF
953 # On branch master
954 # Changes to be committed:
955 # (use "git reset HEAD <file>..." to unstage)
957 # modified: sm
959 # Changes not staged for commit:
960 # (use "git add <file>..." to update what will be committed)
961 # (use "git checkout -- <file>..." to discard changes in working directory)
962 # (commit or discard the untracked or modified content in submodules)
964 # modified: dir1/modified
965 # modified: sm (modified content)
967 # Submodule changes to be committed:
969 # * sm $head...$new_head (1):
970 # > Add bar
972 # Untracked files:
973 # (use "git add <file>..." to include in what will be committed)
975 # .gitmodules
976 # dir1/untracked
977 # dir2/modified
978 # dir2/untracked
979 # expect
980 # output
981 # untracked
984 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
985 git status --ignore-submodules=untracked > output &&
986 test_cmp expect output
989 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
990 git config --add -f .gitmodules submodule.subname.ignore untracked &&
991 git config --add -f .gitmodules submodule.subname.path sm &&
992 git status > output &&
993 test_cmp expect output &&
994 git config -f .gitmodules --remove-section submodule.subname
997 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
998 git config --add -f .gitmodules submodule.subname.ignore none &&
999 git config --add -f .gitmodules submodule.subname.path sm &&
1000 git config --add submodule.subname.ignore untracked &&
1001 git config --add submodule.subname.path sm &&
1002 git status > output &&
1003 test_cmp expect output &&
1004 git config --remove-section submodule.subname &&
1005 git config -f .gitmodules --remove-section submodule.subname
1008 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1010 cat > expect << EOF
1011 # On branch master
1012 # Changes to be committed:
1013 # (use "git reset HEAD <file>..." to unstage)
1015 # modified: sm
1017 # Changes not staged for commit:
1018 # (use "git add <file>..." to update what will be committed)
1019 # (use "git checkout -- <file>..." to discard changes in working directory)
1021 # modified: dir1/modified
1022 # modified: sm (new commits)
1024 # Submodule changes to be committed:
1026 # * sm $head...$new_head (1):
1027 # > Add bar
1029 # Submodules changed but not updated:
1031 # * sm $new_head...$head2 (1):
1032 # > 2nd commit
1034 # Untracked files:
1035 # (use "git add <file>..." to include in what will be committed)
1037 # .gitmodules
1038 # dir1/untracked
1039 # dir2/modified
1040 # dir2/untracked
1041 # expect
1042 # output
1043 # untracked
1046 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1047 git status --ignore-submodules=untracked > output &&
1048 test_cmp expect output
1051 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1052 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1053 git config --add -f .gitmodules submodule.subname.path sm &&
1054 git status > output &&
1055 test_cmp expect output &&
1056 git config -f .gitmodules --remove-section submodule.subname
1059 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1060 git config --add -f .gitmodules submodule.subname.ignore none &&
1061 git config --add -f .gitmodules submodule.subname.path sm &&
1062 git config --add submodule.subname.ignore untracked &&
1063 git config --add submodule.subname.path sm &&
1064 git status > output &&
1065 test_cmp expect output &&
1066 git config --remove-section submodule.subname &&
1067 git config -f .gitmodules --remove-section submodule.subname
1070 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1071 git status --ignore-submodules=dirty > output &&
1072 test_cmp expect output
1074 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
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_cmp expect output &&
1079 git config -f .gitmodules --remove-section submodule.subname
1082 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1083 git config --add -f .gitmodules submodule.subname.ignore none &&
1084 git config --add -f .gitmodules submodule.subname.path sm &&
1085 git config --add submodule.subname.ignore dirty &&
1086 git config --add submodule.subname.path sm &&
1087 git status > output &&
1088 test_cmp expect output &&
1089 git config --remove-section submodule.subname &&
1090 git config -f .gitmodules --remove-section submodule.subname
1093 cat > expect << EOF
1094 # On branch master
1095 # Changes not staged for commit:
1096 # (use "git add <file>..." to update what will be committed)
1097 # (use "git checkout -- <file>..." to discard changes in working directory)
1099 # modified: dir1/modified
1101 # Untracked files:
1102 # (use "git add <file>..." to include in what will be committed)
1104 # .gitmodules
1105 # dir1/untracked
1106 # dir2/modified
1107 # dir2/untracked
1108 # expect
1109 # output
1110 # untracked
1111 no changes added to commit (use "git add" and/or "git commit -a")
1114 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1115 git status --ignore-submodules=all > output &&
1116 test_cmp expect output
1119 test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1120 git config --add -f .gitmodules submodule.subname.ignore all &&
1121 git config --add -f .gitmodules submodule.subname.path sm &&
1122 git status > output &&
1123 test_cmp expect output &&
1124 git config -f .gitmodules --remove-section submodule.subname
1127 test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1128 git config --add -f .gitmodules submodule.subname.ignore none &&
1129 git config --add -f .gitmodules submodule.subname.path sm &&
1130 git config --add submodule.subname.ignore all &&
1131 git config --add submodule.subname.path sm &&
1132 git status > output &&
1133 test_cmp expect output &&
1134 git config --remove-section submodule.subname &&
1135 git config -f .gitmodules --remove-section submodule.subname
1138 test_done