Merge branch 'lf/bundle-with-tip-wo-message'
[git/debian.git] / t / t7508-status.sh
blobe2ffdacc267c22e369247791e24338a20badf94d
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 git config --global advice.statusuoption false &&
12 mkdir broken &&
13 test_when_finished "rm -fr broken" &&
15 cd broken &&
16 git init &&
17 echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
18 test_expect_code 129 git status -h >usage 2>&1
19 ) &&
20 test_i18ngrep "[Uu]sage" broken/usage
23 test_expect_success 'commit -h in broken repository' '
24 mkdir broken &&
25 test_when_finished "rm -fr broken" &&
27 cd broken &&
28 git init &&
29 echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
30 test_expect_code 129 git commit -h >usage 2>&1
31 ) &&
32 test_i18ngrep "[Uu]sage" broken/usage
35 test_expect_success 'setup' '
36 : >tracked &&
37 : >modified &&
38 mkdir dir1 &&
39 : >dir1/tracked &&
40 : >dir1/modified &&
41 mkdir dir2 &&
42 : >dir1/tracked &&
43 : >dir1/modified &&
44 git add . &&
46 git status >output &&
48 test_tick &&
49 git commit -m initial &&
50 : >untracked &&
51 : >dir1/untracked &&
52 : >dir2/untracked &&
53 echo 1 >dir1/modified &&
54 echo 2 >dir2/modified &&
55 echo 3 >dir2/added &&
56 git add dir2/added
59 test_expect_success 'status (1)' '
60 test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output
63 test_expect_success 'status --column' '
64 COLUMNS=50 git status --column="column dense" >output &&
65 cat >expect <<\EOF &&
66 # On branch master
67 # Changes to be committed:
68 # (use "git reset HEAD <file>..." to unstage)
70 # new file: dir2/added
72 # Changes not staged for commit:
73 # (use "git add <file>..." to update what will be committed)
74 # (use "git checkout -- <file>..." to discard changes in working directory)
76 # modified: dir1/modified
78 # Untracked files:
79 # (use "git add <file>..." to include in what will be committed)
81 # dir1/untracked dir2/untracked untracked
82 # dir2/modified output
83 EOF
84 test_i18ncmp expect output
87 cat >expect <<\EOF
88 # On branch master
89 # Changes to be committed:
90 # (use "git reset HEAD <file>..." to unstage)
92 # new file: dir2/added
94 # Changes not staged for commit:
95 # (use "git add <file>..." to update what will be committed)
96 # (use "git checkout -- <file>..." to discard changes in working directory)
98 # modified: dir1/modified
100 # Untracked files:
101 # (use "git add <file>..." to include in what will be committed)
103 # dir1/untracked
104 # dir2/modified
105 # dir2/untracked
106 # expect
107 # output
108 # untracked
111 test_expect_success 'status (2)' '
112 git status >output &&
113 test_i18ncmp expect output
116 cat >expect <<\EOF
117 # On branch master
118 # Changes to be committed:
119 # new file: dir2/added
121 # Changes not staged for commit:
122 # modified: dir1/modified
124 # Untracked files:
125 # dir1/untracked
126 # dir2/modified
127 # dir2/untracked
128 # expect
129 # output
130 # untracked
133 test_expect_success 'status (advice.statusHints false)' '
134 test_config advice.statusHints false &&
135 git status >output &&
136 test_i18ncmp expect output
140 cat >expect <<\EOF
141 M dir1/modified
142 A dir2/added
143 ?? dir1/untracked
144 ?? dir2/modified
145 ?? dir2/untracked
146 ?? expect
147 ?? output
148 ?? untracked
151 test_expect_success 'status -s' '
153 git status -s >output &&
154 test_cmp expect output
158 test_expect_success 'status with gitignore' '
160 echo ".gitignore" &&
161 echo "expect" &&
162 echo "output" &&
163 echo "untracked"
164 } >.gitignore &&
166 cat >expect <<-\EOF &&
167 M dir1/modified
168 A dir2/added
169 ?? dir2/modified
171 git status -s >output &&
172 test_cmp expect output &&
174 cat >expect <<-\EOF &&
175 M dir1/modified
176 A dir2/added
177 ?? dir2/modified
178 !! .gitignore
179 !! dir1/untracked
180 !! dir2/untracked
181 !! expect
182 !! output
183 !! untracked
185 git status -s --ignored >output &&
186 test_cmp expect output &&
188 cat >expect <<-\EOF &&
189 # On branch master
190 # Changes to be committed:
191 # (use "git reset HEAD <file>..." to unstage)
193 # new file: dir2/added
195 # Changes not staged for commit:
196 # (use "git add <file>..." to update what will be committed)
197 # (use "git checkout -- <file>..." to discard changes in working directory)
199 # modified: dir1/modified
201 # Untracked files:
202 # (use "git add <file>..." to include in what will be committed)
204 # dir2/modified
205 # Ignored files:
206 # (use "git add -f <file>..." to include in what will be committed)
208 # .gitignore
209 # dir1/untracked
210 # dir2/untracked
211 # expect
212 # output
213 # untracked
215 git status --ignored >output &&
216 test_i18ncmp expect output
219 test_expect_success 'status with gitignore (nothing untracked)' '
221 echo ".gitignore" &&
222 echo "expect" &&
223 echo "dir2/modified" &&
224 echo "output" &&
225 echo "untracked"
226 } >.gitignore &&
228 cat >expect <<-\EOF &&
229 M dir1/modified
230 A dir2/added
232 git status -s >output &&
233 test_cmp expect output &&
235 cat >expect <<-\EOF &&
236 M dir1/modified
237 A dir2/added
238 !! .gitignore
239 !! dir1/untracked
240 !! dir2/modified
241 !! dir2/untracked
242 !! expect
243 !! output
244 !! untracked
246 git status -s --ignored >output &&
247 test_cmp expect output &&
249 cat >expect <<-\EOF &&
250 # On branch master
251 # Changes to be committed:
252 # (use "git reset HEAD <file>..." to unstage)
254 # new file: dir2/added
256 # Changes not staged for commit:
257 # (use "git add <file>..." to update what will be committed)
258 # (use "git checkout -- <file>..." to discard changes in working directory)
260 # modified: dir1/modified
262 # Ignored files:
263 # (use "git add -f <file>..." to include in what will be committed)
265 # .gitignore
266 # dir1/untracked
267 # dir2/modified
268 # dir2/untracked
269 # expect
270 # output
271 # untracked
273 git status --ignored >output &&
274 test_i18ncmp expect output
277 rm -f .gitignore
279 cat >expect <<\EOF
280 ## master
281 M dir1/modified
282 A dir2/added
283 ?? dir1/untracked
284 ?? dir2/modified
285 ?? dir2/untracked
286 ?? expect
287 ?? output
288 ?? untracked
291 test_expect_success 'status -s -b' '
293 git status -s -b >output &&
294 test_cmp expect output
298 test_expect_success 'status -s -z -b' '
299 tr "\\n" Q <expect >expect.q &&
300 mv expect.q expect &&
301 git status -s -z -b >output &&
302 nul_to_q <output >output.q &&
303 mv output.q output &&
304 test_cmp expect output
307 test_expect_success 'setup dir3' '
308 mkdir dir3 &&
309 : >dir3/untracked1 &&
310 : >dir3/untracked2
313 cat >expect <<EOF
314 # On branch master
315 # Changes to be committed:
316 # (use "git reset HEAD <file>..." to unstage)
318 # new file: dir2/added
320 # Changes not staged for commit:
321 # (use "git add <file>..." to update what will be committed)
322 # (use "git checkout -- <file>..." to discard changes in working directory)
324 # modified: dir1/modified
326 # Untracked files not listed (use -u option to show untracked files)
328 test_expect_success 'status -uno' '
329 git status -uno >output &&
330 test_i18ncmp expect output
333 test_expect_success 'status (status.showUntrackedFiles no)' '
334 test_config status.showuntrackedfiles no &&
335 git status >output &&
336 test_i18ncmp expect output
339 cat >expect <<EOF
340 # On branch master
341 # Changes to be committed:
342 # new file: dir2/added
344 # Changes not staged for commit:
345 # modified: dir1/modified
347 # Untracked files not listed
349 test_expect_success 'status -uno (advice.statusHints false)' '
350 test_config advice.statusHints false &&
351 git status -uno >output &&
352 test_i18ncmp expect output
355 cat >expect << EOF
356 M dir1/modified
357 A dir2/added
359 test_expect_success 'status -s -uno' '
360 git status -s -uno >output &&
361 test_cmp expect output
364 test_expect_success 'status -s (status.showUntrackedFiles no)' '
365 git config status.showuntrackedfiles no
366 git status -s >output &&
367 test_cmp expect output
370 cat >expect <<EOF
371 # On branch master
372 # Changes to be committed:
373 # (use "git reset HEAD <file>..." to unstage)
375 # new file: dir2/added
377 # Changes not staged for commit:
378 # (use "git add <file>..." to update what will be committed)
379 # (use "git checkout -- <file>..." to discard changes in working directory)
381 # modified: dir1/modified
383 # Untracked files:
384 # (use "git add <file>..." to include in what will be committed)
386 # dir1/untracked
387 # dir2/modified
388 # dir2/untracked
389 # dir3/
390 # expect
391 # output
392 # untracked
394 test_expect_success 'status -unormal' '
395 git status -unormal >output &&
396 test_i18ncmp expect output
399 test_expect_success 'status (status.showUntrackedFiles normal)' '
400 test_config status.showuntrackedfiles normal
401 git status >output &&
402 test_i18ncmp expect output
405 cat >expect <<EOF
406 M dir1/modified
407 A dir2/added
408 ?? dir1/untracked
409 ?? dir2/modified
410 ?? dir2/untracked
411 ?? dir3/
412 ?? expect
413 ?? output
414 ?? untracked
416 test_expect_success 'status -s -unormal' '
417 git status -s -unormal >output &&
418 test_cmp expect output
421 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
422 git config status.showuntrackedfiles normal
423 git status -s >output &&
424 test_cmp expect output
427 cat >expect <<EOF
428 # On branch master
429 # Changes to be committed:
430 # (use "git reset HEAD <file>..." to unstage)
432 # new file: dir2/added
434 # Changes not staged for commit:
435 # (use "git add <file>..." to update what will be committed)
436 # (use "git checkout -- <file>..." to discard changes in working directory)
438 # modified: dir1/modified
440 # Untracked files:
441 # (use "git add <file>..." to include in what will be committed)
443 # dir1/untracked
444 # dir2/modified
445 # dir2/untracked
446 # dir3/untracked1
447 # dir3/untracked2
448 # expect
449 # output
450 # untracked
452 test_expect_success 'status -uall' '
453 git status -uall >output &&
454 test_i18ncmp expect output
457 test_expect_success 'status (status.showUntrackedFiles all)' '
458 test_config status.showuntrackedfiles all
459 git status >output &&
460 test_i18ncmp expect output
463 test_expect_success 'teardown dir3' '
464 rm -rf dir3
467 cat >expect <<EOF
468 M dir1/modified
469 A dir2/added
470 ?? dir1/untracked
471 ?? dir2/modified
472 ?? dir2/untracked
473 ?? expect
474 ?? output
475 ?? untracked
477 test_expect_success 'status -s -uall' '
478 git config --unset status.showuntrackedfiles
479 git status -s -uall >output &&
480 test_cmp expect output
482 test_expect_success 'status -s (status.showUntrackedFiles all)' '
483 test_config status.showuntrackedfiles all &&
484 git status -s >output &&
485 rm -rf dir3 &&
486 test_cmp expect output
489 cat >expect <<\EOF
490 # On branch master
491 # Changes to be committed:
492 # (use "git reset HEAD <file>..." to unstage)
494 # new file: ../dir2/added
496 # Changes not staged for commit:
497 # (use "git add <file>..." to update what will be committed)
498 # (use "git checkout -- <file>..." to discard changes in working directory)
500 # modified: modified
502 # Untracked files:
503 # (use "git add <file>..." to include in what will be committed)
505 # untracked
506 # ../dir2/modified
507 # ../dir2/untracked
508 # ../expect
509 # ../output
510 # ../untracked
513 test_expect_success 'status with relative paths' '
514 (cd dir1 && git status) >output &&
515 test_i18ncmp expect output
518 cat >expect <<\EOF
519 M modified
520 A ../dir2/added
521 ?? untracked
522 ?? ../dir2/modified
523 ?? ../dir2/untracked
524 ?? ../expect
525 ?? ../output
526 ?? ../untracked
528 test_expect_success 'status -s with relative paths' '
530 (cd dir1 && git status -s) >output &&
531 test_cmp expect output
535 cat >expect <<\EOF
536 M dir1/modified
537 A dir2/added
538 ?? dir1/untracked
539 ?? dir2/modified
540 ?? dir2/untracked
541 ?? expect
542 ?? output
543 ?? untracked
546 test_expect_success 'status --porcelain ignores relative paths setting' '
548 (cd dir1 && git status --porcelain) >output &&
549 test_cmp expect output
553 test_expect_success 'setup unique colors' '
555 git config status.color.untracked blue &&
556 git config status.color.branch green
560 cat >expect <<\EOF
561 # On branch <GREEN>master<RESET>
562 # Changes to be committed:
563 # (use "git reset HEAD <file>..." to unstage)
565 # <GREEN>new file: dir2/added<RESET>
567 # Changes not staged for commit:
568 # (use "git add <file>..." to update what will be committed)
569 # (use "git checkout -- <file>..." to discard changes in working directory)
571 # <RED>modified: dir1/modified<RESET>
573 # Untracked files:
574 # (use "git add <file>..." to include in what will be committed)
576 # <BLUE>dir1/untracked<RESET>
577 # <BLUE>dir2/modified<RESET>
578 # <BLUE>dir2/untracked<RESET>
579 # <BLUE>expect<RESET>
580 # <BLUE>output<RESET>
581 # <BLUE>untracked<RESET>
584 test_expect_success 'status with color.ui' '
585 test_config color.ui always &&
586 git status | test_decode_color >output &&
587 test_i18ncmp expect output
590 test_expect_success 'status with color.status' '
591 test_config color.status always &&
592 git status | test_decode_color >output &&
593 test_i18ncmp expect output
596 cat >expect <<\EOF
597 <RED>M<RESET> dir1/modified
598 <GREEN>A<RESET> dir2/added
599 <BLUE>??<RESET> dir1/untracked
600 <BLUE>??<RESET> dir2/modified
601 <BLUE>??<RESET> dir2/untracked
602 <BLUE>??<RESET> expect
603 <BLUE>??<RESET> output
604 <BLUE>??<RESET> untracked
607 test_expect_success 'status -s with color.ui' '
609 git config color.ui always &&
610 git status -s | test_decode_color >output &&
611 test_cmp expect output
615 test_expect_success 'status -s with color.status' '
617 git config --unset color.ui &&
618 git config color.status always &&
619 git status -s | test_decode_color >output &&
620 test_cmp expect output
624 cat >expect <<\EOF
625 ## <GREEN>master<RESET>
626 <RED>M<RESET> dir1/modified
627 <GREEN>A<RESET> dir2/added
628 <BLUE>??<RESET> dir1/untracked
629 <BLUE>??<RESET> dir2/modified
630 <BLUE>??<RESET> dir2/untracked
631 <BLUE>??<RESET> expect
632 <BLUE>??<RESET> output
633 <BLUE>??<RESET> untracked
636 test_expect_success 'status -s -b with color.status' '
638 git status -s -b | test_decode_color >output &&
639 test_cmp expect output
643 cat >expect <<\EOF
644 M dir1/modified
645 A dir2/added
646 ?? dir1/untracked
647 ?? dir2/modified
648 ?? dir2/untracked
649 ?? expect
650 ?? output
651 ?? untracked
654 test_expect_success 'status --porcelain ignores color.ui' '
656 git config --unset color.status &&
657 git config color.ui always &&
658 git status --porcelain | test_decode_color >output &&
659 test_cmp expect output
663 test_expect_success 'status --porcelain ignores color.status' '
665 git config --unset color.ui &&
666 git config color.status always &&
667 git status --porcelain | test_decode_color >output &&
668 test_cmp expect output
672 # recover unconditionally from color tests
673 git config --unset color.status
674 git config --unset color.ui
676 test_expect_success 'status --porcelain respects -b' '
678 git status --porcelain -b >output &&
680 echo "## master" &&
681 cat expect
682 } >tmp &&
683 mv tmp expect &&
684 test_cmp expect output
688 cat >expect <<\EOF
689 # On branch master
690 # Changes to be committed:
691 # (use "git reset HEAD <file>..." to unstage)
693 # new file: dir2/added
695 # Changes not staged for commit:
696 # (use "git add <file>..." to update what will be committed)
697 # (use "git checkout -- <file>..." to discard changes in working directory)
699 # modified: dir1/modified
701 # Untracked files:
702 # (use "git add <file>..." to include in what will be committed)
704 # dir1/untracked
705 # dir2/modified
706 # dir2/untracked
707 # expect
708 # output
709 # untracked
713 test_expect_success 'status without relative paths' '
715 test_config status.relativePaths false &&
716 (cd dir1 && git status) >output &&
717 test_i18ncmp expect output
721 cat >expect <<\EOF
722 M dir1/modified
723 A dir2/added
724 ?? dir1/untracked
725 ?? dir2/modified
726 ?? dir2/untracked
727 ?? expect
728 ?? output
729 ?? untracked
732 test_expect_success 'status -s without relative paths' '
734 test_config status.relativePaths false &&
735 (cd dir1 && git status -s) >output &&
736 test_cmp expect output
740 cat <<EOF >expect
741 # On branch master
742 # Changes to be committed:
743 # (use "git reset HEAD <file>..." to unstage)
745 # modified: dir1/modified
747 # Untracked files:
748 # (use "git add <file>..." to include in what will be committed)
750 # dir1/untracked
751 # dir2/
752 # expect
753 # output
754 # untracked
756 test_expect_success 'dry-run of partial commit excluding new file in index' '
757 git commit --dry-run dir1/modified >output &&
758 test_i18ncmp expect output
761 cat >expect <<EOF
762 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
764 test_expect_success 'status refreshes the index' '
765 touch dir2/added &&
766 git status &&
767 git diff-files >output &&
768 test_cmp expect output
771 test_expect_success 'setup status submodule summary' '
772 test_create_repo sm && (
773 cd sm &&
774 >foo &&
775 git add foo &&
776 git commit -m "Add foo"
777 ) &&
778 git add sm
781 cat >expect <<EOF
782 # On branch master
783 # Changes to be committed:
784 # (use "git reset HEAD <file>..." to unstage)
786 # new file: dir2/added
787 # new file: sm
789 # Changes not staged for commit:
790 # (use "git add <file>..." to update what will be committed)
791 # (use "git checkout -- <file>..." to discard changes in working directory)
793 # modified: dir1/modified
795 # Untracked files:
796 # (use "git add <file>..." to include in what will be committed)
798 # dir1/untracked
799 # dir2/modified
800 # dir2/untracked
801 # expect
802 # output
803 # untracked
805 test_expect_success 'status submodule summary is disabled by default' '
806 git status >output &&
807 test_i18ncmp expect output
810 # we expect the same as the previous test
811 test_expect_success 'status --untracked-files=all does not show submodule' '
812 git status --untracked-files=all >output &&
813 test_i18ncmp expect output
816 cat >expect <<EOF
817 M dir1/modified
818 A dir2/added
819 A sm
820 ?? dir1/untracked
821 ?? dir2/modified
822 ?? dir2/untracked
823 ?? expect
824 ?? output
825 ?? untracked
827 test_expect_success 'status -s submodule summary is disabled by default' '
828 git status -s >output &&
829 test_cmp expect output
832 # we expect the same as the previous test
833 test_expect_success 'status -s --untracked-files=all does not show submodule' '
834 git status -s --untracked-files=all >output &&
835 test_cmp expect output
838 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
840 cat >expect <<EOF
841 # On branch master
842 # Changes to be committed:
843 # (use "git reset HEAD <file>..." to unstage)
845 # new file: dir2/added
846 # new file: sm
848 # Changes not staged for commit:
849 # (use "git add <file>..." to update what will be committed)
850 # (use "git checkout -- <file>..." to discard changes in working directory)
852 # modified: dir1/modified
854 # Submodule changes to be committed:
856 # * sm 0000000...$head (1):
857 # > Add foo
859 # Untracked files:
860 # (use "git add <file>..." to include in what will be committed)
862 # dir1/untracked
863 # dir2/modified
864 # dir2/untracked
865 # expect
866 # output
867 # untracked
869 test_expect_success 'status submodule summary' '
870 git config status.submodulesummary 10 &&
871 git status >output &&
872 test_i18ncmp expect output
875 cat >expect <<EOF
876 M dir1/modified
877 A dir2/added
878 A sm
879 ?? dir1/untracked
880 ?? dir2/modified
881 ?? dir2/untracked
882 ?? expect
883 ?? output
884 ?? untracked
886 test_expect_success 'status -s submodule summary' '
887 git status -s >output &&
888 test_cmp expect output
891 cat >expect <<EOF
892 # On branch master
893 # Changes not staged for commit:
894 # (use "git add <file>..." to update what will be committed)
895 # (use "git checkout -- <file>..." to discard changes in working directory)
897 # modified: dir1/modified
899 # Untracked files:
900 # (use "git add <file>..." to include in what will be committed)
902 # dir1/untracked
903 # dir2/modified
904 # dir2/untracked
905 # expect
906 # output
907 # untracked
908 no changes added to commit (use "git add" and/or "git commit -a")
910 test_expect_success 'status submodule summary (clean submodule): commit' '
911 git commit -m "commit submodule" &&
912 git config status.submodulesummary 10 &&
913 test_must_fail git commit --dry-run >output &&
914 test_i18ncmp expect output &&
915 git status >output &&
916 test_i18ncmp expect output
919 cat >expect <<EOF
920 M dir1/modified
921 ?? dir1/untracked
922 ?? dir2/modified
923 ?? dir2/untracked
924 ?? expect
925 ?? output
926 ?? untracked
928 test_expect_success 'status -s submodule summary (clean submodule)' '
929 git status -s >output &&
930 test_cmp expect output
933 test_expect_success 'status -z implies porcelain' '
934 git status --porcelain |
935 "$PERL_PATH" -pe "s/\012/\000/g" >expect &&
936 git status -z >output &&
937 test_cmp expect output
940 cat >expect <<EOF
941 # On branch master
942 # Changes to be committed:
943 # (use "git reset HEAD^1 <file>..." to unstage)
945 # new file: dir2/added
946 # new file: sm
948 # Changes not staged for commit:
949 # (use "git add <file>..." to update what will be committed)
950 # (use "git checkout -- <file>..." to discard changes in working directory)
952 # modified: dir1/modified
954 # Submodule changes to be committed:
956 # * sm 0000000...$head (1):
957 # > Add foo
959 # Untracked files:
960 # (use "git add <file>..." to include in what will be committed)
962 # dir1/untracked
963 # dir2/modified
964 # dir2/untracked
965 # expect
966 # output
967 # untracked
969 test_expect_success 'commit --dry-run submodule summary (--amend)' '
970 git config status.submodulesummary 10 &&
971 git commit --dry-run --amend >output &&
972 test_i18ncmp expect output
975 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
977 chmod a-w .git &&
978 # make dir1/tracked stat-dirty
979 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
980 git status -s >output &&
981 ! grep dir1/tracked output &&
982 # make sure "status" succeeded without writing index out
983 git diff-files | grep dir1/tracked
985 status=$?
986 chmod 775 .git
987 (exit $status)
990 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
991 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
992 touch .gitmodules
994 cat > expect << EOF
995 # On branch master
996 # Changes to be committed:
997 # (use "git reset HEAD <file>..." to unstage)
999 # modified: sm
1001 # Changes not staged for commit:
1002 # (use "git add <file>..." to update what will be committed)
1003 # (use "git checkout -- <file>..." to discard changes in working directory)
1005 # modified: dir1/modified
1007 # Submodule changes to be committed:
1009 # * sm $head...$new_head (1):
1010 # > Add bar
1012 # Untracked files:
1013 # (use "git add <file>..." to include in what will be committed)
1015 # .gitmodules
1016 # dir1/untracked
1017 # dir2/modified
1018 # dir2/untracked
1019 # expect
1020 # output
1021 # untracked
1024 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1025 echo modified sm/untracked &&
1026 git status --ignore-submodules=untracked >output &&
1027 test_i18ncmp expect output
1030 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1031 test_config diff.ignoreSubmodules dirty &&
1032 git status >output &&
1033 test_i18ncmp expect output &&
1034 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1035 git config --add -f .gitmodules submodule.subname.path sm &&
1036 git status >output &&
1037 test_i18ncmp expect output &&
1038 git config -f .gitmodules --remove-section submodule.subname
1041 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1042 git config --add -f .gitmodules submodule.subname.ignore none &&
1043 git config --add -f .gitmodules submodule.subname.path sm &&
1044 git config --add submodule.subname.ignore untracked &&
1045 git config --add submodule.subname.path sm &&
1046 git status >output &&
1047 test_i18ncmp expect output &&
1048 git config --remove-section submodule.subname &&
1049 git config --remove-section -f .gitmodules submodule.subname
1052 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1053 git status --ignore-submodules=dirty >output &&
1054 test_i18ncmp expect output
1057 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1058 test_config diff.ignoreSubmodules dirty &&
1059 git status >output &&
1060 ! test -s actual &&
1061 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1062 git config --add -f .gitmodules submodule.subname.path sm &&
1063 git status >output &&
1064 test_i18ncmp expect output &&
1065 git config -f .gitmodules --remove-section submodule.subname
1068 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1069 git config --add -f .gitmodules submodule.subname.ignore none &&
1070 git config --add -f .gitmodules submodule.subname.path sm &&
1071 git config --add submodule.subname.ignore dirty &&
1072 git config --add submodule.subname.path sm &&
1073 git status >output &&
1074 test_i18ncmp expect output &&
1075 git config --remove-section submodule.subname &&
1076 git config -f .gitmodules --remove-section submodule.subname
1079 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1080 echo modified >sm/foo &&
1081 git status --ignore-submodules=dirty >output &&
1082 test_i18ncmp expect output
1085 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
1086 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1087 git config --add -f .gitmodules submodule.subname.path sm &&
1088 git status >output &&
1089 test_i18ncmp expect output &&
1090 git config -f .gitmodules --remove-section submodule.subname
1093 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
1094 git config --add -f .gitmodules submodule.subname.ignore none &&
1095 git config --add -f .gitmodules submodule.subname.path sm &&
1096 git config --add submodule.subname.ignore dirty &&
1097 git config --add submodule.subname.path sm &&
1098 git status >output &&
1099 test_i18ncmp expect output &&
1100 git config --remove-section submodule.subname &&
1101 git config -f .gitmodules --remove-section submodule.subname
1104 cat > expect << EOF
1105 # On branch master
1106 # Changes to be committed:
1107 # (use "git reset HEAD <file>..." to unstage)
1109 # modified: sm
1111 # Changes not staged for commit:
1112 # (use "git add <file>..." to update what will be committed)
1113 # (use "git checkout -- <file>..." to discard changes in working directory)
1114 # (commit or discard the untracked or modified content in submodules)
1116 # modified: dir1/modified
1117 # modified: sm (modified content)
1119 # Submodule changes to be committed:
1121 # * sm $head...$new_head (1):
1122 # > Add bar
1124 # Untracked files:
1125 # (use "git add <file>..." to include in what will be committed)
1127 # .gitmodules
1128 # dir1/untracked
1129 # dir2/modified
1130 # dir2/untracked
1131 # expect
1132 # output
1133 # untracked
1136 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1137 git status --ignore-submodules=untracked > output &&
1138 test_i18ncmp expect output
1141 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
1142 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1143 git config --add -f .gitmodules submodule.subname.path sm &&
1144 git status >output &&
1145 test_i18ncmp expect output &&
1146 git config -f .gitmodules --remove-section submodule.subname
1149 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1150 git config --add -f .gitmodules submodule.subname.ignore none &&
1151 git config --add -f .gitmodules submodule.subname.path sm &&
1152 git config --add submodule.subname.ignore untracked &&
1153 git config --add submodule.subname.path sm &&
1154 git status >output &&
1155 test_i18ncmp expect output &&
1156 git config --remove-section submodule.subname &&
1157 git config -f .gitmodules --remove-section submodule.subname
1160 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1162 cat > expect << EOF
1163 # On branch master
1164 # Changes to be committed:
1165 # (use "git reset HEAD <file>..." to unstage)
1167 # modified: sm
1169 # Changes not staged for commit:
1170 # (use "git add <file>..." to update what will be committed)
1171 # (use "git checkout -- <file>..." to discard changes in working directory)
1173 # modified: dir1/modified
1174 # modified: sm (new commits)
1176 # Submodule changes to be committed:
1178 # * sm $head...$new_head (1):
1179 # > Add bar
1181 # Submodules changed but not updated:
1183 # * sm $new_head...$head2 (1):
1184 # > 2nd commit
1186 # Untracked files:
1187 # (use "git add <file>..." to include in what will be committed)
1189 # .gitmodules
1190 # dir1/untracked
1191 # dir2/modified
1192 # dir2/untracked
1193 # expect
1194 # output
1195 # untracked
1198 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1199 git status --ignore-submodules=untracked > output &&
1200 test_i18ncmp expect output
1203 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1204 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1205 git config --add -f .gitmodules submodule.subname.path sm &&
1206 git status >output &&
1207 test_i18ncmp expect output &&
1208 git config -f .gitmodules --remove-section submodule.subname
1211 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1212 git config --add -f .gitmodules submodule.subname.ignore none &&
1213 git config --add -f .gitmodules submodule.subname.path sm &&
1214 git config --add submodule.subname.ignore untracked &&
1215 git config --add submodule.subname.path sm &&
1216 git status >output &&
1217 test_i18ncmp expect output &&
1218 git config --remove-section submodule.subname &&
1219 git config -f .gitmodules --remove-section submodule.subname
1222 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1223 git status --ignore-submodules=dirty > output &&
1224 test_i18ncmp expect output
1226 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1227 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1228 git config --add -f .gitmodules submodule.subname.path sm &&
1229 git status >output &&
1230 test_i18ncmp expect output &&
1231 git config -f .gitmodules --remove-section submodule.subname
1234 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1235 git config --add -f .gitmodules submodule.subname.ignore none &&
1236 git config --add -f .gitmodules submodule.subname.path sm &&
1237 git config --add submodule.subname.ignore dirty &&
1238 git config --add submodule.subname.path sm &&
1239 git status >output &&
1240 test_i18ncmp expect output &&
1241 git config --remove-section submodule.subname &&
1242 git config -f .gitmodules --remove-section submodule.subname
1245 cat > expect << EOF
1246 ; On branch master
1247 ; Changes to be committed:
1248 ; (use "git reset HEAD <file>..." to unstage)
1250 ; modified: sm
1252 ; Changes not staged for commit:
1253 ; (use "git add <file>..." to update what will be committed)
1254 ; (use "git checkout -- <file>..." to discard changes in working directory)
1256 ; modified: dir1/modified
1257 ; modified: sm (new commits)
1259 ; Submodule changes to be committed:
1261 ; * sm $head...$new_head (1):
1262 ; > Add bar
1264 ; Submodules changed but not updated:
1266 ; * sm $new_head...$head2 (1):
1267 ; > 2nd commit
1269 ; Untracked files:
1270 ; (use "git add <file>..." to include in what will be committed)
1272 ; .gitmodules
1273 ; dir1/untracked
1274 ; dir2/modified
1275 ; dir2/untracked
1276 ; expect
1277 ; output
1278 ; untracked
1281 test_expect_success "status (core.commentchar with submodule summary)" '
1282 test_config core.commentchar ";" &&
1283 git status >output &&
1284 test_i18ncmp expect output
1287 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1288 test_config core.commentchar ";;" &&
1289 git status >output &&
1290 test_i18ncmp expect output
1293 cat > expect << EOF
1294 # On branch master
1295 # Changes not staged for commit:
1296 # (use "git add <file>..." to update what will be committed)
1297 # (use "git checkout -- <file>..." to discard changes in working directory)
1299 # modified: dir1/modified
1301 # Untracked files:
1302 # (use "git add <file>..." to include in what will be committed)
1304 # .gitmodules
1305 # dir1/untracked
1306 # dir2/modified
1307 # dir2/untracked
1308 # expect
1309 # output
1310 # untracked
1311 no changes added to commit (use "git add" and/or "git commit -a")
1314 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1315 git status --ignore-submodules=all > output &&
1316 test_i18ncmp expect output
1319 test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1320 git config --add -f .gitmodules submodule.subname.ignore all &&
1321 git config --add -f .gitmodules submodule.subname.path sm &&
1322 git status > output &&
1323 test_cmp expect output &&
1324 git config -f .gitmodules --remove-section submodule.subname
1327 test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1328 git config --add -f .gitmodules submodule.subname.ignore none &&
1329 git config --add -f .gitmodules submodule.subname.path sm &&
1330 git config --add submodule.subname.ignore all &&
1331 git config --add submodule.subname.path sm &&
1332 git status > output &&
1333 test_cmp expect output &&
1334 git config --remove-section submodule.subname &&
1335 git config -f .gitmodules --remove-section submodule.subname
1338 test_done