status: add missing blank line after list of "other" files
[git.git] / t / t7508-status.sh
blob9bf97017c090386b7cae6bfbc9b3f9caeb83bdab
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
88 EOF
89 COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
90 test_i18ncmp expect output
93 test_expect_success 'status --column status.displayCommentPrefix=false' '
94 strip_comments expect &&
95 COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
96 test_i18ncmp expect output
99 cat >expect <<\EOF
100 # On branch master
101 # Changes to be committed:
102 # (use "git reset HEAD <file>..." to unstage)
104 # new file: dir2/added
106 # Changes not staged for commit:
107 # (use "git add <file>..." to update what will be committed)
108 # (use "git checkout -- <file>..." to discard changes in working directory)
110 # modified: dir1/modified
112 # Untracked files:
113 # (use "git add <file>..." to include in what will be committed)
115 # dir1/untracked
116 # dir2/modified
117 # dir2/untracked
118 # expect
119 # output
120 # untracked
124 test_expect_success 'status with status.displayCommentPrefix=true' '
125 git -c status.displayCommentPrefix=true status >output &&
126 test_i18ncmp expect output
129 test_expect_success 'status with status.displayCommentPrefix=false' '
130 strip_comments expect &&
131 git -c status.displayCommentPrefix=false status >output &&
132 test_i18ncmp expect output
135 test_expect_success 'setup fake editor' '
136 cat >.git/editor <<-\EOF &&
137 #! /bin/sh
138 cp "$1" output
140 chmod 755 .git/editor
143 commit_template_commented () {
145 EDITOR=.git/editor &&
146 export EDITOR &&
147 # Fails due to empty message
148 test_must_fail git commit
149 ) &&
150 ! grep '^[^#]' output
153 test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
154 commit_template_commented
157 cat >expect <<\EOF
158 On branch master
159 Changes to be committed:
160 new file: dir2/added
162 Changes not staged for commit:
163 modified: dir1/modified
165 Untracked files:
166 dir1/untracked
167 dir2/modified
168 dir2/untracked
169 expect
170 output
171 untracked
175 test_expect_success 'status (advice.statusHints false)' '
176 test_config advice.statusHints false &&
177 git status >output &&
178 test_i18ncmp expect output
182 cat >expect <<\EOF
183 M dir1/modified
184 A dir2/added
185 ?? dir1/untracked
186 ?? dir2/modified
187 ?? dir2/untracked
188 ?? expect
189 ?? output
190 ?? untracked
193 test_expect_success 'status -s' '
195 git status -s >output &&
196 test_cmp expect output
200 test_expect_success 'status with gitignore' '
202 echo ".gitignore" &&
203 echo "expect" &&
204 echo "output" &&
205 echo "untracked"
206 } >.gitignore &&
208 cat >expect <<-\EOF &&
209 M dir1/modified
210 A dir2/added
211 ?? dir2/modified
213 git status -s >output &&
214 test_cmp expect output &&
216 cat >expect <<-\EOF &&
217 M dir1/modified
218 A dir2/added
219 ?? dir2/modified
220 !! .gitignore
221 !! dir1/untracked
222 !! dir2/untracked
223 !! expect
224 !! output
225 !! untracked
227 git status -s --ignored >output &&
228 test_cmp expect output &&
230 cat >expect <<\EOF &&
231 On branch master
232 Changes to be committed:
233 (use "git reset HEAD <file>..." to unstage)
235 new file: dir2/added
237 Changes not staged for commit:
238 (use "git add <file>..." to update what will be committed)
239 (use "git checkout -- <file>..." to discard changes in working directory)
241 modified: dir1/modified
243 Untracked files:
244 (use "git add <file>..." to include in what will be committed)
246 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
259 git status --ignored >output &&
260 test_i18ncmp expect output
263 test_expect_success 'status with gitignore (nothing untracked)' '
265 echo ".gitignore" &&
266 echo "expect" &&
267 echo "dir2/modified" &&
268 echo "output" &&
269 echo "untracked"
270 } >.gitignore &&
272 cat >expect <<-\EOF &&
273 M dir1/modified
274 A dir2/added
276 git status -s >output &&
277 test_cmp expect output &&
279 cat >expect <<-\EOF &&
280 M dir1/modified
281 A dir2/added
282 !! .gitignore
283 !! dir1/untracked
284 !! dir2/modified
285 !! dir2/untracked
286 !! expect
287 !! output
288 !! untracked
290 git status -s --ignored >output &&
291 test_cmp expect output &&
293 cat >expect <<\EOF &&
294 On branch master
295 Changes to be committed:
296 (use "git reset HEAD <file>..." to unstage)
298 new file: dir2/added
300 Changes not staged for commit:
301 (use "git add <file>..." to update what will be committed)
302 (use "git checkout -- <file>..." to discard changes in working directory)
304 modified: dir1/modified
306 Ignored files:
307 (use "git add -f <file>..." to include in what will be committed)
309 .gitignore
310 dir1/untracked
311 dir2/modified
312 dir2/untracked
313 expect
314 output
315 untracked
318 git status --ignored >output &&
319 test_i18ncmp expect output
322 rm -f .gitignore
324 cat >expect <<\EOF
325 ## master
326 M dir1/modified
327 A dir2/added
328 ?? dir1/untracked
329 ?? dir2/modified
330 ?? dir2/untracked
331 ?? expect
332 ?? output
333 ?? untracked
336 test_expect_success 'status -s -b' '
338 git status -s -b >output &&
339 test_cmp expect output
343 test_expect_success 'status -s -z -b' '
344 tr "\\n" Q <expect >expect.q &&
345 mv expect.q expect &&
346 git status -s -z -b >output &&
347 nul_to_q <output >output.q &&
348 mv output.q output &&
349 test_cmp expect output
352 test_expect_success 'setup dir3' '
353 mkdir dir3 &&
354 : >dir3/untracked1 &&
355 : >dir3/untracked2
358 test_expect_success 'status -uno' '
359 cat >expect <<EOF &&
360 On branch master
361 Changes to be committed:
362 (use "git reset HEAD <file>..." to unstage)
364 new file: dir2/added
366 Changes not staged for commit:
367 (use "git add <file>..." to update what will be committed)
368 (use "git checkout -- <file>..." to discard changes in working directory)
370 modified: dir1/modified
372 Untracked files not listed (use -u option to show untracked files)
374 git status -uno >output &&
375 test_i18ncmp expect output
378 test_expect_success 'status (status.showUntrackedFiles no)' '
379 test_config status.showuntrackedfiles no &&
380 git status >output &&
381 test_i18ncmp expect output
384 test_expect_success 'status -uno (advice.statusHints false)' '
385 cat >expect <<EOF &&
386 On branch master
387 Changes to be committed:
388 new file: dir2/added
390 Changes not staged for commit:
391 modified: dir1/modified
393 Untracked files not listed
395 test_config advice.statusHints false &&
396 git status -uno >output &&
397 test_i18ncmp expect output
400 cat >expect << EOF
401 M dir1/modified
402 A dir2/added
404 test_expect_success 'status -s -uno' '
405 git status -s -uno >output &&
406 test_cmp expect output
409 test_expect_success 'status -s (status.showUntrackedFiles no)' '
410 git config status.showuntrackedfiles no
411 git status -s >output &&
412 test_cmp expect output
415 test_expect_success 'status -unormal' '
416 cat >expect <<EOF &&
417 On branch master
418 Changes to be committed:
419 (use "git reset HEAD <file>..." to unstage)
421 new file: dir2/added
423 Changes not staged for commit:
424 (use "git add <file>..." to update what will be committed)
425 (use "git checkout -- <file>..." to discard changes in working directory)
427 modified: dir1/modified
429 Untracked files:
430 (use "git add <file>..." to include in what will be committed)
432 dir1/untracked
433 dir2/modified
434 dir2/untracked
435 dir3/
436 expect
437 output
438 untracked
441 git status -unormal >output &&
442 test_i18ncmp expect output
445 test_expect_success 'status (status.showUntrackedFiles normal)' '
446 test_config status.showuntrackedfiles normal
447 git status >output &&
448 test_i18ncmp expect output
451 cat >expect <<EOF
452 M dir1/modified
453 A dir2/added
454 ?? dir1/untracked
455 ?? dir2/modified
456 ?? dir2/untracked
457 ?? dir3/
458 ?? expect
459 ?? output
460 ?? untracked
462 test_expect_success 'status -s -unormal' '
463 git status -s -unormal >output &&
464 test_cmp expect output
467 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
468 git config status.showuntrackedfiles normal
469 git status -s >output &&
470 test_cmp expect output
473 test_expect_success 'status -uall' '
474 cat >expect <<EOF &&
475 On branch master
476 Changes to be committed:
477 (use "git reset HEAD <file>..." to unstage)
479 new file: dir2/added
481 Changes not staged for commit:
482 (use "git add <file>..." to update what will be committed)
483 (use "git checkout -- <file>..." to discard changes in working directory)
485 modified: dir1/modified
487 Untracked files:
488 (use "git add <file>..." to include in what will be committed)
490 dir1/untracked
491 dir2/modified
492 dir2/untracked
493 dir3/untracked1
494 dir3/untracked2
495 expect
496 output
497 untracked
500 git status -uall >output &&
501 test_i18ncmp expect output
504 test_expect_success 'status (status.showUntrackedFiles all)' '
505 test_config status.showuntrackedfiles all
506 git status >output &&
507 test_i18ncmp expect output
510 test_expect_success 'teardown dir3' '
511 rm -rf dir3
514 cat >expect <<EOF
515 M dir1/modified
516 A dir2/added
517 ?? dir1/untracked
518 ?? dir2/modified
519 ?? dir2/untracked
520 ?? expect
521 ?? output
522 ?? untracked
524 test_expect_success 'status -s -uall' '
525 git config --unset status.showuntrackedfiles
526 git status -s -uall >output &&
527 test_cmp expect output
529 test_expect_success 'status -s (status.showUntrackedFiles all)' '
530 test_config status.showuntrackedfiles all &&
531 git status -s >output &&
532 rm -rf dir3 &&
533 test_cmp expect output
536 test_expect_success 'status with relative paths' '
537 cat >expect <<\EOF &&
538 On branch master
539 Changes to be committed:
540 (use "git reset HEAD <file>..." to unstage)
542 new file: ../dir2/added
544 Changes not staged for commit:
545 (use "git add <file>..." to update what will be committed)
546 (use "git checkout -- <file>..." to discard changes in working directory)
548 modified: modified
550 Untracked files:
551 (use "git add <file>..." to include in what will be committed)
553 untracked
554 ../dir2/modified
555 ../dir2/untracked
556 ../expect
557 ../output
558 ../untracked
561 (cd dir1 && git status) >output &&
562 test_i18ncmp expect output
565 cat >expect <<\EOF
566 M modified
567 A ../dir2/added
568 ?? untracked
569 ?? ../dir2/modified
570 ?? ../dir2/untracked
571 ?? ../expect
572 ?? ../output
573 ?? ../untracked
575 test_expect_success 'status -s with relative paths' '
577 (cd dir1 && git status -s) >output &&
578 test_cmp expect output
582 cat >expect <<\EOF
583 M dir1/modified
584 A dir2/added
585 ?? dir1/untracked
586 ?? dir2/modified
587 ?? dir2/untracked
588 ?? expect
589 ?? output
590 ?? untracked
593 test_expect_success 'status --porcelain ignores relative paths setting' '
595 (cd dir1 && git status --porcelain) >output &&
596 test_cmp expect output
600 test_expect_success 'setup unique colors' '
602 git config status.color.untracked blue &&
603 git config status.color.branch green
607 test_expect_success 'status with color.ui' '
608 cat >expect <<\EOF &&
609 On branch <GREEN>master<RESET>
610 Changes to be committed:
611 (use "git reset HEAD <file>..." to unstage)
613 <GREEN>new file: dir2/added<RESET>
615 Changes not staged for commit:
616 (use "git add <file>..." to update what will be committed)
617 (use "git checkout -- <file>..." to discard changes in working directory)
619 <RED>modified: dir1/modified<RESET>
621 Untracked files:
622 (use "git add <file>..." to include in what will be committed)
624 <BLUE>dir1/untracked<RESET>
625 <BLUE>dir2/modified<RESET>
626 <BLUE>dir2/untracked<RESET>
627 <BLUE>expect<RESET>
628 <BLUE>output<RESET>
629 <BLUE>untracked<RESET>
632 test_config color.ui always &&
633 git status | test_decode_color >output &&
634 test_i18ncmp expect output
637 test_expect_success 'status with color.status' '
638 test_config color.status always &&
639 git status | test_decode_color >output &&
640 test_i18ncmp expect output
643 cat >expect <<\EOF
644 <RED>M<RESET> dir1/modified
645 <GREEN>A<RESET> dir2/added
646 <BLUE>??<RESET> dir1/untracked
647 <BLUE>??<RESET> dir2/modified
648 <BLUE>??<RESET> dir2/untracked
649 <BLUE>??<RESET> expect
650 <BLUE>??<RESET> output
651 <BLUE>??<RESET> untracked
654 test_expect_success 'status -s with color.ui' '
656 git config color.ui always &&
657 git status -s | test_decode_color >output &&
658 test_cmp expect output
662 test_expect_success 'status -s with color.status' '
664 git config --unset color.ui &&
665 git config color.status always &&
666 git status -s | test_decode_color >output &&
667 test_cmp expect output
671 cat >expect <<\EOF
672 ## <GREEN>master<RESET>
673 <RED>M<RESET> dir1/modified
674 <GREEN>A<RESET> dir2/added
675 <BLUE>??<RESET> dir1/untracked
676 <BLUE>??<RESET> dir2/modified
677 <BLUE>??<RESET> dir2/untracked
678 <BLUE>??<RESET> expect
679 <BLUE>??<RESET> output
680 <BLUE>??<RESET> untracked
683 test_expect_success 'status -s -b with color.status' '
685 git status -s -b | test_decode_color >output &&
686 test_cmp expect output
690 cat >expect <<\EOF
691 M dir1/modified
692 A dir2/added
693 ?? dir1/untracked
694 ?? dir2/modified
695 ?? dir2/untracked
696 ?? expect
697 ?? output
698 ?? untracked
701 test_expect_success 'status --porcelain ignores color.ui' '
703 git config --unset color.status &&
704 git config color.ui always &&
705 git status --porcelain | test_decode_color >output &&
706 test_cmp expect output
710 test_expect_success 'status --porcelain ignores color.status' '
712 git config --unset color.ui &&
713 git config color.status always &&
714 git status --porcelain | test_decode_color >output &&
715 test_cmp expect output
719 # recover unconditionally from color tests
720 git config --unset color.status
721 git config --unset color.ui
723 test_expect_success 'status --porcelain respects -b' '
725 git status --porcelain -b >output &&
727 echo "## master" &&
728 cat expect
729 } >tmp &&
730 mv tmp expect &&
731 test_cmp expect output
737 test_expect_success 'status without relative paths' '
738 cat >expect <<\EOF &&
739 On branch master
740 Changes to be committed:
741 (use "git reset HEAD <file>..." to unstage)
743 new file: dir2/added
745 Changes not staged for commit:
746 (use "git add <file>..." to update what will be committed)
747 (use "git checkout -- <file>..." to discard changes in working directory)
749 modified: dir1/modified
751 Untracked files:
752 (use "git add <file>..." to include in what will be committed)
754 dir1/untracked
755 dir2/modified
756 dir2/untracked
757 expect
758 output
759 untracked
762 test_config status.relativePaths false &&
763 (cd dir1 && git status) >output &&
764 test_i18ncmp expect output
768 cat >expect <<\EOF
769 M dir1/modified
770 A dir2/added
771 ?? dir1/untracked
772 ?? dir2/modified
773 ?? dir2/untracked
774 ?? expect
775 ?? output
776 ?? untracked
779 test_expect_success 'status -s without relative paths' '
781 test_config status.relativePaths false &&
782 (cd dir1 && git status -s) >output &&
783 test_cmp expect output
787 test_expect_success 'dry-run of partial commit excluding new file in index' '
788 cat >expect <<EOF &&
789 On branch master
790 Changes to be committed:
791 (use "git reset HEAD <file>..." to unstage)
793 modified: dir1/modified
795 Untracked files:
796 (use "git add <file>..." to include in what will be committed)
798 dir1/untracked
799 dir2/
800 expect
801 output
802 untracked
805 git commit --dry-run dir1/modified >output &&
806 test_i18ncmp expect output
809 cat >expect <<EOF
810 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
812 test_expect_success 'status refreshes the index' '
813 touch dir2/added &&
814 git status &&
815 git diff-files >output &&
816 test_cmp expect output
819 test_expect_success 'setup status submodule summary' '
820 test_create_repo sm && (
821 cd sm &&
822 >foo &&
823 git add foo &&
824 git commit -m "Add foo"
825 ) &&
826 git add sm
829 test_expect_success 'status submodule summary is disabled by default' '
830 cat >expect <<EOF &&
831 On branch master
832 Changes to be committed:
833 (use "git reset HEAD <file>..." to unstage)
835 new file: dir2/added
836 new file: sm
838 Changes not staged for commit:
839 (use "git add <file>..." to update what will be committed)
840 (use "git checkout -- <file>..." to discard changes in working directory)
842 modified: dir1/modified
844 Untracked files:
845 (use "git add <file>..." to include in what will be committed)
847 dir1/untracked
848 dir2/modified
849 dir2/untracked
850 expect
851 output
852 untracked
855 git status >output &&
856 test_i18ncmp expect output
859 # we expect the same as the previous test
860 test_expect_success 'status --untracked-files=all does not show submodule' '
861 git status --untracked-files=all >output &&
862 test_i18ncmp expect output
865 cat >expect <<EOF
866 M dir1/modified
867 A dir2/added
868 A sm
869 ?? dir1/untracked
870 ?? dir2/modified
871 ?? dir2/untracked
872 ?? expect
873 ?? output
874 ?? untracked
876 test_expect_success 'status -s submodule summary is disabled by default' '
877 git status -s >output &&
878 test_cmp expect output
881 # we expect the same as the previous test
882 test_expect_success 'status -s --untracked-files=all does not show submodule' '
883 git status -s --untracked-files=all >output &&
884 test_cmp expect output
887 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
889 test_expect_success 'status submodule summary' '
890 cat >expect <<EOF &&
891 On branch master
892 Changes to be committed:
893 (use "git reset HEAD <file>..." to unstage)
895 new file: dir2/added
896 new file: sm
898 Changes not staged for commit:
899 (use "git add <file>..." to update what will be committed)
900 (use "git checkout -- <file>..." to discard changes in working directory)
902 modified: dir1/modified
904 Submodule changes to be committed:
906 * sm 0000000...$head (1):
907 > Add foo
909 Untracked files:
910 (use "git add <file>..." to include in what will be committed)
912 dir1/untracked
913 dir2/modified
914 dir2/untracked
915 expect
916 output
917 untracked
920 git config status.submodulesummary 10 &&
921 git status >output &&
922 test_i18ncmp expect output
925 test_expect_success 'status submodule summary with status.displayCommentPrefix=false' '
926 strip_comments expect &&
927 git -c status.displayCommentPrefix=false status >output &&
928 test_i18ncmp expect output
931 test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' '
932 commit_template_commented
935 cat >expect <<EOF
936 M dir1/modified
937 A dir2/added
938 A sm
939 ?? dir1/untracked
940 ?? dir2/modified
941 ?? dir2/untracked
942 ?? expect
943 ?? output
944 ?? untracked
946 test_expect_success 'status -s submodule summary' '
947 git status -s >output &&
948 test_cmp expect output
951 test_expect_success 'status submodule summary (clean submodule): commit' '
952 cat >expect <<EOF &&
953 On branch master
954 Changes not staged for commit:
955 (use "git add <file>..." to update what will be committed)
956 (use "git checkout -- <file>..." to discard changes in working directory)
958 modified: dir1/modified
960 Untracked files:
961 (use "git add <file>..." to include in what will be committed)
963 dir1/untracked
964 dir2/modified
965 dir2/untracked
966 expect
967 output
968 untracked
970 no changes added to commit (use "git add" and/or "git commit -a")
972 git commit -m "commit submodule" &&
973 git config status.submodulesummary 10 &&
974 test_must_fail git commit --dry-run >output &&
975 test_i18ncmp expect output &&
976 git status >output &&
977 test_i18ncmp expect output
980 cat >expect <<EOF
981 M dir1/modified
982 ?? dir1/untracked
983 ?? dir2/modified
984 ?? dir2/untracked
985 ?? expect
986 ?? output
987 ?? untracked
989 test_expect_success 'status -s submodule summary (clean submodule)' '
990 git status -s >output &&
991 test_cmp expect output
994 test_expect_success 'status -z implies porcelain' '
995 git status --porcelain |
996 "$PERL_PATH" -pe "s/\012/\000/g" >expect &&
997 git status -z >output &&
998 test_cmp expect output
1001 test_expect_success 'commit --dry-run submodule summary (--amend)' '
1002 cat >expect <<EOF &&
1003 On branch master
1004 Changes to be committed:
1005 (use "git reset HEAD^1 <file>..." to unstage)
1007 new file: dir2/added
1008 new file: sm
1010 Changes not staged for commit:
1011 (use "git add <file>..." to update what will be committed)
1012 (use "git checkout -- <file>..." to discard changes in working directory)
1014 modified: dir1/modified
1016 Submodule changes to be committed:
1018 * sm 0000000...$head (1):
1019 > Add foo
1021 Untracked files:
1022 (use "git add <file>..." to include in what will be committed)
1024 dir1/untracked
1025 dir2/modified
1026 dir2/untracked
1027 expect
1028 output
1029 untracked
1032 git config status.submodulesummary 10 &&
1033 git commit --dry-run --amend >output &&
1034 test_i18ncmp expect output
1037 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
1039 chmod a-w .git &&
1040 # make dir1/tracked stat-dirty
1041 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
1042 git status -s >output &&
1043 ! grep dir1/tracked output &&
1044 # make sure "status" succeeded without writing index out
1045 git diff-files | grep dir1/tracked
1047 status=$?
1048 chmod 775 .git
1049 (exit $status)
1052 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
1053 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
1054 touch .gitmodules
1056 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1057 cat > expect << EOF &&
1058 On branch master
1059 Changes to be committed:
1060 (use "git reset HEAD <file>..." to unstage)
1062 modified: sm
1064 Changes not staged for commit:
1065 (use "git add <file>..." to update what will be committed)
1066 (use "git checkout -- <file>..." to discard changes in working directory)
1068 modified: dir1/modified
1070 Submodule changes to be committed:
1072 * sm $head...$new_head (1):
1073 > Add bar
1075 Untracked files:
1076 (use "git add <file>..." to include in what will be committed)
1078 .gitmodules
1079 dir1/untracked
1080 dir2/modified
1081 dir2/untracked
1082 expect
1083 output
1084 untracked
1087 echo modified sm/untracked &&
1088 git status --ignore-submodules=untracked >output &&
1089 test_i18ncmp expect output
1092 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1093 test_config diff.ignoreSubmodules dirty &&
1094 git status >output &&
1095 test_i18ncmp expect output &&
1096 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1097 git config --add -f .gitmodules submodule.subname.path sm &&
1098 git status >output &&
1099 test_i18ncmp expect output &&
1100 git config -f .gitmodules --remove-section submodule.subname
1103 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1104 git config --add -f .gitmodules submodule.subname.ignore none &&
1105 git config --add -f .gitmodules submodule.subname.path sm &&
1106 git config --add submodule.subname.ignore untracked &&
1107 git config --add submodule.subname.path sm &&
1108 git status >output &&
1109 test_i18ncmp expect output &&
1110 git config --remove-section submodule.subname &&
1111 git config --remove-section -f .gitmodules submodule.subname
1114 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1115 git status --ignore-submodules=dirty >output &&
1116 test_i18ncmp expect output
1119 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1120 test_config diff.ignoreSubmodules dirty &&
1121 git status >output &&
1122 ! test -s actual &&
1123 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1124 git config --add -f .gitmodules submodule.subname.path sm &&
1125 git status >output &&
1126 test_i18ncmp expect output &&
1127 git config -f .gitmodules --remove-section submodule.subname
1130 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1131 git config --add -f .gitmodules submodule.subname.ignore none &&
1132 git config --add -f .gitmodules submodule.subname.path sm &&
1133 git config --add submodule.subname.ignore dirty &&
1134 git config --add submodule.subname.path sm &&
1135 git status >output &&
1136 test_i18ncmp expect output &&
1137 git config --remove-section submodule.subname &&
1138 git config -f .gitmodules --remove-section submodule.subname
1141 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1142 echo modified >sm/foo &&
1143 git status --ignore-submodules=dirty >output &&
1144 test_i18ncmp expect output
1147 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
1148 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1149 git config --add -f .gitmodules submodule.subname.path sm &&
1150 git status >output &&
1151 test_i18ncmp expect output &&
1152 git config -f .gitmodules --remove-section submodule.subname
1155 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
1156 git config --add -f .gitmodules submodule.subname.ignore none &&
1157 git config --add -f .gitmodules submodule.subname.path sm &&
1158 git config --add submodule.subname.ignore dirty &&
1159 git config --add submodule.subname.path sm &&
1160 git status >output &&
1161 test_i18ncmp expect output &&
1162 git config --remove-section submodule.subname &&
1163 git config -f .gitmodules --remove-section submodule.subname
1166 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1167 cat > expect << EOF &&
1168 On branch master
1169 Changes to be committed:
1170 (use "git reset HEAD <file>..." to unstage)
1172 modified: sm
1174 Changes not staged for commit:
1175 (use "git add <file>..." to update what will be committed)
1176 (use "git checkout -- <file>..." to discard changes in working directory)
1177 (commit or discard the untracked or modified content in submodules)
1179 modified: dir1/modified
1180 modified: sm (modified content)
1182 Submodule changes to be committed:
1184 * sm $head...$new_head (1):
1185 > Add bar
1187 Untracked files:
1188 (use "git add <file>..." to include in what will be committed)
1190 .gitmodules
1191 dir1/untracked
1192 dir2/modified
1193 dir2/untracked
1194 expect
1195 output
1196 untracked
1199 git status --ignore-submodules=untracked > output &&
1200 test_i18ncmp expect output
1203 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
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 submodules with modified content" '
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 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1224 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1225 cat > expect << EOF &&
1226 On branch master
1227 Changes to be committed:
1228 (use "git reset HEAD <file>..." to unstage)
1230 modified: sm
1232 Changes not staged for commit:
1233 (use "git add <file>..." to update what will be committed)
1234 (use "git checkout -- <file>..." to discard changes in working directory)
1236 modified: dir1/modified
1237 modified: sm (new commits)
1239 Submodule changes to be committed:
1241 * sm $head...$new_head (1):
1242 > Add bar
1244 Submodules changed but not updated:
1246 * sm $new_head...$head2 (1):
1247 > 2nd commit
1249 Untracked files:
1250 (use "git add <file>..." to include in what will be committed)
1252 .gitmodules
1253 dir1/untracked
1254 dir2/modified
1255 dir2/untracked
1256 expect
1257 output
1258 untracked
1261 git status --ignore-submodules=untracked > output &&
1262 test_i18ncmp expect output
1265 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1266 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1267 git config --add -f .gitmodules submodule.subname.path sm &&
1268 git status >output &&
1269 test_i18ncmp expect output &&
1270 git config -f .gitmodules --remove-section submodule.subname
1273 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1274 git config --add -f .gitmodules submodule.subname.ignore none &&
1275 git config --add -f .gitmodules submodule.subname.path sm &&
1276 git config --add submodule.subname.ignore untracked &&
1277 git config --add submodule.subname.path sm &&
1278 git status >output &&
1279 test_i18ncmp expect output &&
1280 git config --remove-section submodule.subname &&
1281 git config -f .gitmodules --remove-section submodule.subname
1284 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1285 git status --ignore-submodules=dirty > output &&
1286 test_i18ncmp expect output
1288 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1289 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1290 git config --add -f .gitmodules submodule.subname.path sm &&
1291 git status >output &&
1292 test_i18ncmp expect output &&
1293 git config -f .gitmodules --remove-section submodule.subname
1296 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1297 git config --add -f .gitmodules submodule.subname.ignore none &&
1298 git config --add -f .gitmodules submodule.subname.path sm &&
1299 git config --add submodule.subname.ignore dirty &&
1300 git config --add submodule.subname.path sm &&
1301 git status >output &&
1302 test_i18ncmp expect output &&
1303 git config --remove-section submodule.subname &&
1304 git config -f .gitmodules --remove-section submodule.subname
1307 cat > expect << EOF
1308 ; On branch master
1309 ; Changes to be committed:
1310 ; (use "git reset HEAD <file>..." to unstage)
1312 ; modified: sm
1314 ; Changes not staged for commit:
1315 ; (use "git add <file>..." to update what will be committed)
1316 ; (use "git checkout -- <file>..." to discard changes in working directory)
1318 ; modified: dir1/modified
1319 ; modified: sm (new commits)
1321 ; Submodule changes to be committed:
1323 ; * sm $head...$new_head (1):
1324 ; > Add bar
1326 ; Submodules changed but not updated:
1328 ; * sm $new_head...$head2 (1):
1329 ; > 2nd commit
1331 ; Untracked files:
1332 ; (use "git add <file>..." to include in what will be committed)
1334 ; .gitmodules
1335 ; dir1/untracked
1336 ; dir2/modified
1337 ; dir2/untracked
1338 ; expect
1339 ; output
1340 ; untracked
1344 test_expect_success "status (core.commentchar with submodule summary)" '
1345 test_config core.commentchar ";" &&
1346 git -c status.displayCommentPrefix=true status >output &&
1347 test_i18ncmp expect output
1350 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1351 test_config core.commentchar ";;" &&
1352 git -c status.displayCommentPrefix=true status >output &&
1353 test_i18ncmp expect output
1356 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1357 cat > expect << EOF &&
1358 On branch master
1359 Changes not staged for commit:
1360 (use "git add <file>..." to update what will be committed)
1361 (use "git checkout -- <file>..." to discard changes in working directory)
1363 modified: dir1/modified
1365 Untracked files:
1366 (use "git add <file>..." to include in what will be committed)
1368 .gitmodules
1369 dir1/untracked
1370 dir2/modified
1371 dir2/untracked
1372 expect
1373 output
1374 untracked
1376 no changes added to commit (use "git add" and/or "git commit -a")
1378 git status --ignore-submodules=all > output &&
1379 test_i18ncmp expect output
1382 test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1383 git config --add -f .gitmodules submodule.subname.ignore all &&
1384 git config --add -f .gitmodules submodule.subname.path sm &&
1385 git status > output &&
1386 test_cmp expect output &&
1387 git config -f .gitmodules --remove-section submodule.subname
1390 test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1391 git config --add -f .gitmodules submodule.subname.ignore none &&
1392 git config --add -f .gitmodules submodule.subname.path sm &&
1393 git config --add submodule.subname.ignore all &&
1394 git config --add submodule.subname.path sm &&
1395 git status > output &&
1396 test_cmp expect output &&
1397 git config --remove-section submodule.subname &&
1398 git config -f .gitmodules --remove-section submodule.subname
1401 test_expect_success 'setup of test environment' '
1402 git config status.showUntrackedFiles no &&
1403 git status -s >expected_short &&
1404 git status --no-short >expected_noshort
1407 test_expect_success '"status.short=true" same as "-s"' '
1408 git -c status.short=true status >actual &&
1409 test_cmp expected_short actual
1412 test_expect_success '"status.short=true" weaker than "--no-short"' '
1413 git -c status.short=true status --no-short >actual &&
1414 test_cmp expected_noshort actual
1417 test_expect_success '"status.short=false" same as "--no-short"' '
1418 git -c status.short=false status >actual &&
1419 test_cmp expected_noshort actual
1422 test_expect_success '"status.short=false" weaker than "-s"' '
1423 git -c status.short=false status -s >actual &&
1424 test_cmp expected_short actual
1427 test_expect_success '"status.branch=true" same as "-b"' '
1428 git status -sb >expected_branch &&
1429 git -c status.branch=true status -s >actual &&
1430 test_cmp expected_branch actual
1433 test_expect_success '"status.branch=true" different from "--no-branch"' '
1434 git status -s --no-branch >expected_nobranch &&
1435 git -c status.branch=true status -s >actual &&
1436 test_must_fail test_cmp expected_nobranch actual
1439 test_expect_success '"status.branch=true" weaker than "--no-branch"' '
1440 git -c status.branch=true status -s --no-branch >actual &&
1441 test_cmp expected_nobranch actual
1444 test_expect_success '"status.branch=true" weaker than "--porcelain"' '
1445 git -c status.branch=true status --porcelain >actual &&
1446 test_cmp expected_nobranch actual
1449 test_expect_success '"status.branch=false" same as "--no-branch"' '
1450 git -c status.branch=false status -s >actual &&
1451 test_cmp expected_nobranch actual
1454 test_expect_success '"status.branch=false" weaker than "-b"' '
1455 git -c status.branch=false status -sb >actual &&
1456 test_cmp expected_branch actual
1459 test_expect_success 'Restore default test environment' '
1460 git config --unset status.showUntrackedFiles
1463 test_done