tests: don't set status.displayCommentPrefix file-wide
[git.git] / t / t7508-status.sh
blobd0444d3054d5126c7cd73f421236f0f0fa82b241
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 strip_comments () {
64 sed "s/^\# //; s/^\#$//; s/^#\t/\t/" <"$1" >"$1".tmp &&
65 rm "$1" && mv "$1".tmp "$1"
68 test_expect_success 'status --column' '
69 cat >expect <<\EOF &&
70 # On branch master
71 # Changes to be committed:
72 # (use "git reset HEAD <file>..." to unstage)
74 # new file: dir2/added
76 # Changes not staged for commit:
77 # (use "git add <file>..." to update what will be committed)
78 # (use "git checkout -- <file>..." to discard changes in working directory)
80 # modified: dir1/modified
82 # Untracked files:
83 # (use "git add <file>..." to include in what will be committed)
85 # dir1/untracked dir2/untracked output
86 # dir2/modified expect untracked
87 EOF
88 COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
89 test_i18ncmp expect output
92 test_expect_success 'status --column status.displayCommentPrefix=false' '
93 strip_comments expect &&
94 COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
95 test_i18ncmp expect output
98 cat >expect <<\EOF
99 # On branch master
100 # Changes to be committed:
101 # (use "git reset HEAD <file>..." to unstage)
103 # new file: dir2/added
105 # Changes not staged for commit:
106 # (use "git add <file>..." to update what will be committed)
107 # (use "git checkout -- <file>..." to discard changes in working directory)
109 # modified: dir1/modified
111 # Untracked files:
112 # (use "git add <file>..." to include in what will be committed)
114 # dir1/untracked
115 # dir2/modified
116 # dir2/untracked
117 # expect
118 # output
119 # untracked
122 test_expect_success 'status with status.displayCommentPrefix=true' '
123 git -c status.displayCommentPrefix=true status >output &&
124 test_i18ncmp expect output
127 test_expect_success 'status with status.displayCommentPrefix=false' '
128 strip_comments expect &&
129 git -c status.displayCommentPrefix=false status >output &&
130 test_i18ncmp expect output
133 test_expect_success 'setup fake editor' '
134 cat >.git/editor <<-\EOF &&
135 #! /bin/sh
136 cp "$1" output
138 chmod 755 .git/editor
141 commit_template_commented () {
143 EDITOR=.git/editor &&
144 export EDITOR &&
145 # Fails due to empty message
146 test_must_fail git commit
147 ) &&
148 ! grep '^[^#]' output
151 test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
152 commit_template_commented
155 cat >expect <<\EOF
156 On branch master
157 Changes to be committed:
158 new file: dir2/added
160 Changes not staged for commit:
161 modified: dir1/modified
163 Untracked files:
164 dir1/untracked
165 dir2/modified
166 dir2/untracked
167 expect
168 output
169 untracked
172 test_expect_success 'status (advice.statusHints false)' '
173 test_config advice.statusHints false &&
174 git status >output &&
175 test_i18ncmp expect output
179 cat >expect <<\EOF
180 M dir1/modified
181 A dir2/added
182 ?? dir1/untracked
183 ?? dir2/modified
184 ?? dir2/untracked
185 ?? expect
186 ?? output
187 ?? untracked
190 test_expect_success 'status -s' '
192 git status -s >output &&
193 test_cmp expect output
197 test_expect_success 'status with gitignore' '
199 echo ".gitignore" &&
200 echo "expect" &&
201 echo "output" &&
202 echo "untracked"
203 } >.gitignore &&
205 cat >expect <<-\EOF &&
206 M dir1/modified
207 A dir2/added
208 ?? dir2/modified
210 git status -s >output &&
211 test_cmp expect output &&
213 cat >expect <<-\EOF &&
214 M dir1/modified
215 A dir2/added
216 ?? dir2/modified
217 !! .gitignore
218 !! dir1/untracked
219 !! dir2/untracked
220 !! expect
221 !! output
222 !! untracked
224 git status -s --ignored >output &&
225 test_cmp expect output &&
227 cat >expect <<\EOF &&
228 On branch master
229 Changes to be committed:
230 (use "git reset HEAD <file>..." to unstage)
232 new file: dir2/added
234 Changes not staged for commit:
235 (use "git add <file>..." to update what will be committed)
236 (use "git checkout -- <file>..." to discard changes in working directory)
238 modified: dir1/modified
240 Untracked files:
241 (use "git add <file>..." to include in what will be committed)
243 dir2/modified
244 Ignored files:
245 (use "git add -f <file>..." to include in what will be committed)
247 .gitignore
248 dir1/untracked
249 dir2/untracked
250 expect
251 output
252 untracked
254 git status --ignored >output &&
255 test_i18ncmp expect output
258 test_expect_success 'status with gitignore (nothing untracked)' '
260 echo ".gitignore" &&
261 echo "expect" &&
262 echo "dir2/modified" &&
263 echo "output" &&
264 echo "untracked"
265 } >.gitignore &&
267 cat >expect <<-\EOF &&
268 M dir1/modified
269 A dir2/added
271 git status -s >output &&
272 test_cmp expect output &&
274 cat >expect <<-\EOF &&
275 M dir1/modified
276 A dir2/added
277 !! .gitignore
278 !! dir1/untracked
279 !! dir2/modified
280 !! dir2/untracked
281 !! expect
282 !! output
283 !! untracked
285 git status -s --ignored >output &&
286 test_cmp expect output &&
288 cat >expect <<\EOF &&
289 On branch master
290 Changes to be committed:
291 (use "git reset HEAD <file>..." to unstage)
293 new file: dir2/added
295 Changes not staged for commit:
296 (use "git add <file>..." to update what will be committed)
297 (use "git checkout -- <file>..." to discard changes in working directory)
299 modified: dir1/modified
301 Ignored files:
302 (use "git add -f <file>..." to include in what will be committed)
304 .gitignore
305 dir1/untracked
306 dir2/modified
307 dir2/untracked
308 expect
309 output
310 untracked
312 git status --ignored >output &&
313 test_i18ncmp expect output
316 rm -f .gitignore
318 cat >expect <<\EOF
319 ## master
320 M dir1/modified
321 A dir2/added
322 ?? dir1/untracked
323 ?? dir2/modified
324 ?? dir2/untracked
325 ?? expect
326 ?? output
327 ?? untracked
330 test_expect_success 'status -s -b' '
332 git status -s -b >output &&
333 test_cmp expect output
337 test_expect_success 'status -s -z -b' '
338 tr "\\n" Q <expect >expect.q &&
339 mv expect.q expect &&
340 git status -s -z -b >output &&
341 nul_to_q <output >output.q &&
342 mv output.q output &&
343 test_cmp expect output
346 test_expect_success 'setup dir3' '
347 mkdir dir3 &&
348 : >dir3/untracked1 &&
349 : >dir3/untracked2
352 test_expect_success 'status -uno' '
353 cat >expect <<EOF &&
354 On branch master
355 Changes to be committed:
356 (use "git reset HEAD <file>..." to unstage)
358 new file: dir2/added
360 Changes not staged for commit:
361 (use "git add <file>..." to update what will be committed)
362 (use "git checkout -- <file>..." to discard changes in working directory)
364 modified: dir1/modified
366 Untracked files not listed (use -u option to show untracked files)
368 git status -uno >output &&
369 test_i18ncmp expect output
372 test_expect_success 'status (status.showUntrackedFiles no)' '
373 test_config status.showuntrackedfiles no &&
374 git status >output &&
375 test_i18ncmp expect output
378 test_expect_success 'status -uno (advice.statusHints false)' '
379 cat >expect <<EOF &&
380 On branch master
381 Changes to be committed:
382 new file: dir2/added
384 Changes not staged for commit:
385 modified: dir1/modified
387 Untracked files not listed
389 test_config advice.statusHints false &&
390 git status -uno >output &&
391 test_i18ncmp expect output
394 cat >expect << EOF
395 M dir1/modified
396 A dir2/added
398 test_expect_success 'status -s -uno' '
399 git status -s -uno >output &&
400 test_cmp expect output
403 test_expect_success 'status -s (status.showUntrackedFiles no)' '
404 git config status.showuntrackedfiles no
405 git status -s >output &&
406 test_cmp expect output
409 test_expect_success 'status -unormal' '
410 cat >expect <<EOF &&
411 On branch master
412 Changes to be committed:
413 (use "git reset HEAD <file>..." to unstage)
415 new file: dir2/added
417 Changes not staged for commit:
418 (use "git add <file>..." to update what will be committed)
419 (use "git checkout -- <file>..." to discard changes in working directory)
421 modified: dir1/modified
423 Untracked files:
424 (use "git add <file>..." to include in what will be committed)
426 dir1/untracked
427 dir2/modified
428 dir2/untracked
429 dir3/
430 expect
431 output
432 untracked
434 git status -unormal >output &&
435 test_i18ncmp expect output
438 test_expect_success 'status (status.showUntrackedFiles normal)' '
439 test_config status.showuntrackedfiles normal
440 git status >output &&
441 test_i18ncmp expect output
444 cat >expect <<EOF
445 M dir1/modified
446 A dir2/added
447 ?? dir1/untracked
448 ?? dir2/modified
449 ?? dir2/untracked
450 ?? dir3/
451 ?? expect
452 ?? output
453 ?? untracked
455 test_expect_success 'status -s -unormal' '
456 git status -s -unormal >output &&
457 test_cmp expect output
460 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
461 git config status.showuntrackedfiles normal
462 git status -s >output &&
463 test_cmp expect output
466 test_expect_success 'status -uall' '
467 cat >expect <<EOF &&
468 On branch master
469 Changes to be committed:
470 (use "git reset HEAD <file>..." to unstage)
472 new file: dir2/added
474 Changes not staged for commit:
475 (use "git add <file>..." to update what will be committed)
476 (use "git checkout -- <file>..." to discard changes in working directory)
478 modified: dir1/modified
480 Untracked files:
481 (use "git add <file>..." to include in what will be committed)
483 dir1/untracked
484 dir2/modified
485 dir2/untracked
486 dir3/untracked1
487 dir3/untracked2
488 expect
489 output
490 untracked
492 git status -uall >output &&
493 test_i18ncmp expect output
496 test_expect_success 'status (status.showUntrackedFiles all)' '
497 test_config status.showuntrackedfiles all
498 git status >output &&
499 test_i18ncmp expect output
502 test_expect_success 'teardown dir3' '
503 rm -rf dir3
506 cat >expect <<EOF
507 M dir1/modified
508 A dir2/added
509 ?? dir1/untracked
510 ?? dir2/modified
511 ?? dir2/untracked
512 ?? expect
513 ?? output
514 ?? untracked
516 test_expect_success 'status -s -uall' '
517 git config --unset status.showuntrackedfiles
518 git status -s -uall >output &&
519 test_cmp expect output
521 test_expect_success 'status -s (status.showUntrackedFiles all)' '
522 test_config status.showuntrackedfiles all &&
523 git status -s >output &&
524 rm -rf dir3 &&
525 test_cmp expect output
528 test_expect_success 'status with relative paths' '
529 cat >expect <<\EOF &&
530 On branch master
531 Changes to be committed:
532 (use "git reset HEAD <file>..." to unstage)
534 new file: ../dir2/added
536 Changes not staged for commit:
537 (use "git add <file>..." to update what will be committed)
538 (use "git checkout -- <file>..." to discard changes in working directory)
540 modified: modified
542 Untracked files:
543 (use "git add <file>..." to include in what will be committed)
545 untracked
546 ../dir2/modified
547 ../dir2/untracked
548 ../expect
549 ../output
550 ../untracked
552 (cd dir1 && git status) >output &&
553 test_i18ncmp expect output
556 cat >expect <<\EOF
557 M modified
558 A ../dir2/added
559 ?? untracked
560 ?? ../dir2/modified
561 ?? ../dir2/untracked
562 ?? ../expect
563 ?? ../output
564 ?? ../untracked
566 test_expect_success 'status -s with relative paths' '
568 (cd dir1 && git status -s) >output &&
569 test_cmp expect output
573 cat >expect <<\EOF
574 M dir1/modified
575 A dir2/added
576 ?? dir1/untracked
577 ?? dir2/modified
578 ?? dir2/untracked
579 ?? expect
580 ?? output
581 ?? untracked
584 test_expect_success 'status --porcelain ignores relative paths setting' '
586 (cd dir1 && git status --porcelain) >output &&
587 test_cmp expect output
591 test_expect_success 'setup unique colors' '
593 git config status.color.untracked blue &&
594 git config status.color.branch green
598 test_expect_success 'status with color.ui' '
599 cat >expect <<\EOF &&
600 On branch <GREEN>master<RESET>
601 Changes to be committed:
602 (use "git reset HEAD <file>..." to unstage)
604 <GREEN>new file: dir2/added<RESET>
606 Changes not staged for commit:
607 (use "git add <file>..." to update what will be committed)
608 (use "git checkout -- <file>..." to discard changes in working directory)
610 <RED>modified: dir1/modified<RESET>
612 Untracked files:
613 (use "git add <file>..." to include in what will be committed)
615 <BLUE>dir1/untracked<RESET>
616 <BLUE>dir2/modified<RESET>
617 <BLUE>dir2/untracked<RESET>
618 <BLUE>expect<RESET>
619 <BLUE>output<RESET>
620 <BLUE>untracked<RESET>
622 test_config color.ui always &&
623 git status | test_decode_color >output &&
624 test_i18ncmp expect output
627 test_expect_success 'status with color.status' '
628 test_config color.status always &&
629 git status | test_decode_color >output &&
630 test_i18ncmp expect output
633 cat >expect <<\EOF
634 <RED>M<RESET> dir1/modified
635 <GREEN>A<RESET> dir2/added
636 <BLUE>??<RESET> dir1/untracked
637 <BLUE>??<RESET> dir2/modified
638 <BLUE>??<RESET> dir2/untracked
639 <BLUE>??<RESET> expect
640 <BLUE>??<RESET> output
641 <BLUE>??<RESET> untracked
644 test_expect_success 'status -s with color.ui' '
646 git config color.ui always &&
647 git status -s | test_decode_color >output &&
648 test_cmp expect output
652 test_expect_success 'status -s with color.status' '
654 git config --unset color.ui &&
655 git config color.status always &&
656 git status -s | test_decode_color >output &&
657 test_cmp expect output
661 cat >expect <<\EOF
662 ## <GREEN>master<RESET>
663 <RED>M<RESET> dir1/modified
664 <GREEN>A<RESET> dir2/added
665 <BLUE>??<RESET> dir1/untracked
666 <BLUE>??<RESET> dir2/modified
667 <BLUE>??<RESET> dir2/untracked
668 <BLUE>??<RESET> expect
669 <BLUE>??<RESET> output
670 <BLUE>??<RESET> untracked
673 test_expect_success 'status -s -b with color.status' '
675 git status -s -b | test_decode_color >output &&
676 test_cmp expect output
680 cat >expect <<\EOF
681 M dir1/modified
682 A dir2/added
683 ?? dir1/untracked
684 ?? dir2/modified
685 ?? dir2/untracked
686 ?? expect
687 ?? output
688 ?? untracked
691 test_expect_success 'status --porcelain ignores color.ui' '
693 git config --unset color.status &&
694 git config color.ui always &&
695 git status --porcelain | test_decode_color >output &&
696 test_cmp expect output
700 test_expect_success 'status --porcelain ignores color.status' '
702 git config --unset color.ui &&
703 git config color.status always &&
704 git status --porcelain | test_decode_color >output &&
705 test_cmp expect output
709 # recover unconditionally from color tests
710 git config --unset color.status
711 git config --unset color.ui
713 test_expect_success 'status --porcelain respects -b' '
715 git status --porcelain -b >output &&
717 echo "## master" &&
718 cat expect
719 } >tmp &&
720 mv tmp expect &&
721 test_cmp expect output
727 test_expect_success 'status without relative paths' '
728 cat >expect <<\EOF &&
729 On branch master
730 Changes to be committed:
731 (use "git reset HEAD <file>..." to unstage)
733 new file: dir2/added
735 Changes not staged for commit:
736 (use "git add <file>..." to update what will be committed)
737 (use "git checkout -- <file>..." to discard changes in working directory)
739 modified: dir1/modified
741 Untracked files:
742 (use "git add <file>..." to include in what will be committed)
744 dir1/untracked
745 dir2/modified
746 dir2/untracked
747 expect
748 output
749 untracked
751 test_config status.relativePaths false &&
752 (cd dir1 && git status) >output &&
753 test_i18ncmp expect output
757 cat >expect <<\EOF
758 M dir1/modified
759 A dir2/added
760 ?? dir1/untracked
761 ?? dir2/modified
762 ?? dir2/untracked
763 ?? expect
764 ?? output
765 ?? untracked
768 test_expect_success 'status -s without relative paths' '
770 test_config status.relativePaths false &&
771 (cd dir1 && git status -s) >output &&
772 test_cmp expect output
776 test_expect_success 'dry-run of partial commit excluding new file in index' '
777 cat >expect <<EOF &&
778 On branch master
779 Changes to be committed:
780 (use "git reset HEAD <file>..." to unstage)
782 modified: dir1/modified
784 Untracked files:
785 (use "git add <file>..." to include in what will be committed)
787 dir1/untracked
788 dir2/
789 expect
790 output
791 untracked
793 git commit --dry-run dir1/modified >output &&
794 test_i18ncmp expect output
797 cat >expect <<EOF
798 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
800 test_expect_success 'status refreshes the index' '
801 touch dir2/added &&
802 git status &&
803 git diff-files >output &&
804 test_cmp expect output
807 test_expect_success 'setup status submodule summary' '
808 test_create_repo sm && (
809 cd sm &&
810 >foo &&
811 git add foo &&
812 git commit -m "Add foo"
813 ) &&
814 git add sm
817 test_expect_success 'status submodule summary is disabled by default' '
818 cat >expect <<EOF &&
819 On branch master
820 Changes to be committed:
821 (use "git reset HEAD <file>..." to unstage)
823 new file: dir2/added
824 new file: sm
826 Changes not staged for commit:
827 (use "git add <file>..." to update what will be committed)
828 (use "git checkout -- <file>..." to discard changes in working directory)
830 modified: dir1/modified
832 Untracked files:
833 (use "git add <file>..." to include in what will be committed)
835 dir1/untracked
836 dir2/modified
837 dir2/untracked
838 expect
839 output
840 untracked
842 git status >output &&
843 test_i18ncmp expect output
846 # we expect the same as the previous test
847 test_expect_success 'status --untracked-files=all does not show submodule' '
848 git status --untracked-files=all >output &&
849 test_i18ncmp expect output
852 cat >expect <<EOF
853 M dir1/modified
854 A dir2/added
855 A sm
856 ?? dir1/untracked
857 ?? dir2/modified
858 ?? dir2/untracked
859 ?? expect
860 ?? output
861 ?? untracked
863 test_expect_success 'status -s submodule summary is disabled by default' '
864 git status -s >output &&
865 test_cmp expect output
868 # we expect the same as the previous test
869 test_expect_success 'status -s --untracked-files=all does not show submodule' '
870 git status -s --untracked-files=all >output &&
871 test_cmp expect output
874 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
876 test_expect_success 'status submodule summary' '
877 cat >expect <<EOF &&
878 On branch master
879 Changes to be committed:
880 (use "git reset HEAD <file>..." to unstage)
882 new file: dir2/added
883 new file: sm
885 Changes not staged for commit:
886 (use "git add <file>..." to update what will be committed)
887 (use "git checkout -- <file>..." to discard changes in working directory)
889 modified: dir1/modified
891 Submodule changes to be committed:
893 * sm 0000000...$head (1):
894 > Add foo
896 Untracked files:
897 (use "git add <file>..." to include in what will be committed)
899 dir1/untracked
900 dir2/modified
901 dir2/untracked
902 expect
903 output
904 untracked
906 git config status.submodulesummary 10 &&
907 git status >output &&
908 test_i18ncmp expect output
911 test_expect_success 'status submodule summary with status.displayCommentPrefix=false' '
912 strip_comments expect &&
913 git -c status.displayCommentPrefix=false status >output &&
914 test_i18ncmp expect output
917 test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' '
918 commit_template_commented
921 cat >expect <<EOF
922 M dir1/modified
923 A dir2/added
924 A sm
925 ?? dir1/untracked
926 ?? dir2/modified
927 ?? dir2/untracked
928 ?? expect
929 ?? output
930 ?? untracked
932 test_expect_success 'status -s submodule summary' '
933 git status -s >output &&
934 test_cmp expect output
937 test_expect_success 'status submodule summary (clean submodule): commit' '
938 cat >expect <<EOF &&
939 On branch master
940 Changes not staged for commit:
941 (use "git add <file>..." to update what will be committed)
942 (use "git checkout -- <file>..." to discard changes in working directory)
944 modified: dir1/modified
946 Untracked files:
947 (use "git add <file>..." to include in what will be committed)
949 dir1/untracked
950 dir2/modified
951 dir2/untracked
952 expect
953 output
954 untracked
955 no changes added to commit (use "git add" and/or "git commit -a")
957 git commit -m "commit submodule" &&
958 git config status.submodulesummary 10 &&
959 test_must_fail git commit --dry-run >output &&
960 test_i18ncmp expect output &&
961 git status >output &&
962 test_i18ncmp expect output
965 cat >expect <<EOF
966 M dir1/modified
967 ?? dir1/untracked
968 ?? dir2/modified
969 ?? dir2/untracked
970 ?? expect
971 ?? output
972 ?? untracked
974 test_expect_success 'status -s submodule summary (clean submodule)' '
975 git status -s >output &&
976 test_cmp expect output
979 test_expect_success 'status -z implies porcelain' '
980 git status --porcelain |
981 "$PERL_PATH" -pe "s/\012/\000/g" >expect &&
982 git status -z >output &&
983 test_cmp expect output
986 test_expect_success 'commit --dry-run submodule summary (--amend)' '
987 cat >expect <<EOF &&
988 On branch master
989 Changes to be committed:
990 (use "git reset HEAD^1 <file>..." to unstage)
992 new file: dir2/added
993 new file: sm
995 Changes not staged for commit:
996 (use "git add <file>..." to update what will be committed)
997 (use "git checkout -- <file>..." to discard changes in working directory)
999 modified: dir1/modified
1001 Submodule changes to be committed:
1003 * sm 0000000...$head (1):
1004 > Add foo
1006 Untracked files:
1007 (use "git add <file>..." to include in what will be committed)
1009 dir1/untracked
1010 dir2/modified
1011 dir2/untracked
1012 expect
1013 output
1014 untracked
1016 git config status.submodulesummary 10 &&
1017 git commit --dry-run --amend >output &&
1018 test_i18ncmp expect output
1021 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
1023 chmod a-w .git &&
1024 # make dir1/tracked stat-dirty
1025 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
1026 git status -s >output &&
1027 ! grep dir1/tracked output &&
1028 # make sure "status" succeeded without writing index out
1029 git diff-files | grep dir1/tracked
1031 status=$?
1032 chmod 775 .git
1033 (exit $status)
1036 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
1037 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
1038 touch .gitmodules
1040 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1041 cat > expect << EOF &&
1042 On branch master
1043 Changes to be committed:
1044 (use "git reset HEAD <file>..." to unstage)
1046 modified: sm
1048 Changes not staged for commit:
1049 (use "git add <file>..." to update what will be committed)
1050 (use "git checkout -- <file>..." to discard changes in working directory)
1052 modified: dir1/modified
1054 Submodule changes to be committed:
1056 * sm $head...$new_head (1):
1057 > Add bar
1059 Untracked files:
1060 (use "git add <file>..." to include in what will be committed)
1062 .gitmodules
1063 dir1/untracked
1064 dir2/modified
1065 dir2/untracked
1066 expect
1067 output
1068 untracked
1070 echo modified sm/untracked &&
1071 git status --ignore-submodules=untracked >output &&
1072 test_i18ncmp expect output
1075 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1076 test_config diff.ignoreSubmodules dirty &&
1077 git status >output &&
1078 test_i18ncmp expect output &&
1079 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1080 git config --add -f .gitmodules submodule.subname.path sm &&
1081 git status >output &&
1082 test_i18ncmp expect output &&
1083 git config -f .gitmodules --remove-section submodule.subname
1086 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1087 git config --add -f .gitmodules submodule.subname.ignore none &&
1088 git config --add -f .gitmodules submodule.subname.path sm &&
1089 git config --add submodule.subname.ignore untracked &&
1090 git config --add submodule.subname.path sm &&
1091 git status >output &&
1092 test_i18ncmp expect output &&
1093 git config --remove-section submodule.subname &&
1094 git config --remove-section -f .gitmodules submodule.subname
1097 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1098 git status --ignore-submodules=dirty >output &&
1099 test_i18ncmp expect output
1102 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1103 test_config diff.ignoreSubmodules dirty &&
1104 git status >output &&
1105 ! test -s actual &&
1106 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1107 git config --add -f .gitmodules submodule.subname.path sm &&
1108 git status >output &&
1109 test_i18ncmp expect output &&
1110 git config -f .gitmodules --remove-section submodule.subname
1113 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1114 git config --add -f .gitmodules submodule.subname.ignore none &&
1115 git config --add -f .gitmodules submodule.subname.path sm &&
1116 git config --add submodule.subname.ignore dirty &&
1117 git config --add submodule.subname.path sm &&
1118 git status >output &&
1119 test_i18ncmp expect output &&
1120 git config --remove-section submodule.subname &&
1121 git config -f .gitmodules --remove-section submodule.subname
1124 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1125 echo modified >sm/foo &&
1126 git status --ignore-submodules=dirty >output &&
1127 test_i18ncmp expect output
1130 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
1131 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1132 git config --add -f .gitmodules submodule.subname.path sm &&
1133 git status >output &&
1134 test_i18ncmp expect output &&
1135 git config -f .gitmodules --remove-section submodule.subname
1138 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
1139 git config --add -f .gitmodules submodule.subname.ignore none &&
1140 git config --add -f .gitmodules submodule.subname.path sm &&
1141 git config --add submodule.subname.ignore dirty &&
1142 git config --add submodule.subname.path sm &&
1143 git status >output &&
1144 test_i18ncmp expect output &&
1145 git config --remove-section submodule.subname &&
1146 git config -f .gitmodules --remove-section submodule.subname
1149 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1150 cat > expect << EOF &&
1151 On branch master
1152 Changes to be committed:
1153 (use "git reset HEAD <file>..." to unstage)
1155 modified: sm
1157 Changes not staged for commit:
1158 (use "git add <file>..." to update what will be committed)
1159 (use "git checkout -- <file>..." to discard changes in working directory)
1160 (commit or discard the untracked or modified content in submodules)
1162 modified: dir1/modified
1163 modified: sm (modified content)
1165 Submodule changes to be committed:
1167 * sm $head...$new_head (1):
1168 > Add bar
1170 Untracked files:
1171 (use "git add <file>..." to include in what will be committed)
1173 .gitmodules
1174 dir1/untracked
1175 dir2/modified
1176 dir2/untracked
1177 expect
1178 output
1179 untracked
1181 git status --ignore-submodules=untracked > output &&
1182 test_i18ncmp expect output
1185 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
1186 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1187 git config --add -f .gitmodules submodule.subname.path sm &&
1188 git status >output &&
1189 test_i18ncmp expect output &&
1190 git config -f .gitmodules --remove-section submodule.subname
1193 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1194 git config --add -f .gitmodules submodule.subname.ignore none &&
1195 git config --add -f .gitmodules submodule.subname.path sm &&
1196 git config --add submodule.subname.ignore untracked &&
1197 git config --add submodule.subname.path sm &&
1198 git status >output &&
1199 test_i18ncmp expect output &&
1200 git config --remove-section submodule.subname &&
1201 git config -f .gitmodules --remove-section submodule.subname
1204 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1206 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1207 cat > expect << EOF &&
1208 On branch master
1209 Changes to be committed:
1210 (use "git reset HEAD <file>..." to unstage)
1212 modified: sm
1214 Changes not staged for commit:
1215 (use "git add <file>..." to update what will be committed)
1216 (use "git checkout -- <file>..." to discard changes in working directory)
1218 modified: dir1/modified
1219 modified: sm (new commits)
1221 Submodule changes to be committed:
1223 * sm $head...$new_head (1):
1224 > Add bar
1226 Submodules changed but not updated:
1228 * sm $new_head...$head2 (1):
1229 > 2nd commit
1231 Untracked files:
1232 (use "git add <file>..." to include in what will be committed)
1234 .gitmodules
1235 dir1/untracked
1236 dir2/modified
1237 dir2/untracked
1238 expect
1239 output
1240 untracked
1242 git status --ignore-submodules=untracked > output &&
1243 test_i18ncmp expect output
1246 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1247 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1248 git config --add -f .gitmodules submodule.subname.path sm &&
1249 git status >output &&
1250 test_i18ncmp expect output &&
1251 git config -f .gitmodules --remove-section submodule.subname
1254 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1255 git config --add -f .gitmodules submodule.subname.ignore none &&
1256 git config --add -f .gitmodules submodule.subname.path sm &&
1257 git config --add submodule.subname.ignore untracked &&
1258 git config --add submodule.subname.path sm &&
1259 git status >output &&
1260 test_i18ncmp expect output &&
1261 git config --remove-section submodule.subname &&
1262 git config -f .gitmodules --remove-section submodule.subname
1265 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1266 git status --ignore-submodules=dirty > output &&
1267 test_i18ncmp expect output
1269 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1270 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1271 git config --add -f .gitmodules submodule.subname.path sm &&
1272 git status >output &&
1273 test_i18ncmp expect output &&
1274 git config -f .gitmodules --remove-section submodule.subname
1277 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1278 git config --add -f .gitmodules submodule.subname.ignore none &&
1279 git config --add -f .gitmodules submodule.subname.path sm &&
1280 git config --add submodule.subname.ignore dirty &&
1281 git config --add submodule.subname.path sm &&
1282 git status >output &&
1283 test_i18ncmp expect output &&
1284 git config --remove-section submodule.subname &&
1285 git config -f .gitmodules --remove-section submodule.subname
1288 cat > expect << EOF
1289 ; On branch master
1290 ; Changes to be committed:
1291 ; (use "git reset HEAD <file>..." to unstage)
1293 ; modified: sm
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
1300 ; modified: sm (new commits)
1302 ; Submodule changes to be committed:
1304 ; * sm $head...$new_head (1):
1305 ; > Add bar
1307 ; Submodules changed but not updated:
1309 ; * sm $new_head...$head2 (1):
1310 ; > 2nd commit
1312 ; Untracked files:
1313 ; (use "git add <file>..." to include in what will be committed)
1315 ; .gitmodules
1316 ; dir1/untracked
1317 ; dir2/modified
1318 ; dir2/untracked
1319 ; expect
1320 ; output
1321 ; untracked
1324 test_expect_success "status (core.commentchar with submodule summary)" '
1325 test_config core.commentchar ";" &&
1326 git -c status.displayCommentPrefix=true status >output &&
1327 test_i18ncmp expect output
1330 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1331 test_config core.commentchar ";;" &&
1332 git -c status.displayCommentPrefix=true status >output &&
1333 test_i18ncmp expect output
1336 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1337 cat > expect << EOF &&
1338 On branch master
1339 Changes not staged for commit:
1340 (use "git add <file>..." to update what will be committed)
1341 (use "git checkout -- <file>..." to discard changes in working directory)
1343 modified: dir1/modified
1345 Untracked files:
1346 (use "git add <file>..." to include in what will be committed)
1348 .gitmodules
1349 dir1/untracked
1350 dir2/modified
1351 dir2/untracked
1352 expect
1353 output
1354 untracked
1355 no changes added to commit (use "git add" and/or "git commit -a")
1357 git status --ignore-submodules=all > output &&
1358 test_i18ncmp expect output
1361 test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1362 git config --add -f .gitmodules submodule.subname.ignore all &&
1363 git config --add -f .gitmodules submodule.subname.path sm &&
1364 git status > output &&
1365 test_cmp expect output &&
1366 git config -f .gitmodules --remove-section submodule.subname
1369 test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1370 git config --add -f .gitmodules submodule.subname.ignore none &&
1371 git config --add -f .gitmodules submodule.subname.path sm &&
1372 git config --add submodule.subname.ignore all &&
1373 git config --add submodule.subname.path sm &&
1374 git status > output &&
1375 test_cmp expect output &&
1376 git config --remove-section submodule.subname &&
1377 git config -f .gitmodules --remove-section submodule.subname
1380 test_expect_success 'setup of test environment' '
1381 git config status.showUntrackedFiles no &&
1382 git status -s >expected_short &&
1383 git status --no-short >expected_noshort
1386 test_expect_success '"status.short=true" same as "-s"' '
1387 git -c status.short=true status >actual &&
1388 test_cmp expected_short actual
1391 test_expect_success '"status.short=true" weaker than "--no-short"' '
1392 git -c status.short=true status --no-short >actual &&
1393 test_cmp expected_noshort actual
1396 test_expect_success '"status.short=false" same as "--no-short"' '
1397 git -c status.short=false status >actual &&
1398 test_cmp expected_noshort actual
1401 test_expect_success '"status.short=false" weaker than "-s"' '
1402 git -c status.short=false status -s >actual &&
1403 test_cmp expected_short actual
1406 test_expect_success '"status.branch=true" same as "-b"' '
1407 git status -sb >expected_branch &&
1408 git -c status.branch=true status -s >actual &&
1409 test_cmp expected_branch actual
1412 test_expect_success '"status.branch=true" different from "--no-branch"' '
1413 git status -s --no-branch >expected_nobranch &&
1414 git -c status.branch=true status -s >actual &&
1415 test_must_fail test_cmp expected_nobranch actual
1418 test_expect_success '"status.branch=true" weaker than "--no-branch"' '
1419 git -c status.branch=true status -s --no-branch >actual &&
1420 test_cmp expected_nobranch actual
1423 test_expect_success '"status.branch=true" weaker than "--porcelain"' '
1424 git -c status.branch=true status --porcelain >actual &&
1425 test_cmp expected_nobranch actual
1428 test_expect_success '"status.branch=false" same as "--no-branch"' '
1429 git -c status.branch=false status -s >actual &&
1430 test_cmp expected_nobranch actual
1433 test_expect_success '"status.branch=false" weaker than "-b"' '
1434 git -c status.branch=false status -sb >actual &&
1435 test_cmp expected_branch actual
1438 test_expect_success 'Restore default test environment' '
1439 git config --unset status.showUntrackedFiles
1442 test_done