status: disable display of '#' comment prefix by default
[git/mingw.git] / t / t7508-status.sh
blob8d282802356025761a2b32ffbaec65fec207553c
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='git status'
8 . ./test-lib.sh
10 test_expect_success 'use status.displayCommentPrefix by default ' '
11 git config --global status.displayCommentPrefix true
14 test_expect_success 'status -h in broken repository' '
15 git config --global advice.statusuoption false &&
16 mkdir broken &&
17 test_when_finished "rm -fr broken" &&
19 cd broken &&
20 git init &&
21 echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
22 test_expect_code 129 git status -h >usage 2>&1
23 ) &&
24 test_i18ngrep "[Uu]sage" broken/usage
27 test_expect_success 'commit -h in broken repository' '
28 mkdir broken &&
29 test_when_finished "rm -fr broken" &&
31 cd broken &&
32 git init &&
33 echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
34 test_expect_code 129 git commit -h >usage 2>&1
35 ) &&
36 test_i18ngrep "[Uu]sage" broken/usage
39 test_expect_success 'setup' '
40 : >tracked &&
41 : >modified &&
42 mkdir dir1 &&
43 : >dir1/tracked &&
44 : >dir1/modified &&
45 mkdir dir2 &&
46 : >dir1/tracked &&
47 : >dir1/modified &&
48 git add . &&
50 git status >output &&
52 test_tick &&
53 git commit -m initial &&
54 : >untracked &&
55 : >dir1/untracked &&
56 : >dir2/untracked &&
57 echo 1 >dir1/modified &&
58 echo 2 >dir2/modified &&
59 echo 3 >dir2/added &&
60 git add dir2/added
63 test_expect_success 'status (1)' '
64 test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output
67 strip_comments () {
68 sed "s/^\# //; s/^\#$//; s/^#\t/\t/" <"$1" >"$1".tmp &&
69 rm "$1" && mv "$1".tmp "$1"
72 test_expect_success 'status --column' '
73 cat >expect <<\EOF &&
74 # On branch master
75 # Changes to be committed:
76 # (use "git reset HEAD <file>..." to unstage)
78 # new file: dir2/added
80 # Changes not staged for commit:
81 # (use "git add <file>..." to update what will be committed)
82 # (use "git checkout -- <file>..." to discard changes in working directory)
84 # modified: dir1/modified
86 # Untracked files:
87 # (use "git add <file>..." to include in what will be committed)
89 # dir1/untracked dir2/untracked output
90 # dir2/modified expect untracked
91 EOF
92 COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
93 test_i18ncmp expect output
96 test_expect_success 'status --column status.displayCommentPrefix=false' '
97 strip_comments expect &&
98 COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
99 test_i18ncmp expect output
102 cat >expect <<\EOF
103 # On branch master
104 # Changes to be committed:
105 # (use "git reset HEAD <file>..." to unstage)
107 # new file: dir2/added
109 # Changes not staged for commit:
110 # (use "git add <file>..." to update what will be committed)
111 # (use "git checkout -- <file>..." to discard changes in working directory)
113 # modified: dir1/modified
115 # Untracked files:
116 # (use "git add <file>..." to include in what will be committed)
118 # dir1/untracked
119 # dir2/modified
120 # dir2/untracked
121 # expect
122 # output
123 # untracked
126 test_expect_success 'status with status.displayCommentPrefix=true' '
127 git -c status.displayCommentPrefix=true status >output &&
128 test_i18ncmp expect output
131 test_expect_success 'status with status.displayCommentPrefix=false' '
132 strip_comments expect &&
133 git -c status.displayCommentPrefix=false status >output &&
134 test_i18ncmp expect output
137 test_expect_success 'setup fake editor' '
138 cat >.git/editor <<-\EOF &&
139 #! /bin/sh
140 cp "$1" output
142 chmod 755 .git/editor
145 commit_template_commented () {
147 EDITOR=.git/editor &&
148 export EDITOR &&
149 # Fails due to empty message
150 test_must_fail git commit
151 ) &&
152 ! grep '^[^#]' output
155 test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
156 commit_template_commented
159 cat >expect <<\EOF
160 # On branch master
161 # Changes to be committed:
162 # new file: dir2/added
164 # Changes not staged for commit:
165 # modified: dir1/modified
167 # Untracked files:
168 # dir1/untracked
169 # dir2/modified
170 # dir2/untracked
171 # expect
172 # output
173 # untracked
176 test_expect_success 'status (advice.statusHints false)' '
177 test_config advice.statusHints false &&
178 git status >output &&
179 test_i18ncmp expect output
183 cat >expect <<\EOF
184 M dir1/modified
185 A dir2/added
186 ?? dir1/untracked
187 ?? dir2/modified
188 ?? dir2/untracked
189 ?? expect
190 ?? output
191 ?? untracked
194 test_expect_success 'status -s' '
196 git status -s >output &&
197 test_cmp expect output
201 test_expect_success 'status with gitignore' '
203 echo ".gitignore" &&
204 echo "expect" &&
205 echo "output" &&
206 echo "untracked"
207 } >.gitignore &&
209 cat >expect <<-\EOF &&
210 M dir1/modified
211 A dir2/added
212 ?? dir2/modified
214 git status -s >output &&
215 test_cmp expect output &&
217 cat >expect <<-\EOF &&
218 M dir1/modified
219 A dir2/added
220 ?? dir2/modified
221 !! .gitignore
222 !! dir1/untracked
223 !! dir2/untracked
224 !! expect
225 !! output
226 !! untracked
228 git status -s --ignored >output &&
229 test_cmp expect output &&
231 cat >expect <<-\EOF &&
232 # On branch master
233 # Changes to be committed:
234 # (use "git reset HEAD <file>..." to unstage)
236 # new file: dir2/added
238 # Changes not staged for commit:
239 # (use "git add <file>..." to update what will be committed)
240 # (use "git checkout -- <file>..." to discard changes in working directory)
242 # modified: dir1/modified
244 # Untracked files:
245 # (use "git add <file>..." to include in what will be committed)
247 # dir2/modified
248 # Ignored files:
249 # (use "git add -f <file>..." to include in what will be committed)
251 # .gitignore
252 # dir1/untracked
253 # dir2/untracked
254 # expect
255 # output
256 # untracked
258 git status --ignored >output &&
259 test_i18ncmp expect output
262 test_expect_success 'status with gitignore (nothing untracked)' '
264 echo ".gitignore" &&
265 echo "expect" &&
266 echo "dir2/modified" &&
267 echo "output" &&
268 echo "untracked"
269 } >.gitignore &&
271 cat >expect <<-\EOF &&
272 M dir1/modified
273 A dir2/added
275 git status -s >output &&
276 test_cmp expect output &&
278 cat >expect <<-\EOF &&
279 M dir1/modified
280 A dir2/added
281 !! .gitignore
282 !! dir1/untracked
283 !! dir2/modified
284 !! dir2/untracked
285 !! expect
286 !! output
287 !! untracked
289 git status -s --ignored >output &&
290 test_cmp expect output &&
292 cat >expect <<-\EOF &&
293 # On branch master
294 # Changes to be committed:
295 # (use "git reset HEAD <file>..." to unstage)
297 # new file: dir2/added
299 # Changes not staged for commit:
300 # (use "git add <file>..." to update what will be committed)
301 # (use "git checkout -- <file>..." to discard changes in working directory)
303 # modified: dir1/modified
305 # Ignored files:
306 # (use "git add -f <file>..." to include in what will be committed)
308 # .gitignore
309 # dir1/untracked
310 # dir2/modified
311 # dir2/untracked
312 # expect
313 # output
314 # untracked
316 git status --ignored >output &&
317 test_i18ncmp expect output
320 rm -f .gitignore
322 cat >expect <<\EOF
323 ## master
324 M dir1/modified
325 A dir2/added
326 ?? dir1/untracked
327 ?? dir2/modified
328 ?? dir2/untracked
329 ?? expect
330 ?? output
331 ?? untracked
334 test_expect_success 'status -s -b' '
336 git status -s -b >output &&
337 test_cmp expect output
341 test_expect_success 'status -s -z -b' '
342 tr "\\n" Q <expect >expect.q &&
343 mv expect.q expect &&
344 git status -s -z -b >output &&
345 nul_to_q <output >output.q &&
346 mv output.q output &&
347 test_cmp expect output
350 test_expect_success 'setup dir3' '
351 mkdir dir3 &&
352 : >dir3/untracked1 &&
353 : >dir3/untracked2
356 cat >expect <<EOF
357 # On branch master
358 # Changes to be committed:
359 # (use "git reset HEAD <file>..." to unstage)
361 # new file: dir2/added
363 # Changes not staged for commit:
364 # (use "git add <file>..." to update what will be committed)
365 # (use "git checkout -- <file>..." to discard changes in working directory)
367 # modified: dir1/modified
369 # Untracked files not listed (use -u option to show untracked files)
371 test_expect_success 'status -uno' '
372 git status -uno >output &&
373 test_i18ncmp expect output
376 test_expect_success 'status (status.showUntrackedFiles no)' '
377 test_config status.showuntrackedfiles no &&
378 git status >output &&
379 test_i18ncmp expect output
382 cat >expect <<EOF
383 # On branch master
384 # Changes to be committed:
385 # new file: dir2/added
387 # Changes not staged for commit:
388 # modified: dir1/modified
390 # Untracked files not listed
392 test_expect_success 'status -uno (advice.statusHints false)' '
393 test_config advice.statusHints false &&
394 git status -uno >output &&
395 test_i18ncmp expect output
398 cat >expect << EOF
399 M dir1/modified
400 A dir2/added
402 test_expect_success 'status -s -uno' '
403 git status -s -uno >output &&
404 test_cmp expect output
407 test_expect_success 'status -s (status.showUntrackedFiles no)' '
408 git config status.showuntrackedfiles no
409 git status -s >output &&
410 test_cmp expect output
413 cat >expect <<EOF
414 # On branch master
415 # Changes to be committed:
416 # (use "git reset HEAD <file>..." to unstage)
418 # new file: dir2/added
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 # modified: dir1/modified
426 # Untracked files:
427 # (use "git add <file>..." to include in what will be committed)
429 # dir1/untracked
430 # dir2/modified
431 # dir2/untracked
432 # dir3/
433 # expect
434 # output
435 # untracked
437 test_expect_success 'status -unormal' '
438 git status -unormal >output &&
439 test_i18ncmp expect output
442 test_expect_success 'status (status.showUntrackedFiles normal)' '
443 test_config status.showuntrackedfiles normal
444 git status >output &&
445 test_i18ncmp expect output
448 cat >expect <<EOF
449 M dir1/modified
450 A dir2/added
451 ?? dir1/untracked
452 ?? dir2/modified
453 ?? dir2/untracked
454 ?? dir3/
455 ?? expect
456 ?? output
457 ?? untracked
459 test_expect_success 'status -s -unormal' '
460 git status -s -unormal >output &&
461 test_cmp expect output
464 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
465 git config status.showuntrackedfiles normal
466 git status -s >output &&
467 test_cmp expect output
470 cat >expect <<EOF
471 # On branch master
472 # Changes to be committed:
473 # (use "git reset HEAD <file>..." to unstage)
475 # new file: dir2/added
477 # Changes not staged for commit:
478 # (use "git add <file>..." to update what will be committed)
479 # (use "git checkout -- <file>..." to discard changes in working directory)
481 # modified: dir1/modified
483 # Untracked files:
484 # (use "git add <file>..." to include in what will be committed)
486 # dir1/untracked
487 # dir2/modified
488 # dir2/untracked
489 # dir3/untracked1
490 # dir3/untracked2
491 # expect
492 # output
493 # untracked
495 test_expect_success 'status -uall' '
496 git status -uall >output &&
497 test_i18ncmp expect output
500 test_expect_success 'status (status.showUntrackedFiles all)' '
501 test_config status.showuntrackedfiles all
502 git status >output &&
503 test_i18ncmp expect output
506 test_expect_success 'teardown dir3' '
507 rm -rf dir3
510 cat >expect <<EOF
511 M dir1/modified
512 A dir2/added
513 ?? dir1/untracked
514 ?? dir2/modified
515 ?? dir2/untracked
516 ?? expect
517 ?? output
518 ?? untracked
520 test_expect_success 'status -s -uall' '
521 git config --unset status.showuntrackedfiles
522 git status -s -uall >output &&
523 test_cmp expect output
525 test_expect_success 'status -s (status.showUntrackedFiles all)' '
526 test_config status.showuntrackedfiles all &&
527 git status -s >output &&
528 rm -rf dir3 &&
529 test_cmp expect output
532 cat >expect <<\EOF
533 # On branch master
534 # Changes to be committed:
535 # (use "git reset HEAD <file>..." to unstage)
537 # new file: ../dir2/added
539 # Changes not staged for commit:
540 # (use "git add <file>..." to update what will be committed)
541 # (use "git checkout -- <file>..." to discard changes in working directory)
543 # modified: modified
545 # Untracked files:
546 # (use "git add <file>..." to include in what will be committed)
548 # untracked
549 # ../dir2/modified
550 # ../dir2/untracked
551 # ../expect
552 # ../output
553 # ../untracked
556 test_expect_success 'status with relative paths' '
557 (cd dir1 && git status) >output &&
558 test_i18ncmp expect output
561 cat >expect <<\EOF
562 M modified
563 A ../dir2/added
564 ?? untracked
565 ?? ../dir2/modified
566 ?? ../dir2/untracked
567 ?? ../expect
568 ?? ../output
569 ?? ../untracked
571 test_expect_success 'status -s with relative paths' '
573 (cd dir1 && git status -s) >output &&
574 test_cmp expect output
578 cat >expect <<\EOF
579 M dir1/modified
580 A dir2/added
581 ?? dir1/untracked
582 ?? dir2/modified
583 ?? dir2/untracked
584 ?? expect
585 ?? output
586 ?? untracked
589 test_expect_success 'status --porcelain ignores relative paths setting' '
591 (cd dir1 && git status --porcelain) >output &&
592 test_cmp expect output
596 test_expect_success 'setup unique colors' '
598 git config status.color.untracked blue &&
599 git config status.color.branch green
603 cat >expect <<\EOF
604 # On branch <GREEN>master<RESET>
605 # Changes to be committed:
606 # (use "git reset HEAD <file>..." to unstage)
608 # <GREEN>new file: dir2/added<RESET>
610 # Changes not staged for commit:
611 # (use "git add <file>..." to update what will be committed)
612 # (use "git checkout -- <file>..." to discard changes in working directory)
614 # <RED>modified: dir1/modified<RESET>
616 # Untracked files:
617 # (use "git add <file>..." to include in what will be committed)
619 # <BLUE>dir1/untracked<RESET>
620 # <BLUE>dir2/modified<RESET>
621 # <BLUE>dir2/untracked<RESET>
622 # <BLUE>expect<RESET>
623 # <BLUE>output<RESET>
624 # <BLUE>untracked<RESET>
627 test_expect_success 'status with color.ui' '
628 test_config color.ui always &&
629 git status | test_decode_color >output &&
630 test_i18ncmp expect output
633 test_expect_success 'status with color.status' '
634 test_config color.status always &&
635 git status | test_decode_color >output &&
636 test_i18ncmp expect output
639 cat >expect <<\EOF
640 <RED>M<RESET> dir1/modified
641 <GREEN>A<RESET> dir2/added
642 <BLUE>??<RESET> dir1/untracked
643 <BLUE>??<RESET> dir2/modified
644 <BLUE>??<RESET> dir2/untracked
645 <BLUE>??<RESET> expect
646 <BLUE>??<RESET> output
647 <BLUE>??<RESET> untracked
650 test_expect_success 'status -s with color.ui' '
652 git config color.ui always &&
653 git status -s | test_decode_color >output &&
654 test_cmp expect output
658 test_expect_success 'status -s with color.status' '
660 git config --unset color.ui &&
661 git config color.status always &&
662 git status -s | test_decode_color >output &&
663 test_cmp expect output
667 cat >expect <<\EOF
668 ## <GREEN>master<RESET>
669 <RED>M<RESET> dir1/modified
670 <GREEN>A<RESET> dir2/added
671 <BLUE>??<RESET> dir1/untracked
672 <BLUE>??<RESET> dir2/modified
673 <BLUE>??<RESET> dir2/untracked
674 <BLUE>??<RESET> expect
675 <BLUE>??<RESET> output
676 <BLUE>??<RESET> untracked
679 test_expect_success 'status -s -b with color.status' '
681 git status -s -b | test_decode_color >output &&
682 test_cmp expect output
686 cat >expect <<\EOF
687 M dir1/modified
688 A dir2/added
689 ?? dir1/untracked
690 ?? dir2/modified
691 ?? dir2/untracked
692 ?? expect
693 ?? output
694 ?? untracked
697 test_expect_success 'status --porcelain ignores color.ui' '
699 git config --unset color.status &&
700 git config color.ui always &&
701 git status --porcelain | test_decode_color >output &&
702 test_cmp expect output
706 test_expect_success 'status --porcelain ignores color.status' '
708 git config --unset color.ui &&
709 git config color.status always &&
710 git status --porcelain | test_decode_color >output &&
711 test_cmp expect output
715 # recover unconditionally from color tests
716 git config --unset color.status
717 git config --unset color.ui
719 test_expect_success 'status --porcelain respects -b' '
721 git status --porcelain -b >output &&
723 echo "## master" &&
724 cat expect
725 } >tmp &&
726 mv tmp expect &&
727 test_cmp expect output
731 cat >expect <<\EOF
732 # On branch master
733 # Changes to be committed:
734 # (use "git reset HEAD <file>..." to unstage)
736 # new file: dir2/added
738 # Changes not staged for commit:
739 # (use "git add <file>..." to update what will be committed)
740 # (use "git checkout -- <file>..." to discard changes in working directory)
742 # modified: dir1/modified
744 # Untracked files:
745 # (use "git add <file>..." to include in what will be committed)
747 # dir1/untracked
748 # dir2/modified
749 # dir2/untracked
750 # expect
751 # output
752 # untracked
756 test_expect_success 'status without relative paths' '
758 test_config status.relativePaths false &&
759 (cd dir1 && git status) >output &&
760 test_i18ncmp expect output
764 cat >expect <<\EOF
765 M dir1/modified
766 A dir2/added
767 ?? dir1/untracked
768 ?? dir2/modified
769 ?? dir2/untracked
770 ?? expect
771 ?? output
772 ?? untracked
775 test_expect_success 'status -s without relative paths' '
777 test_config status.relativePaths false &&
778 (cd dir1 && git status -s) >output &&
779 test_cmp expect output
783 cat <<EOF >expect
784 # On branch master
785 # Changes to be committed:
786 # (use "git reset HEAD <file>..." to unstage)
788 # modified: dir1/modified
790 # Untracked files:
791 # (use "git add <file>..." to include in what will be committed)
793 # dir1/untracked
794 # dir2/
795 # expect
796 # output
797 # untracked
799 test_expect_success 'dry-run of partial commit excluding new file in index' '
800 git commit --dry-run dir1/modified >output &&
801 test_i18ncmp expect output
804 cat >expect <<EOF
805 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
807 test_expect_success 'status refreshes the index' '
808 touch dir2/added &&
809 git status &&
810 git diff-files >output &&
811 test_cmp expect output
814 test_expect_success 'setup status submodule summary' '
815 test_create_repo sm && (
816 cd sm &&
817 >foo &&
818 git add foo &&
819 git commit -m "Add foo"
820 ) &&
821 git add sm
824 cat >expect <<EOF
825 # On branch master
826 # Changes to be committed:
827 # (use "git reset HEAD <file>..." to unstage)
829 # new file: dir2/added
830 # new file: sm
832 # Changes not staged for commit:
833 # (use "git add <file>..." to update what will be committed)
834 # (use "git checkout -- <file>..." to discard changes in working directory)
836 # modified: dir1/modified
838 # Untracked files:
839 # (use "git add <file>..." to include in what will be committed)
841 # dir1/untracked
842 # dir2/modified
843 # dir2/untracked
844 # expect
845 # output
846 # untracked
848 test_expect_success 'status submodule summary is disabled by default' '
849 git status >output &&
850 test_i18ncmp expect output
853 # we expect the same as the previous test
854 test_expect_success 'status --untracked-files=all does not show submodule' '
855 git status --untracked-files=all >output &&
856 test_i18ncmp expect output
859 cat >expect <<EOF
860 M dir1/modified
861 A dir2/added
862 A sm
863 ?? dir1/untracked
864 ?? dir2/modified
865 ?? dir2/untracked
866 ?? expect
867 ?? output
868 ?? untracked
870 test_expect_success 'status -s submodule summary is disabled by default' '
871 git status -s >output &&
872 test_cmp expect output
875 # we expect the same as the previous test
876 test_expect_success 'status -s --untracked-files=all does not show submodule' '
877 git status -s --untracked-files=all >output &&
878 test_cmp expect output
881 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
883 cat >expect <<EOF
884 # On branch master
885 # Changes to be committed:
886 # (use "git reset HEAD <file>..." to unstage)
888 # new file: dir2/added
889 # new file: sm
891 # Changes not staged for commit:
892 # (use "git add <file>..." to update what will be committed)
893 # (use "git checkout -- <file>..." to discard changes in working directory)
895 # modified: dir1/modified
897 # Submodule changes to be committed:
899 # * sm 0000000...$head (1):
900 # > Add foo
902 # Untracked files:
903 # (use "git add <file>..." to include in what will be committed)
905 # dir1/untracked
906 # dir2/modified
907 # dir2/untracked
908 # expect
909 # output
910 # untracked
912 test_expect_success 'status submodule summary' '
913 git config status.submodulesummary 10 &&
914 git status >output &&
915 test_i18ncmp expect output
918 test_expect_success 'status submodule summary with status.displayCommentPrefix=false' '
919 strip_comments expect &&
920 git -c status.displayCommentPrefix=false status >output &&
921 test_i18ncmp expect output
924 test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' '
925 commit_template_commented
928 cat >expect <<EOF
929 M dir1/modified
930 A dir2/added
931 A sm
932 ?? dir1/untracked
933 ?? dir2/modified
934 ?? dir2/untracked
935 ?? expect
936 ?? output
937 ?? untracked
939 test_expect_success 'status -s submodule summary' '
940 git status -s >output &&
941 test_cmp expect output
944 cat >expect <<EOF
945 # On branch master
946 # Changes not staged for commit:
947 # (use "git add <file>..." to update what will be committed)
948 # (use "git checkout -- <file>..." to discard changes in working directory)
950 # modified: dir1/modified
952 # Untracked files:
953 # (use "git add <file>..." to include in what will be committed)
955 # dir1/untracked
956 # dir2/modified
957 # dir2/untracked
958 # expect
959 # output
960 # untracked
961 no changes added to commit (use "git add" and/or "git commit -a")
963 test_expect_success 'status submodule summary (clean submodule): commit' '
964 git commit -m "commit submodule" &&
965 git config status.submodulesummary 10 &&
966 test_must_fail git commit --dry-run >output &&
967 test_i18ncmp expect output &&
968 git status >output &&
969 test_i18ncmp expect output
972 cat >expect <<EOF
973 M dir1/modified
974 ?? dir1/untracked
975 ?? dir2/modified
976 ?? dir2/untracked
977 ?? expect
978 ?? output
979 ?? untracked
981 test_expect_success 'status -s submodule summary (clean submodule)' '
982 git status -s >output &&
983 test_cmp expect output
986 test_expect_success 'status -z implies porcelain' '
987 git status --porcelain |
988 "$PERL_PATH" -pe "s/\012/\000/g" >expect &&
989 git status -z >output &&
990 test_cmp expect output
993 cat >expect <<EOF
994 # On branch master
995 # Changes to be committed:
996 # (use "git reset HEAD^1 <file>..." to unstage)
998 # new file: dir2/added
999 # new file: 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 0000000...$head (1):
1010 # > Add foo
1012 # Untracked files:
1013 # (use "git add <file>..." to include in what will be committed)
1015 # dir1/untracked
1016 # dir2/modified
1017 # dir2/untracked
1018 # expect
1019 # output
1020 # untracked
1022 test_expect_success 'commit --dry-run submodule summary (--amend)' '
1023 git config status.submodulesummary 10 &&
1024 git commit --dry-run --amend >output &&
1025 test_i18ncmp expect output
1028 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
1030 chmod a-w .git &&
1031 # make dir1/tracked stat-dirty
1032 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
1033 git status -s >output &&
1034 ! grep dir1/tracked output &&
1035 # make sure "status" succeeded without writing index out
1036 git diff-files | grep dir1/tracked
1038 status=$?
1039 chmod 775 .git
1040 (exit $status)
1043 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
1044 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
1045 touch .gitmodules
1047 cat > expect << EOF
1048 # On branch master
1049 # Changes to be committed:
1050 # (use "git reset HEAD <file>..." to unstage)
1052 # modified: sm
1054 # Changes not staged for commit:
1055 # (use "git add <file>..." to update what will be committed)
1056 # (use "git checkout -- <file>..." to discard changes in working directory)
1058 # modified: dir1/modified
1060 # Submodule changes to be committed:
1062 # * sm $head...$new_head (1):
1063 # > Add bar
1065 # Untracked files:
1066 # (use "git add <file>..." to include in what will be committed)
1068 # .gitmodules
1069 # dir1/untracked
1070 # dir2/modified
1071 # dir2/untracked
1072 # expect
1073 # output
1074 # untracked
1077 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1078 echo modified sm/untracked &&
1079 git status --ignore-submodules=untracked >output &&
1080 test_i18ncmp expect output
1083 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1084 test_config diff.ignoreSubmodules dirty &&
1085 git status >output &&
1086 test_i18ncmp expect output &&
1087 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1088 git config --add -f .gitmodules submodule.subname.path sm &&
1089 git status >output &&
1090 test_i18ncmp expect output &&
1091 git config -f .gitmodules --remove-section submodule.subname
1094 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1095 git config --add -f .gitmodules submodule.subname.ignore none &&
1096 git config --add -f .gitmodules submodule.subname.path sm &&
1097 git config --add submodule.subname.ignore untracked &&
1098 git config --add submodule.subname.path sm &&
1099 git status >output &&
1100 test_i18ncmp expect output &&
1101 git config --remove-section submodule.subname &&
1102 git config --remove-section -f .gitmodules submodule.subname
1105 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1106 git status --ignore-submodules=dirty >output &&
1107 test_i18ncmp expect output
1110 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1111 test_config diff.ignoreSubmodules dirty &&
1112 git status >output &&
1113 ! test -s actual &&
1114 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1115 git config --add -f .gitmodules submodule.subname.path sm &&
1116 git status >output &&
1117 test_i18ncmp expect output &&
1118 git config -f .gitmodules --remove-section submodule.subname
1121 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1122 git config --add -f .gitmodules submodule.subname.ignore none &&
1123 git config --add -f .gitmodules submodule.subname.path sm &&
1124 git config --add submodule.subname.ignore dirty &&
1125 git config --add submodule.subname.path sm &&
1126 git status >output &&
1127 test_i18ncmp expect output &&
1128 git config --remove-section submodule.subname &&
1129 git config -f .gitmodules --remove-section submodule.subname
1132 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1133 echo modified >sm/foo &&
1134 git status --ignore-submodules=dirty >output &&
1135 test_i18ncmp expect output
1138 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
1139 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1140 git config --add -f .gitmodules submodule.subname.path sm &&
1141 git status >output &&
1142 test_i18ncmp expect output &&
1143 git config -f .gitmodules --remove-section submodule.subname
1146 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
1147 git config --add -f .gitmodules submodule.subname.ignore none &&
1148 git config --add -f .gitmodules submodule.subname.path sm &&
1149 git config --add submodule.subname.ignore dirty &&
1150 git config --add submodule.subname.path sm &&
1151 git status >output &&
1152 test_i18ncmp expect output &&
1153 git config --remove-section submodule.subname &&
1154 git config -f .gitmodules --remove-section submodule.subname
1157 cat > expect << EOF
1158 # On branch master
1159 # Changes to be committed:
1160 # (use "git reset HEAD <file>..." to unstage)
1162 # modified: sm
1164 # Changes not staged for commit:
1165 # (use "git add <file>..." to update what will be committed)
1166 # (use "git checkout -- <file>..." to discard changes in working directory)
1167 # (commit or discard the untracked or modified content in submodules)
1169 # modified: dir1/modified
1170 # modified: sm (modified content)
1172 # Submodule changes to be committed:
1174 # * sm $head...$new_head (1):
1175 # > Add bar
1177 # Untracked files:
1178 # (use "git add <file>..." to include in what will be committed)
1180 # .gitmodules
1181 # dir1/untracked
1182 # dir2/modified
1183 # dir2/untracked
1184 # expect
1185 # output
1186 # untracked
1189 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1190 git status --ignore-submodules=untracked > output &&
1191 test_i18ncmp expect output
1194 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
1195 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1196 git config --add -f .gitmodules submodule.subname.path sm &&
1197 git status >output &&
1198 test_i18ncmp expect output &&
1199 git config -f .gitmodules --remove-section submodule.subname
1202 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1203 git config --add -f .gitmodules submodule.subname.ignore none &&
1204 git config --add -f .gitmodules submodule.subname.path sm &&
1205 git config --add submodule.subname.ignore untracked &&
1206 git config --add submodule.subname.path sm &&
1207 git status >output &&
1208 test_i18ncmp expect output &&
1209 git config --remove-section submodule.subname &&
1210 git config -f .gitmodules --remove-section submodule.subname
1213 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1215 cat > expect << EOF
1216 # On branch master
1217 # Changes to be committed:
1218 # (use "git reset HEAD <file>..." to unstage)
1220 # modified: sm
1222 # Changes not staged for commit:
1223 # (use "git add <file>..." to update what will be committed)
1224 # (use "git checkout -- <file>..." to discard changes in working directory)
1226 # modified: dir1/modified
1227 # modified: sm (new commits)
1229 # Submodule changes to be committed:
1231 # * sm $head...$new_head (1):
1232 # > Add bar
1234 # Submodules changed but not updated:
1236 # * sm $new_head...$head2 (1):
1237 # > 2nd commit
1239 # Untracked files:
1240 # (use "git add <file>..." to include in what will be committed)
1242 # .gitmodules
1243 # dir1/untracked
1244 # dir2/modified
1245 # dir2/untracked
1246 # expect
1247 # output
1248 # untracked
1251 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1252 git status --ignore-submodules=untracked > output &&
1253 test_i18ncmp expect output
1256 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1257 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1258 git config --add -f .gitmodules submodule.subname.path sm &&
1259 git status >output &&
1260 test_i18ncmp expect output &&
1261 git config -f .gitmodules --remove-section submodule.subname
1264 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1265 git config --add -f .gitmodules submodule.subname.ignore none &&
1266 git config --add -f .gitmodules submodule.subname.path sm &&
1267 git config --add submodule.subname.ignore untracked &&
1268 git config --add submodule.subname.path sm &&
1269 git status >output &&
1270 test_i18ncmp expect output &&
1271 git config --remove-section submodule.subname &&
1272 git config -f .gitmodules --remove-section submodule.subname
1275 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1276 git status --ignore-submodules=dirty > output &&
1277 test_i18ncmp expect output
1279 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1280 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1281 git config --add -f .gitmodules submodule.subname.path sm &&
1282 git status >output &&
1283 test_i18ncmp expect output &&
1284 git config -f .gitmodules --remove-section submodule.subname
1287 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1288 git config --add -f .gitmodules submodule.subname.ignore none &&
1289 git config --add -f .gitmodules submodule.subname.path sm &&
1290 git config --add submodule.subname.ignore dirty &&
1291 git config --add submodule.subname.path sm &&
1292 git status >output &&
1293 test_i18ncmp expect output &&
1294 git config --remove-section submodule.subname &&
1295 git config -f .gitmodules --remove-section submodule.subname
1298 cat > expect << EOF
1299 ; On branch master
1300 ; Changes to be committed:
1301 ; (use "git reset HEAD <file>..." to unstage)
1303 ; modified: sm
1305 ; Changes not staged for commit:
1306 ; (use "git add <file>..." to update what will be committed)
1307 ; (use "git checkout -- <file>..." to discard changes in working directory)
1309 ; modified: dir1/modified
1310 ; modified: sm (new commits)
1312 ; Submodule changes to be committed:
1314 ; * sm $head...$new_head (1):
1315 ; > Add bar
1317 ; Submodules changed but not updated:
1319 ; * sm $new_head...$head2 (1):
1320 ; > 2nd commit
1322 ; Untracked files:
1323 ; (use "git add <file>..." to include in what will be committed)
1325 ; .gitmodules
1326 ; dir1/untracked
1327 ; dir2/modified
1328 ; dir2/untracked
1329 ; expect
1330 ; output
1331 ; untracked
1334 test_expect_success "status (core.commentchar with submodule summary)" '
1335 test_config core.commentchar ";" &&
1336 git status >output &&
1337 test_i18ncmp expect output
1340 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1341 test_config core.commentchar ";;" &&
1342 git status >output &&
1343 test_i18ncmp expect output
1346 cat > expect << EOF
1347 # On branch master
1348 # Changes not staged for commit:
1349 # (use "git add <file>..." to update what will be committed)
1350 # (use "git checkout -- <file>..." to discard changes in working directory)
1352 # modified: dir1/modified
1354 # Untracked files:
1355 # (use "git add <file>..." to include in what will be committed)
1357 # .gitmodules
1358 # dir1/untracked
1359 # dir2/modified
1360 # dir2/untracked
1361 # expect
1362 # output
1363 # untracked
1364 no changes added to commit (use "git add" and/or "git commit -a")
1367 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1368 git status --ignore-submodules=all > output &&
1369 test_i18ncmp expect output
1372 test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1373 git config --add -f .gitmodules submodule.subname.ignore all &&
1374 git config --add -f .gitmodules submodule.subname.path sm &&
1375 git status > output &&
1376 test_cmp expect output &&
1377 git config -f .gitmodules --remove-section submodule.subname
1380 test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1381 git config --add -f .gitmodules submodule.subname.ignore none &&
1382 git config --add -f .gitmodules submodule.subname.path sm &&
1383 git config --add submodule.subname.ignore all &&
1384 git config --add submodule.subname.path sm &&
1385 git status > output &&
1386 test_cmp expect output &&
1387 git config --remove-section submodule.subname &&
1388 git config -f .gitmodules --remove-section submodule.subname
1391 test_expect_success 'setup of test environment' '
1392 git config status.showUntrackedFiles no &&
1393 git status -s >expected_short &&
1394 git status --no-short >expected_noshort
1397 test_expect_success '"status.short=true" same as "-s"' '
1398 git -c status.short=true status >actual &&
1399 test_cmp expected_short actual
1402 test_expect_success '"status.short=true" weaker than "--no-short"' '
1403 git -c status.short=true status --no-short >actual &&
1404 test_cmp expected_noshort actual
1407 test_expect_success '"status.short=false" same as "--no-short"' '
1408 git -c status.short=false status >actual &&
1409 test_cmp expected_noshort actual
1412 test_expect_success '"status.short=false" weaker than "-s"' '
1413 git -c status.short=false status -s >actual &&
1414 test_cmp expected_short actual
1417 test_expect_success '"status.branch=true" same as "-b"' '
1418 git status -sb >expected_branch &&
1419 git -c status.branch=true status -s >actual &&
1420 test_cmp expected_branch actual
1423 test_expect_success '"status.branch=true" different from "--no-branch"' '
1424 git status -s --no-branch >expected_nobranch &&
1425 git -c status.branch=true status -s >actual &&
1426 test_must_fail test_cmp expected_nobranch actual
1429 test_expect_success '"status.branch=true" weaker than "--no-branch"' '
1430 git -c status.branch=true status -s --no-branch >actual &&
1431 test_cmp expected_nobranch actual
1434 test_expect_success '"status.branch=true" weaker than "--porcelain"' '
1435 git -c status.branch=true status --porcelain >actual &&
1436 test_cmp expected_nobranch actual
1439 test_expect_success '"status.branch=false" same as "--no-branch"' '
1440 git -c status.branch=false status -s >actual &&
1441 test_cmp expected_nobranch actual
1444 test_expect_success '"status.branch=false" weaker than "-b"' '
1445 git -c status.branch=false status -sb >actual &&
1446 test_cmp expected_branch actual
1449 test_expect_success 'Restore default test environment' '
1450 git config --unset status.showUntrackedFiles
1453 test_done