Makefile: make perf tests optional for profile build
[git/gitweb.git] / t / t7508-status.sh
blob8ed5788808055889208ac9451054f098538a6878
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 tab=' '
65 sed "s/^\# //; s/^\#$//; s/^#$tab/$tab/" <"$1" >"$1".tmp &&
66 rm "$1" && mv "$1".tmp "$1"
69 test_expect_success 'status --column' '
70 cat >expect <<\EOF &&
71 # On branch master
72 # Changes to be committed:
73 # (use "git reset HEAD <file>..." to unstage)
75 # new file: dir2/added
77 # Changes not staged for commit:
78 # (use "git add <file>..." to update what will be committed)
79 # (use "git checkout -- <file>..." to discard changes in working directory)
81 # modified: dir1/modified
83 # Untracked files:
84 # (use "git add <file>..." to include in what will be committed)
86 # dir1/untracked dir2/untracked output
87 # dir2/modified expect untracked
89 EOF
90 COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
91 test_i18ncmp expect output
94 test_expect_success 'status --column status.displayCommentPrefix=false' '
95 strip_comments expect &&
96 COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
97 test_i18ncmp expect output
100 cat >expect <<\EOF
101 # On branch master
102 # Changes to be committed:
103 # (use "git reset HEAD <file>..." to unstage)
105 # new file: dir2/added
107 # Changes not staged for commit:
108 # (use "git add <file>..." to update what will be committed)
109 # (use "git checkout -- <file>..." to discard changes in working directory)
111 # modified: dir1/modified
113 # Untracked files:
114 # (use "git add <file>..." to include in what will be committed)
116 # dir1/untracked
117 # dir2/modified
118 # dir2/untracked
119 # expect
120 # output
121 # untracked
125 test_expect_success 'status with status.displayCommentPrefix=true' '
126 git -c status.displayCommentPrefix=true status >output &&
127 test_i18ncmp expect output
130 test_expect_success 'status with status.displayCommentPrefix=false' '
131 strip_comments expect &&
132 git -c status.displayCommentPrefix=false status >output &&
133 test_i18ncmp expect output
136 test_expect_success 'setup fake editor' '
137 cat >.git/editor <<-\EOF &&
138 #! /bin/sh
139 cp "$1" output
141 chmod 755 .git/editor
144 commit_template_commented () {
146 EDITOR=.git/editor &&
147 export EDITOR &&
148 # Fails due to empty message
149 test_must_fail git commit
150 ) &&
151 ! grep '^[^#]' output
154 test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
155 commit_template_commented
158 cat >expect <<\EOF
159 On branch master
160 Changes to be committed:
161 new file: dir2/added
163 Changes not staged for commit:
164 modified: dir1/modified
166 Untracked files:
167 dir1/untracked
168 dir2/modified
169 dir2/untracked
170 expect
171 output
172 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
249 Ignored files:
250 (use "git add -f <file>..." to include in what will be committed)
252 .gitignore
253 dir1/untracked
254 dir2/untracked
255 expect
256 output
257 untracked
260 git status --ignored >output &&
261 test_i18ncmp expect output
264 test_expect_success 'status with gitignore (nothing untracked)' '
266 echo ".gitignore" &&
267 echo "expect" &&
268 echo "dir2/modified" &&
269 echo "output" &&
270 echo "untracked"
271 } >.gitignore &&
273 cat >expect <<-\EOF &&
274 M dir1/modified
275 A dir2/added
277 git status -s >output &&
278 test_cmp expect output &&
280 cat >expect <<-\EOF &&
281 M dir1/modified
282 A dir2/added
283 !! .gitignore
284 !! dir1/untracked
285 !! dir2/modified
286 !! dir2/untracked
287 !! expect
288 !! output
289 !! untracked
291 git status -s --ignored >output &&
292 test_cmp expect output &&
294 cat >expect <<\EOF &&
295 On branch master
296 Changes to be committed:
297 (use "git reset HEAD <file>..." to unstage)
299 new file: dir2/added
301 Changes not staged for commit:
302 (use "git add <file>..." to update what will be committed)
303 (use "git checkout -- <file>..." to discard changes in working directory)
305 modified: dir1/modified
307 Ignored files:
308 (use "git add -f <file>..." to include in what will be committed)
310 .gitignore
311 dir1/untracked
312 dir2/modified
313 dir2/untracked
314 expect
315 output
316 untracked
319 git status --ignored >output &&
320 test_i18ncmp expect output
323 rm -f .gitignore
325 cat >expect <<\EOF
326 ## master
327 M dir1/modified
328 A dir2/added
329 ?? dir1/untracked
330 ?? dir2/modified
331 ?? dir2/untracked
332 ?? expect
333 ?? output
334 ?? untracked
337 test_expect_success 'status -s -b' '
339 git status -s -b >output &&
340 test_cmp expect output
344 test_expect_success 'status -s -z -b' '
345 tr "\\n" Q <expect >expect.q &&
346 mv expect.q expect &&
347 git status -s -z -b >output &&
348 nul_to_q <output >output.q &&
349 mv output.q output &&
350 test_cmp expect output
353 test_expect_success 'setup dir3' '
354 mkdir dir3 &&
355 : >dir3/untracked1 &&
356 : >dir3/untracked2
359 test_expect_success 'status -uno' '
360 cat >expect <<EOF &&
361 On branch master
362 Changes to be committed:
363 (use "git reset HEAD <file>..." to unstage)
365 new file: dir2/added
367 Changes not staged for commit:
368 (use "git add <file>..." to update what will be committed)
369 (use "git checkout -- <file>..." to discard changes in working directory)
371 modified: dir1/modified
373 Untracked files not listed (use -u option to show untracked files)
375 git status -uno >output &&
376 test_i18ncmp expect output
379 test_expect_success 'status (status.showUntrackedFiles no)' '
380 test_config status.showuntrackedfiles no &&
381 git status >output &&
382 test_i18ncmp expect output
385 test_expect_success 'status -uno (advice.statusHints false)' '
386 cat >expect <<EOF &&
387 On branch master
388 Changes to be committed:
389 new file: dir2/added
391 Changes not staged for commit:
392 modified: dir1/modified
394 Untracked files not listed
396 test_config advice.statusHints false &&
397 git status -uno >output &&
398 test_i18ncmp expect output
401 cat >expect << EOF
402 M dir1/modified
403 A dir2/added
405 test_expect_success 'status -s -uno' '
406 git status -s -uno >output &&
407 test_cmp expect output
410 test_expect_success 'status -s (status.showUntrackedFiles no)' '
411 git config status.showuntrackedfiles no
412 git status -s >output &&
413 test_cmp expect output
416 test_expect_success 'status -unormal' '
417 cat >expect <<EOF &&
418 On branch master
419 Changes to be committed:
420 (use "git reset HEAD <file>..." to unstage)
422 new file: dir2/added
424 Changes not staged for commit:
425 (use "git add <file>..." to update what will be committed)
426 (use "git checkout -- <file>..." to discard changes in working directory)
428 modified: dir1/modified
430 Untracked files:
431 (use "git add <file>..." to include in what will be committed)
433 dir1/untracked
434 dir2/modified
435 dir2/untracked
436 dir3/
437 expect
438 output
439 untracked
442 git status -unormal >output &&
443 test_i18ncmp expect output
446 test_expect_success 'status (status.showUntrackedFiles normal)' '
447 test_config status.showuntrackedfiles normal
448 git status >output &&
449 test_i18ncmp expect output
452 cat >expect <<EOF
453 M dir1/modified
454 A dir2/added
455 ?? dir1/untracked
456 ?? dir2/modified
457 ?? dir2/untracked
458 ?? dir3/
459 ?? expect
460 ?? output
461 ?? untracked
463 test_expect_success 'status -s -unormal' '
464 git status -s -unormal >output &&
465 test_cmp expect output
468 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
469 git config status.showuntrackedfiles normal
470 git status -s >output &&
471 test_cmp expect output
474 test_expect_success 'status -uall' '
475 cat >expect <<EOF &&
476 On branch master
477 Changes to be committed:
478 (use "git reset HEAD <file>..." to unstage)
480 new file: dir2/added
482 Changes not staged for commit:
483 (use "git add <file>..." to update what will be committed)
484 (use "git checkout -- <file>..." to discard changes in working directory)
486 modified: dir1/modified
488 Untracked files:
489 (use "git add <file>..." to include in what will be committed)
491 dir1/untracked
492 dir2/modified
493 dir2/untracked
494 dir3/untracked1
495 dir3/untracked2
496 expect
497 output
498 untracked
501 git status -uall >output &&
502 test_i18ncmp expect output
505 test_expect_success 'status (status.showUntrackedFiles all)' '
506 test_config status.showuntrackedfiles all
507 git status >output &&
508 test_i18ncmp expect output
511 test_expect_success 'teardown dir3' '
512 rm -rf dir3
515 cat >expect <<EOF
516 M dir1/modified
517 A dir2/added
518 ?? dir1/untracked
519 ?? dir2/modified
520 ?? dir2/untracked
521 ?? expect
522 ?? output
523 ?? untracked
525 test_expect_success 'status -s -uall' '
526 git config --unset status.showuntrackedfiles
527 git status -s -uall >output &&
528 test_cmp expect output
530 test_expect_success 'status -s (status.showUntrackedFiles all)' '
531 test_config status.showuntrackedfiles all &&
532 git status -s >output &&
533 rm -rf dir3 &&
534 test_cmp expect output
537 test_expect_success 'status with relative paths' '
538 cat >expect <<\EOF &&
539 On branch master
540 Changes to be committed:
541 (use "git reset HEAD <file>..." to unstage)
543 new file: ../dir2/added
545 Changes not staged for commit:
546 (use "git add <file>..." to update what will be committed)
547 (use "git checkout -- <file>..." to discard changes in working directory)
549 modified: modified
551 Untracked files:
552 (use "git add <file>..." to include in what will be committed)
554 untracked
555 ../dir2/modified
556 ../dir2/untracked
557 ../expect
558 ../output
559 ../untracked
562 (cd dir1 && git status) >output &&
563 test_i18ncmp expect output
566 cat >expect <<\EOF
567 M modified
568 A ../dir2/added
569 ?? untracked
570 ?? ../dir2/modified
571 ?? ../dir2/untracked
572 ?? ../expect
573 ?? ../output
574 ?? ../untracked
576 test_expect_success 'status -s with relative paths' '
578 (cd dir1 && git status -s) >output &&
579 test_cmp expect output
583 cat >expect <<\EOF
584 M dir1/modified
585 A dir2/added
586 ?? dir1/untracked
587 ?? dir2/modified
588 ?? dir2/untracked
589 ?? expect
590 ?? output
591 ?? untracked
594 test_expect_success 'status --porcelain ignores relative paths setting' '
596 (cd dir1 && git status --porcelain) >output &&
597 test_cmp expect output
601 test_expect_success 'setup unique colors' '
603 git config status.color.untracked blue &&
604 git config status.color.branch green
608 test_expect_success 'status with color.ui' '
609 cat >expect <<\EOF &&
610 On branch <GREEN>master<RESET>
611 Changes to be committed:
612 (use "git reset HEAD <file>..." to unstage)
614 <GREEN>new file: dir2/added<RESET>
616 Changes not staged for commit:
617 (use "git add <file>..." to update what will be committed)
618 (use "git checkout -- <file>..." to discard changes in working directory)
620 <RED>modified: dir1/modified<RESET>
622 Untracked files:
623 (use "git add <file>..." to include in what will be committed)
625 <BLUE>dir1/untracked<RESET>
626 <BLUE>dir2/modified<RESET>
627 <BLUE>dir2/untracked<RESET>
628 <BLUE>expect<RESET>
629 <BLUE>output<RESET>
630 <BLUE>untracked<RESET>
633 test_config color.ui always &&
634 git status | test_decode_color >output &&
635 test_i18ncmp expect output
638 test_expect_success 'status with color.status' '
639 test_config color.status always &&
640 git status | test_decode_color >output &&
641 test_i18ncmp expect output
644 cat >expect <<\EOF
645 <RED>M<RESET> dir1/modified
646 <GREEN>A<RESET> dir2/added
647 <BLUE>??<RESET> dir1/untracked
648 <BLUE>??<RESET> dir2/modified
649 <BLUE>??<RESET> dir2/untracked
650 <BLUE>??<RESET> expect
651 <BLUE>??<RESET> output
652 <BLUE>??<RESET> untracked
655 test_expect_success 'status -s with color.ui' '
657 git config color.ui always &&
658 git status -s | test_decode_color >output &&
659 test_cmp expect output
663 test_expect_success 'status -s with color.status' '
665 git config --unset color.ui &&
666 git config color.status always &&
667 git status -s | test_decode_color >output &&
668 test_cmp expect output
672 cat >expect <<\EOF
673 ## <GREEN>master<RESET>
674 <RED>M<RESET> dir1/modified
675 <GREEN>A<RESET> dir2/added
676 <BLUE>??<RESET> dir1/untracked
677 <BLUE>??<RESET> dir2/modified
678 <BLUE>??<RESET> dir2/untracked
679 <BLUE>??<RESET> expect
680 <BLUE>??<RESET> output
681 <BLUE>??<RESET> untracked
684 test_expect_success 'status -s -b with color.status' '
686 git status -s -b | test_decode_color >output &&
687 test_cmp expect output
691 cat >expect <<\EOF
692 M dir1/modified
693 A dir2/added
694 ?? dir1/untracked
695 ?? dir2/modified
696 ?? dir2/untracked
697 ?? expect
698 ?? output
699 ?? untracked
702 test_expect_success 'status --porcelain ignores color.ui' '
704 git config --unset color.status &&
705 git config color.ui always &&
706 git status --porcelain | test_decode_color >output &&
707 test_cmp expect output
711 test_expect_success 'status --porcelain ignores color.status' '
713 git config --unset color.ui &&
714 git config color.status always &&
715 git status --porcelain | test_decode_color >output &&
716 test_cmp expect output
720 # recover unconditionally from color tests
721 git config --unset color.status
722 git config --unset color.ui
724 test_expect_success 'status --porcelain respects -b' '
726 git status --porcelain -b >output &&
728 echo "## master" &&
729 cat expect
730 } >tmp &&
731 mv tmp expect &&
732 test_cmp expect output
738 test_expect_success 'status without relative paths' '
739 cat >expect <<\EOF &&
740 On branch master
741 Changes to be committed:
742 (use "git reset HEAD <file>..." to unstage)
744 new file: dir2/added
746 Changes not staged for commit:
747 (use "git add <file>..." to update what will be committed)
748 (use "git checkout -- <file>..." to discard changes in working directory)
750 modified: dir1/modified
752 Untracked files:
753 (use "git add <file>..." to include in what will be committed)
755 dir1/untracked
756 dir2/modified
757 dir2/untracked
758 expect
759 output
760 untracked
763 test_config status.relativePaths false &&
764 (cd dir1 && git status) >output &&
765 test_i18ncmp expect output
769 cat >expect <<\EOF
770 M dir1/modified
771 A dir2/added
772 ?? dir1/untracked
773 ?? dir2/modified
774 ?? dir2/untracked
775 ?? expect
776 ?? output
777 ?? untracked
780 test_expect_success 'status -s without relative paths' '
782 test_config status.relativePaths false &&
783 (cd dir1 && git status -s) >output &&
784 test_cmp expect output
788 test_expect_success 'dry-run of partial commit excluding new file in index' '
789 cat >expect <<EOF &&
790 On branch master
791 Changes to be committed:
792 (use "git reset HEAD <file>..." to unstage)
794 modified: dir1/modified
796 Untracked files:
797 (use "git add <file>..." to include in what will be committed)
799 dir1/untracked
800 dir2/
801 expect
802 output
803 untracked
806 git commit --dry-run dir1/modified >output &&
807 test_i18ncmp expect output
810 cat >expect <<EOF
811 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
813 test_expect_success 'status refreshes the index' '
814 touch dir2/added &&
815 git status &&
816 git diff-files >output &&
817 test_cmp expect output
820 test_expect_success 'setup status submodule summary' '
821 test_create_repo sm && (
822 cd sm &&
823 >foo &&
824 git add foo &&
825 git commit -m "Add foo"
826 ) &&
827 git add sm
830 test_expect_success 'status submodule summary is disabled by default' '
831 cat >expect <<EOF &&
832 On branch master
833 Changes to be committed:
834 (use "git reset HEAD <file>..." to unstage)
836 new file: dir2/added
837 new file: sm
839 Changes not staged for commit:
840 (use "git add <file>..." to update what will be committed)
841 (use "git checkout -- <file>..." to discard changes in working directory)
843 modified: dir1/modified
845 Untracked files:
846 (use "git add <file>..." to include in what will be committed)
848 dir1/untracked
849 dir2/modified
850 dir2/untracked
851 expect
852 output
853 untracked
856 git status >output &&
857 test_i18ncmp expect output
860 # we expect the same as the previous test
861 test_expect_success 'status --untracked-files=all does not show submodule' '
862 git status --untracked-files=all >output &&
863 test_i18ncmp expect output
866 cat >expect <<EOF
867 M dir1/modified
868 A dir2/added
869 A sm
870 ?? dir1/untracked
871 ?? dir2/modified
872 ?? dir2/untracked
873 ?? expect
874 ?? output
875 ?? untracked
877 test_expect_success 'status -s submodule summary is disabled by default' '
878 git status -s >output &&
879 test_cmp expect output
882 # we expect the same as the previous test
883 test_expect_success 'status -s --untracked-files=all does not show submodule' '
884 git status -s --untracked-files=all >output &&
885 test_cmp expect output
888 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
890 test_expect_success 'status submodule summary' '
891 cat >expect <<EOF &&
892 On branch master
893 Changes to be committed:
894 (use "git reset HEAD <file>..." to unstage)
896 new file: dir2/added
897 new file: sm
899 Changes not staged for commit:
900 (use "git add <file>..." to update what will be committed)
901 (use "git checkout -- <file>..." to discard changes in working directory)
903 modified: dir1/modified
905 Submodule changes to be committed:
907 * sm 0000000...$head (1):
908 > Add foo
910 Untracked files:
911 (use "git add <file>..." to include in what will be committed)
913 dir1/untracked
914 dir2/modified
915 dir2/untracked
916 expect
917 output
918 untracked
921 git config status.submodulesummary 10 &&
922 git status >output &&
923 test_i18ncmp expect output
926 test_expect_success 'status submodule summary with status.displayCommentPrefix=false' '
927 strip_comments expect &&
928 git -c status.displayCommentPrefix=false status >output &&
929 test_i18ncmp expect output
932 test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' '
933 commit_template_commented
936 cat >expect <<EOF
937 M dir1/modified
938 A dir2/added
939 A sm
940 ?? dir1/untracked
941 ?? dir2/modified
942 ?? dir2/untracked
943 ?? expect
944 ?? output
945 ?? untracked
947 test_expect_success 'status -s submodule summary' '
948 git status -s >output &&
949 test_cmp expect output
952 test_expect_success 'status submodule summary (clean submodule): commit' '
953 cat >expect <<EOF &&
954 On branch master
955 Changes not staged for commit:
956 (use "git add <file>..." to update what will be committed)
957 (use "git checkout -- <file>..." to discard changes in working directory)
959 modified: dir1/modified
961 Untracked files:
962 (use "git add <file>..." to include in what will be committed)
964 dir1/untracked
965 dir2/modified
966 dir2/untracked
967 expect
968 output
969 untracked
971 no changes added to commit (use "git add" and/or "git commit -a")
973 git commit -m "commit submodule" &&
974 git config status.submodulesummary 10 &&
975 test_must_fail git commit --dry-run >output &&
976 test_i18ncmp expect output &&
977 git status >output &&
978 test_i18ncmp expect output
981 cat >expect <<EOF
982 M dir1/modified
983 ?? dir1/untracked
984 ?? dir2/modified
985 ?? dir2/untracked
986 ?? expect
987 ?? output
988 ?? untracked
990 test_expect_success 'status -s submodule summary (clean submodule)' '
991 git status -s >output &&
992 test_cmp expect output
995 test_expect_success 'status -z implies porcelain' '
996 git status --porcelain |
997 perl -pe "s/\012/\000/g" >expect &&
998 git status -z >output &&
999 test_cmp expect output
1002 test_expect_success 'commit --dry-run submodule summary (--amend)' '
1003 cat >expect <<EOF &&
1004 On branch master
1005 Changes to be committed:
1006 (use "git reset HEAD^1 <file>..." to unstage)
1008 new file: dir2/added
1009 new file: sm
1011 Changes not staged for commit:
1012 (use "git add <file>..." to update what will be committed)
1013 (use "git checkout -- <file>..." to discard changes in working directory)
1015 modified: dir1/modified
1017 Submodule changes to be committed:
1019 * sm 0000000...$head (1):
1020 > Add foo
1022 Untracked files:
1023 (use "git add <file>..." to include in what will be committed)
1025 dir1/untracked
1026 dir2/modified
1027 dir2/untracked
1028 expect
1029 output
1030 untracked
1033 git config status.submodulesummary 10 &&
1034 git commit --dry-run --amend >output &&
1035 test_i18ncmp expect output
1038 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
1040 chmod a-w .git &&
1041 # make dir1/tracked stat-dirty
1042 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
1043 git status -s >output &&
1044 ! grep dir1/tracked output &&
1045 # make sure "status" succeeded without writing index out
1046 git diff-files | grep dir1/tracked
1048 status=$?
1049 chmod 775 .git
1050 (exit $status)
1053 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
1054 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
1055 touch .gitmodules
1057 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1058 cat > expect << EOF &&
1059 On branch master
1060 Changes to be committed:
1061 (use "git reset HEAD <file>..." to unstage)
1063 modified: sm
1065 Changes not staged for commit:
1066 (use "git add <file>..." to update what will be committed)
1067 (use "git checkout -- <file>..." to discard changes in working directory)
1069 modified: dir1/modified
1071 Submodule changes to be committed:
1073 * sm $head...$new_head (1):
1074 > Add bar
1076 Untracked files:
1077 (use "git add <file>..." to include in what will be committed)
1079 .gitmodules
1080 dir1/untracked
1081 dir2/modified
1082 dir2/untracked
1083 expect
1084 output
1085 untracked
1088 echo modified sm/untracked &&
1089 git status --ignore-submodules=untracked >output &&
1090 test_i18ncmp expect output
1093 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1094 test_config diff.ignoreSubmodules dirty &&
1095 git status >output &&
1096 test_i18ncmp expect output &&
1097 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1098 git config --add -f .gitmodules submodule.subname.path sm &&
1099 git status >output &&
1100 test_i18ncmp expect output &&
1101 git config -f .gitmodules --remove-section submodule.subname
1104 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1105 git config --add -f .gitmodules submodule.subname.ignore none &&
1106 git config --add -f .gitmodules submodule.subname.path sm &&
1107 git config --add submodule.subname.ignore untracked &&
1108 git config --add submodule.subname.path sm &&
1109 git status >output &&
1110 test_i18ncmp expect output &&
1111 git config --remove-section submodule.subname &&
1112 git config --remove-section -f .gitmodules submodule.subname
1115 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1116 git status --ignore-submodules=dirty >output &&
1117 test_i18ncmp expect output
1120 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1121 test_config diff.ignoreSubmodules dirty &&
1122 git status >output &&
1123 ! test -s actual &&
1124 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1125 git config --add -f .gitmodules submodule.subname.path sm &&
1126 git status >output &&
1127 test_i18ncmp expect output &&
1128 git config -f .gitmodules --remove-section submodule.subname
1131 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1132 git config --add -f .gitmodules submodule.subname.ignore none &&
1133 git config --add -f .gitmodules submodule.subname.path sm &&
1134 git config --add submodule.subname.ignore dirty &&
1135 git config --add submodule.subname.path sm &&
1136 git status >output &&
1137 test_i18ncmp expect output &&
1138 git config --remove-section submodule.subname &&
1139 git config -f .gitmodules --remove-section submodule.subname
1142 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1143 echo modified >sm/foo &&
1144 git status --ignore-submodules=dirty >output &&
1145 test_i18ncmp expect output
1148 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
1149 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1150 git config --add -f .gitmodules submodule.subname.path sm &&
1151 git status >output &&
1152 test_i18ncmp expect output &&
1153 git config -f .gitmodules --remove-section submodule.subname
1156 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
1157 git config --add -f .gitmodules submodule.subname.ignore none &&
1158 git config --add -f .gitmodules submodule.subname.path sm &&
1159 git config --add submodule.subname.ignore dirty &&
1160 git config --add submodule.subname.path sm &&
1161 git status >output &&
1162 test_i18ncmp expect output &&
1163 git config --remove-section submodule.subname &&
1164 git config -f .gitmodules --remove-section submodule.subname
1167 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1168 cat > expect << EOF &&
1169 On branch master
1170 Changes to be committed:
1171 (use "git reset HEAD <file>..." to unstage)
1173 modified: sm
1175 Changes not staged for commit:
1176 (use "git add <file>..." to update what will be committed)
1177 (use "git checkout -- <file>..." to discard changes in working directory)
1178 (commit or discard the untracked or modified content in submodules)
1180 modified: dir1/modified
1181 modified: sm (modified content)
1183 Submodule changes to be committed:
1185 * sm $head...$new_head (1):
1186 > Add bar
1188 Untracked files:
1189 (use "git add <file>..." to include in what will be committed)
1191 .gitmodules
1192 dir1/untracked
1193 dir2/modified
1194 dir2/untracked
1195 expect
1196 output
1197 untracked
1200 git status --ignore-submodules=untracked > output &&
1201 test_i18ncmp expect output
1204 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
1205 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1206 git config --add -f .gitmodules submodule.subname.path sm &&
1207 git status >output &&
1208 test_i18ncmp expect output &&
1209 git config -f .gitmodules --remove-section submodule.subname
1212 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1213 git config --add -f .gitmodules submodule.subname.ignore none &&
1214 git config --add -f .gitmodules submodule.subname.path sm &&
1215 git config --add submodule.subname.ignore untracked &&
1216 git config --add submodule.subname.path sm &&
1217 git status >output &&
1218 test_i18ncmp expect output &&
1219 git config --remove-section submodule.subname &&
1220 git config -f .gitmodules --remove-section submodule.subname
1223 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1225 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1226 cat > expect << EOF &&
1227 On branch master
1228 Changes to be committed:
1229 (use "git reset HEAD <file>..." to unstage)
1231 modified: sm
1233 Changes not staged for commit:
1234 (use "git add <file>..." to update what will be committed)
1235 (use "git checkout -- <file>..." to discard changes in working directory)
1237 modified: dir1/modified
1238 modified: sm (new commits)
1240 Submodule changes to be committed:
1242 * sm $head...$new_head (1):
1243 > Add bar
1245 Submodules changed but not updated:
1247 * sm $new_head...$head2 (1):
1248 > 2nd commit
1250 Untracked files:
1251 (use "git add <file>..." to include in what will be committed)
1253 .gitmodules
1254 dir1/untracked
1255 dir2/modified
1256 dir2/untracked
1257 expect
1258 output
1259 untracked
1262 git status --ignore-submodules=untracked > output &&
1263 test_i18ncmp expect output
1266 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1267 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1268 git config --add -f .gitmodules submodule.subname.path sm &&
1269 git status >output &&
1270 test_i18ncmp expect output &&
1271 git config -f .gitmodules --remove-section submodule.subname
1274 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1275 git config --add -f .gitmodules submodule.subname.ignore none &&
1276 git config --add -f .gitmodules submodule.subname.path sm &&
1277 git config --add submodule.subname.ignore untracked &&
1278 git config --add submodule.subname.path sm &&
1279 git status >output &&
1280 test_i18ncmp expect output &&
1281 git config --remove-section submodule.subname &&
1282 git config -f .gitmodules --remove-section submodule.subname
1285 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1286 git status --ignore-submodules=dirty > output &&
1287 test_i18ncmp expect output
1289 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1290 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1291 git config --add -f .gitmodules submodule.subname.path sm &&
1292 git status >output &&
1293 test_i18ncmp expect output &&
1294 git config -f .gitmodules --remove-section submodule.subname
1297 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1298 git config --add -f .gitmodules submodule.subname.ignore none &&
1299 git config --add -f .gitmodules submodule.subname.path sm &&
1300 git config --add submodule.subname.ignore dirty &&
1301 git config --add submodule.subname.path sm &&
1302 git status >output &&
1303 test_i18ncmp expect output &&
1304 git config --remove-section submodule.subname &&
1305 git config -f .gitmodules --remove-section submodule.subname
1308 cat > expect << EOF
1309 ; On branch master
1310 ; Changes to be committed:
1311 ; (use "git reset HEAD <file>..." to unstage)
1313 ; modified: sm
1315 ; Changes not staged for commit:
1316 ; (use "git add <file>..." to update what will be committed)
1317 ; (use "git checkout -- <file>..." to discard changes in working directory)
1319 ; modified: dir1/modified
1320 ; modified: sm (new commits)
1322 ; Submodule changes to be committed:
1324 ; * sm $head...$new_head (1):
1325 ; > Add bar
1327 ; Submodules changed but not updated:
1329 ; * sm $new_head...$head2 (1):
1330 ; > 2nd commit
1332 ; Untracked files:
1333 ; (use "git add <file>..." to include in what will be committed)
1335 ; .gitmodules
1336 ; dir1/untracked
1337 ; dir2/modified
1338 ; dir2/untracked
1339 ; expect
1340 ; output
1341 ; untracked
1345 test_expect_success "status (core.commentchar with submodule summary)" '
1346 test_config core.commentchar ";" &&
1347 git -c status.displayCommentPrefix=true status >output &&
1348 test_i18ncmp expect output
1351 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1352 test_config core.commentchar ";;" &&
1353 test_must_fail git -c status.displayCommentPrefix=true status
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_success '.gitmodules ignore=all suppresses unstaged submodule summary' '
1383 cat > expect << EOF &&
1384 On branch master
1385 Changes to be committed:
1386 (use "git reset HEAD <file>..." to unstage)
1388 modified: sm
1390 Changes not staged for commit:
1391 (use "git add <file>..." to update what will be committed)
1392 (use "git checkout -- <file>..." to discard changes in working directory)
1394 modified: dir1/modified
1396 Untracked files:
1397 (use "git add <file>..." to include in what will be committed)
1399 .gitmodules
1400 dir1/untracked
1401 dir2/modified
1402 dir2/untracked
1403 expect
1404 output
1405 untracked
1408 git config --add -f .gitmodules submodule.subname.ignore all &&
1409 git config --add -f .gitmodules submodule.subname.path sm &&
1410 git status > output &&
1411 test_cmp expect output &&
1412 git config -f .gitmodules --remove-section submodule.subname
1415 test_expect_success '.git/config ignore=all suppresses unstaged submodule summary' '
1416 git config --add -f .gitmodules submodule.subname.ignore none &&
1417 git config --add -f .gitmodules submodule.subname.path sm &&
1418 git config --add submodule.subname.ignore all &&
1419 git config --add submodule.subname.path sm &&
1420 git status > output &&
1421 test_cmp expect output &&
1422 git config --remove-section submodule.subname &&
1423 git config -f .gitmodules --remove-section submodule.subname
1426 test_expect_success 'setup of test environment' '
1427 git config status.showUntrackedFiles no &&
1428 git status -s >expected_short &&
1429 git status --no-short >expected_noshort
1432 test_expect_success '"status.short=true" same as "-s"' '
1433 git -c status.short=true status >actual &&
1434 test_cmp expected_short actual
1437 test_expect_success '"status.short=true" weaker than "--no-short"' '
1438 git -c status.short=true status --no-short >actual &&
1439 test_cmp expected_noshort actual
1442 test_expect_success '"status.short=false" same as "--no-short"' '
1443 git -c status.short=false status >actual &&
1444 test_cmp expected_noshort actual
1447 test_expect_success '"status.short=false" weaker than "-s"' '
1448 git -c status.short=false status -s >actual &&
1449 test_cmp expected_short actual
1452 test_expect_success '"status.branch=true" same as "-b"' '
1453 git status -sb >expected_branch &&
1454 git -c status.branch=true status -s >actual &&
1455 test_cmp expected_branch actual
1458 test_expect_success '"status.branch=true" different from "--no-branch"' '
1459 git status -s --no-branch >expected_nobranch &&
1460 git -c status.branch=true status -s >actual &&
1461 test_must_fail test_cmp expected_nobranch actual
1464 test_expect_success '"status.branch=true" weaker than "--no-branch"' '
1465 git -c status.branch=true status -s --no-branch >actual &&
1466 test_cmp expected_nobranch actual
1469 test_expect_success '"status.branch=true" weaker than "--porcelain"' '
1470 git -c status.branch=true status --porcelain >actual &&
1471 test_cmp expected_nobranch actual
1474 test_expect_success '"status.branch=false" same as "--no-branch"' '
1475 git -c status.branch=false status -s >actual &&
1476 test_cmp expected_nobranch actual
1479 test_expect_success '"status.branch=false" weaker than "-b"' '
1480 git -c status.branch=false status -sb >actual &&
1481 test_cmp expected_branch actual
1484 test_expect_success 'Restore default test environment' '
1485 git config --unset status.showUntrackedFiles
1488 test_expect_success 'git commit will commit a staged but ignored submodule' '
1489 git config --add -f .gitmodules submodule.subname.ignore all &&
1490 git config --add -f .gitmodules submodule.subname.path sm &&
1491 git config --add submodule.subname.ignore all &&
1492 git status -s --ignore-submodules=dirty >output &&
1493 test_i18ngrep "^M. sm" output &&
1494 GIT_EDITOR="echo hello >>\"\$1\"" &&
1495 export GIT_EDITOR &&
1496 git commit -uno &&
1497 git status -s --ignore-submodules=dirty >output &&
1498 test_i18ngrep ! "^M. sm" output
1501 test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '
1502 git reset HEAD^ &&
1503 git add sm &&
1504 cat >expect << EOF &&
1505 On branch master
1506 Changes to be committed:
1507 (use "git reset HEAD <file>..." to unstage)
1509 modified: sm
1511 Changes not staged for commit:
1512 (use "git add <file>..." to update what will be committed)
1513 (use "git checkout -- <file>..." to discard changes in working directory)
1515 modified: dir1/modified
1517 Untracked files not listed (use -u option to show untracked files)
1519 git commit -uno --dry-run >output &&
1520 test_i18ncmp expect output &&
1521 git status -s --ignore-submodules=dirty >output &&
1522 test_i18ngrep "^M. sm" output
1525 test_expect_success 'git commit -m will commit a staged but ignored submodule' '
1526 git commit -uno -m message &&
1527 git status -s --ignore-submodules=dirty >output &&
1528 test_i18ngrep ! "^M. sm" output &&
1529 git config --remove-section submodule.subname &&
1530 git config -f .gitmodules --remove-section submodule.subname
1533 test_done