Merge branch 'master' of git://repo.or.cz/git/jrn.git
[git/mingw.git] / t / t7508-status.sh
blobb143ebed764d12308160669ddc66c005da6ff867
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='git status'
8 case $(uname -s) in
9 *MINGW*) GIT_TEST_CMP="diff -uw";;
10 esac
12 . ./test-lib.sh
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 tab=' '
69 sed "s/^\# //; s/^\#$//; s/^#$tab/$tab/" <"$1" >"$1".tmp &&
70 rm "$1" && mv "$1".tmp "$1"
73 test_expect_success 'status --column' '
74 cat >expect <<\EOF &&
75 # On branch master
76 # Changes to be committed:
77 # (use "git reset HEAD <file>..." to unstage)
79 # new file: dir2/added
81 # Changes not staged for commit:
82 # (use "git add <file>..." to update what will be committed)
83 # (use "git checkout -- <file>..." to discard changes in working directory)
85 # modified: dir1/modified
87 # Untracked files:
88 # (use "git add <file>..." to include in what will be committed)
90 # dir1/untracked dir2/untracked output
91 # dir2/modified expect untracked
93 EOF
94 COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
95 test_i18ncmp expect output
98 test_expect_success 'status --column status.displayCommentPrefix=false' '
99 strip_comments expect &&
100 COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
101 test_i18ncmp expect output
104 cat >expect <<\EOF
105 # On branch master
106 # Changes to be committed:
107 # (use "git reset HEAD <file>..." to unstage)
109 # new file: dir2/added
111 # Changes not staged for commit:
112 # (use "git add <file>..." to update what will be committed)
113 # (use "git checkout -- <file>..." to discard changes in working directory)
115 # modified: dir1/modified
117 # Untracked files:
118 # (use "git add <file>..." to include in what will be committed)
120 # dir1/untracked
121 # dir2/modified
122 # dir2/untracked
123 # expect
124 # output
125 # untracked
129 test_expect_success 'status with status.displayCommentPrefix=true' '
130 git -c status.displayCommentPrefix=true status >output &&
131 test_i18ncmp expect output
134 test_expect_success 'status with status.displayCommentPrefix=false' '
135 strip_comments expect &&
136 git -c status.displayCommentPrefix=false status >output &&
137 test_i18ncmp expect output
140 test_expect_success 'setup fake editor' '
141 cat >.git/editor <<-\EOF &&
142 #! /bin/sh
143 cp "$1" output
145 chmod 755 .git/editor
148 commit_template_commented () {
150 EDITOR=.git/editor &&
151 export EDITOR &&
152 # Fails due to empty message
153 test_must_fail git commit
154 ) &&
155 ! grep '^[^#]' output
158 test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
159 commit_template_commented
162 cat >expect <<\EOF
163 On branch master
164 Changes to be committed:
165 new file: dir2/added
167 Changes not staged for commit:
168 modified: dir1/modified
170 Untracked files:
171 dir1/untracked
172 dir2/modified
173 dir2/untracked
174 expect
175 output
176 untracked
180 test_expect_success 'status (advice.statusHints false)' '
181 test_config advice.statusHints false &&
182 git status >output &&
183 test_i18ncmp expect output
187 cat >expect <<\EOF
188 M dir1/modified
189 A dir2/added
190 ?? dir1/untracked
191 ?? dir2/modified
192 ?? dir2/untracked
193 ?? expect
194 ?? output
195 ?? untracked
198 test_expect_success 'status -s' '
200 git status -s >output &&
201 test_cmp expect output
205 test_expect_success 'status with gitignore' '
207 echo ".gitignore" &&
208 echo "expect" &&
209 echo "output" &&
210 echo "untracked"
211 } >.gitignore &&
213 cat >expect <<-\EOF &&
214 M dir1/modified
215 A dir2/added
216 ?? dir2/modified
218 git status -s >output &&
219 test_cmp expect output &&
221 cat >expect <<-\EOF &&
222 M dir1/modified
223 A dir2/added
224 ?? dir2/modified
225 !! .gitignore
226 !! dir1/untracked
227 !! dir2/untracked
228 !! expect
229 !! output
230 !! untracked
232 git status -s --ignored >output &&
233 test_cmp expect output &&
235 cat >expect <<\EOF &&
236 On branch master
237 Changes to be committed:
238 (use "git reset HEAD <file>..." to unstage)
240 new file: dir2/added
242 Changes not staged for commit:
243 (use "git add <file>..." to update what will be committed)
244 (use "git checkout -- <file>..." to discard changes in working directory)
246 modified: dir1/modified
248 Untracked files:
249 (use "git add <file>..." to include in what will be committed)
251 dir2/modified
253 Ignored files:
254 (use "git add -f <file>..." to include in what will be committed)
256 .gitignore
257 dir1/untracked
258 dir2/untracked
259 expect
260 output
261 untracked
264 git status --ignored >output &&
265 test_i18ncmp expect output
268 test_expect_success 'status with gitignore (nothing untracked)' '
270 echo ".gitignore" &&
271 echo "expect" &&
272 echo "dir2/modified" &&
273 echo "output" &&
274 echo "untracked"
275 } >.gitignore &&
277 cat >expect <<-\EOF &&
278 M dir1/modified
279 A dir2/added
281 git status -s >output &&
282 test_cmp expect output &&
284 cat >expect <<-\EOF &&
285 M dir1/modified
286 A dir2/added
287 !! .gitignore
288 !! dir1/untracked
289 !! dir2/modified
290 !! dir2/untracked
291 !! expect
292 !! output
293 !! untracked
295 git status -s --ignored >output &&
296 test_cmp expect output &&
298 cat >expect <<\EOF &&
299 On branch master
300 Changes to be committed:
301 (use "git reset HEAD <file>..." to unstage)
303 new file: dir2/added
305 Changes not staged for commit:
306 (use "git add <file>..." to update what will be committed)
307 (use "git checkout -- <file>..." to discard changes in working directory)
309 modified: dir1/modified
311 Ignored files:
312 (use "git add -f <file>..." to include in what will be committed)
314 .gitignore
315 dir1/untracked
316 dir2/modified
317 dir2/untracked
318 expect
319 output
320 untracked
323 git status --ignored >output &&
324 test_i18ncmp expect output
327 rm -f .gitignore
329 cat >expect <<\EOF
330 ## master
331 M dir1/modified
332 A dir2/added
333 ?? dir1/untracked
334 ?? dir2/modified
335 ?? dir2/untracked
336 ?? expect
337 ?? output
338 ?? untracked
341 test_expect_success 'status -s -b' '
343 git status -s -b >output &&
344 test_cmp expect output
348 test_expect_success 'status -s -z -b' '
349 tr "\\n" Q <expect >expect.q &&
350 mv expect.q expect &&
351 git status -s -z -b >output &&
352 nul_to_q <output >output.q &&
353 mv output.q output &&
354 test_cmp expect output
357 test_expect_success 'setup dir3' '
358 mkdir dir3 &&
359 : >dir3/untracked1 &&
360 : >dir3/untracked2
363 test_expect_success 'status -uno' '
364 cat >expect <<EOF &&
365 On branch master
366 Changes to be committed:
367 (use "git reset HEAD <file>..." to unstage)
369 new file: dir2/added
371 Changes not staged for commit:
372 (use "git add <file>..." to update what will be committed)
373 (use "git checkout -- <file>..." to discard changes in working directory)
375 modified: dir1/modified
377 Untracked files not listed (use -u option to show untracked files)
379 git status -uno >output &&
380 test_i18ncmp expect output
383 test_expect_success 'status (status.showUntrackedFiles no)' '
384 test_config status.showuntrackedfiles no &&
385 git status >output &&
386 test_i18ncmp expect output
389 test_expect_success 'status -uno (advice.statusHints false)' '
390 cat >expect <<EOF &&
391 On branch master
392 Changes to be committed:
393 new file: dir2/added
395 Changes not staged for commit:
396 modified: dir1/modified
398 Untracked files not listed
400 test_config advice.statusHints false &&
401 git status -uno >output &&
402 test_i18ncmp expect output
405 cat >expect << EOF
406 M dir1/modified
407 A dir2/added
409 test_expect_success 'status -s -uno' '
410 git status -s -uno >output &&
411 test_cmp expect output
414 test_expect_success 'status -s (status.showUntrackedFiles no)' '
415 git config status.showuntrackedfiles no
416 git status -s >output &&
417 test_cmp expect output
420 test_expect_success 'status -unormal' '
421 cat >expect <<EOF &&
422 On branch master
423 Changes to be committed:
424 (use "git reset HEAD <file>..." to unstage)
426 new file: dir2/added
428 Changes not staged for commit:
429 (use "git add <file>..." to update what will be committed)
430 (use "git checkout -- <file>..." to discard changes in working directory)
432 modified: dir1/modified
434 Untracked files:
435 (use "git add <file>..." to include in what will be committed)
437 dir1/untracked
438 dir2/modified
439 dir2/untracked
440 dir3/
441 expect
442 output
443 untracked
446 git status -unormal >output &&
447 test_i18ncmp expect output
450 test_expect_success 'status (status.showUntrackedFiles normal)' '
451 test_config status.showuntrackedfiles normal
452 git status >output &&
453 test_i18ncmp expect output
456 cat >expect <<EOF
457 M dir1/modified
458 A dir2/added
459 ?? dir1/untracked
460 ?? dir2/modified
461 ?? dir2/untracked
462 ?? dir3/
463 ?? expect
464 ?? output
465 ?? untracked
467 test_expect_success 'status -s -unormal' '
468 git status -s -unormal >output &&
469 test_cmp expect output
472 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
473 git config status.showuntrackedfiles normal
474 git status -s >output &&
475 test_cmp expect output
478 test_expect_success 'status -uall' '
479 cat >expect <<EOF &&
480 On branch master
481 Changes to be committed:
482 (use "git reset HEAD <file>..." to unstage)
484 new file: dir2/added
486 Changes not staged for commit:
487 (use "git add <file>..." to update what will be committed)
488 (use "git checkout -- <file>..." to discard changes in working directory)
490 modified: dir1/modified
492 Untracked files:
493 (use "git add <file>..." to include in what will be committed)
495 dir1/untracked
496 dir2/modified
497 dir2/untracked
498 dir3/untracked1
499 dir3/untracked2
500 expect
501 output
502 untracked
505 git status -uall >output &&
506 test_i18ncmp expect output
509 test_expect_success 'status (status.showUntrackedFiles all)' '
510 test_config status.showuntrackedfiles all
511 git status >output &&
512 test_i18ncmp expect output
515 test_expect_success 'teardown dir3' '
516 rm -rf dir3
519 cat >expect <<EOF
520 M dir1/modified
521 A dir2/added
522 ?? dir1/untracked
523 ?? dir2/modified
524 ?? dir2/untracked
525 ?? expect
526 ?? output
527 ?? untracked
529 test_expect_success 'status -s -uall' '
530 git config --unset status.showuntrackedfiles
531 git status -s -uall >output &&
532 test_cmp expect output
534 test_expect_success 'status -s (status.showUntrackedFiles all)' '
535 test_config status.showuntrackedfiles all &&
536 git status -s >output &&
537 rm -rf dir3 &&
538 test_cmp expect output
541 test_expect_success 'status with relative paths' '
542 cat >expect <<\EOF &&
543 On branch master
544 Changes to be committed:
545 (use "git reset HEAD <file>..." to unstage)
547 new file: ../dir2/added
549 Changes not staged for commit:
550 (use "git add <file>..." to update what will be committed)
551 (use "git checkout -- <file>..." to discard changes in working directory)
553 modified: modified
555 Untracked files:
556 (use "git add <file>..." to include in what will be committed)
558 untracked
559 ../dir2/modified
560 ../dir2/untracked
561 ../expect
562 ../output
563 ../untracked
566 (cd dir1 && git status) >output &&
567 test_i18ncmp expect output
570 cat >expect <<\EOF
571 M modified
572 A ../dir2/added
573 ?? untracked
574 ?? ../dir2/modified
575 ?? ../dir2/untracked
576 ?? ../expect
577 ?? ../output
578 ?? ../untracked
580 test_expect_success 'status -s with relative paths' '
582 (cd dir1 && git status -s) >output &&
583 test_cmp expect output
587 cat >expect <<\EOF
588 M dir1/modified
589 A dir2/added
590 ?? dir1/untracked
591 ?? dir2/modified
592 ?? dir2/untracked
593 ?? expect
594 ?? output
595 ?? untracked
598 test_expect_success 'status --porcelain ignores relative paths setting' '
600 (cd dir1 && git status --porcelain) >output &&
601 test_cmp expect output
605 test_expect_success 'setup unique colors' '
607 git config status.color.untracked blue &&
608 git config status.color.branch green
612 test_expect_success 'status with color.ui' '
613 cat >expect <<\EOF &&
614 On branch <GREEN>master<RESET>
615 Changes to be committed:
616 (use "git reset HEAD <file>..." to unstage)
618 <GREEN>new file: dir2/added<RESET>
620 Changes not staged for commit:
621 (use "git add <file>..." to update what will be committed)
622 (use "git checkout -- <file>..." to discard changes in working directory)
624 <RED>modified: dir1/modified<RESET>
626 Untracked files:
627 (use "git add <file>..." to include in what will be committed)
629 <BLUE>dir1/untracked<RESET>
630 <BLUE>dir2/modified<RESET>
631 <BLUE>dir2/untracked<RESET>
632 <BLUE>expect<RESET>
633 <BLUE>output<RESET>
634 <BLUE>untracked<RESET>
637 test_config color.ui always &&
638 git status | test_decode_color >output &&
639 test_i18ncmp expect output
642 test_expect_success 'status with color.status' '
643 test_config color.status always &&
644 git status | test_decode_color >output &&
645 test_i18ncmp expect output
648 cat >expect <<\EOF
649 <RED>M<RESET> dir1/modified
650 <GREEN>A<RESET> dir2/added
651 <BLUE>??<RESET> dir1/untracked
652 <BLUE>??<RESET> dir2/modified
653 <BLUE>??<RESET> dir2/untracked
654 <BLUE>??<RESET> expect
655 <BLUE>??<RESET> output
656 <BLUE>??<RESET> untracked
659 test_expect_success 'status -s with color.ui' '
661 git config color.ui always &&
662 git status -s | test_decode_color >output &&
663 test_cmp expect output
667 test_expect_success 'status -s with color.status' '
669 git config --unset color.ui &&
670 git config color.status always &&
671 git status -s | test_decode_color >output &&
672 test_cmp expect output
676 cat >expect <<\EOF
677 ## <GREEN>master<RESET>
678 <RED>M<RESET> dir1/modified
679 <GREEN>A<RESET> dir2/added
680 <BLUE>??<RESET> dir1/untracked
681 <BLUE>??<RESET> dir2/modified
682 <BLUE>??<RESET> dir2/untracked
683 <BLUE>??<RESET> expect
684 <BLUE>??<RESET> output
685 <BLUE>??<RESET> untracked
688 test_expect_success 'status -s -b with color.status' '
690 git status -s -b | test_decode_color >output &&
691 test_cmp expect output
695 cat >expect <<\EOF
696 M dir1/modified
697 A dir2/added
698 ?? dir1/untracked
699 ?? dir2/modified
700 ?? dir2/untracked
701 ?? expect
702 ?? output
703 ?? untracked
706 test_expect_success 'status --porcelain ignores color.ui' '
708 git config --unset color.status &&
709 git config color.ui always &&
710 git status --porcelain | test_decode_color >output &&
711 test_cmp expect output
715 test_expect_success 'status --porcelain ignores color.status' '
717 git config --unset color.ui &&
718 git config color.status always &&
719 git status --porcelain | test_decode_color >output &&
720 test_cmp expect output
724 # recover unconditionally from color tests
725 git config --unset color.status
726 git config --unset color.ui
728 test_expect_success 'status --porcelain respects -b' '
730 git status --porcelain -b >output &&
732 echo "## master" &&
733 cat expect
734 } >tmp &&
735 mv tmp expect &&
736 test_cmp expect output
742 test_expect_success 'status without relative paths' '
743 cat >expect <<\EOF &&
744 On branch master
745 Changes to be committed:
746 (use "git reset HEAD <file>..." to unstage)
748 new file: dir2/added
750 Changes not staged for commit:
751 (use "git add <file>..." to update what will be committed)
752 (use "git checkout -- <file>..." to discard changes in working directory)
754 modified: dir1/modified
756 Untracked files:
757 (use "git add <file>..." to include in what will be committed)
759 dir1/untracked
760 dir2/modified
761 dir2/untracked
762 expect
763 output
764 untracked
767 test_config status.relativePaths false &&
768 (cd dir1 && git status) >output &&
769 test_i18ncmp expect output
773 cat >expect <<\EOF
774 M dir1/modified
775 A dir2/added
776 ?? dir1/untracked
777 ?? dir2/modified
778 ?? dir2/untracked
779 ?? expect
780 ?? output
781 ?? untracked
784 test_expect_success 'status -s without relative paths' '
786 test_config status.relativePaths false &&
787 (cd dir1 && git status -s) >output &&
788 test_cmp expect output
792 test_expect_success 'dry-run of partial commit excluding new file in index' '
793 cat >expect <<EOF &&
794 On branch master
795 Changes to be committed:
796 (use "git reset HEAD <file>..." to unstage)
798 modified: dir1/modified
800 Untracked files:
801 (use "git add <file>..." to include in what will be committed)
803 dir1/untracked
804 dir2/
805 expect
806 output
807 untracked
810 git commit --dry-run dir1/modified >output &&
811 test_i18ncmp expect output
814 cat >expect <<EOF
815 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
817 test_expect_success 'status refreshes the index' '
818 touch dir2/added &&
819 git status &&
820 git diff-files >output &&
821 test_cmp expect output
824 test_expect_success 'setup status submodule summary' '
825 test_create_repo sm && (
826 cd sm &&
827 >foo &&
828 git add foo &&
829 git commit -m "Add foo"
830 ) &&
831 git add sm
834 test_expect_success 'status submodule summary is disabled by default' '
835 cat >expect <<EOF &&
836 On branch master
837 Changes to be committed:
838 (use "git reset HEAD <file>..." to unstage)
840 new file: dir2/added
841 new file: sm
843 Changes not staged for commit:
844 (use "git add <file>..." to update what will be committed)
845 (use "git checkout -- <file>..." to discard changes in working directory)
847 modified: dir1/modified
849 Untracked files:
850 (use "git add <file>..." to include in what will be committed)
852 dir1/untracked
853 dir2/modified
854 dir2/untracked
855 expect
856 output
857 untracked
860 git status >output &&
861 test_i18ncmp expect output
864 # we expect the same as the previous test
865 test_expect_success 'status --untracked-files=all does not show submodule' '
866 git status --untracked-files=all >output &&
867 test_i18ncmp expect output
870 cat >expect <<EOF
871 M dir1/modified
872 A dir2/added
873 A sm
874 ?? dir1/untracked
875 ?? dir2/modified
876 ?? dir2/untracked
877 ?? expect
878 ?? output
879 ?? untracked
881 test_expect_success 'status -s submodule summary is disabled by default' '
882 git status -s >output &&
883 test_cmp expect output
886 # we expect the same as the previous test
887 test_expect_success 'status -s --untracked-files=all does not show submodule' '
888 git status -s --untracked-files=all >output &&
889 test_cmp expect output
892 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
894 test_expect_success 'status submodule summary' '
895 cat >expect <<EOF &&
896 On branch master
897 Changes to be committed:
898 (use "git reset HEAD <file>..." to unstage)
900 new file: dir2/added
901 new file: sm
903 Changes not staged for commit:
904 (use "git add <file>..." to update what will be committed)
905 (use "git checkout -- <file>..." to discard changes in working directory)
907 modified: dir1/modified
909 Submodule changes to be committed:
911 * sm 0000000...$head (1):
912 > Add foo
914 Untracked files:
915 (use "git add <file>..." to include in what will be committed)
917 dir1/untracked
918 dir2/modified
919 dir2/untracked
920 expect
921 output
922 untracked
925 git config status.submodulesummary 10 &&
926 git status >output &&
927 test_i18ncmp expect output
930 test_expect_success 'status submodule summary with status.displayCommentPrefix=false' '
931 strip_comments expect &&
932 git -c status.displayCommentPrefix=false status >output &&
933 test_i18ncmp expect output
936 test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' '
937 commit_template_commented
940 cat >expect <<EOF
941 M dir1/modified
942 A dir2/added
943 A sm
944 ?? dir1/untracked
945 ?? dir2/modified
946 ?? dir2/untracked
947 ?? expect
948 ?? output
949 ?? untracked
951 test_expect_success 'status -s submodule summary' '
952 git status -s >output &&
953 test_cmp expect output
956 test_expect_success 'status submodule summary (clean submodule): commit' '
957 cat >expect <<EOF &&
958 On branch master
959 Changes not staged for commit:
960 (use "git add <file>..." to update what will be committed)
961 (use "git checkout -- <file>..." to discard changes in working directory)
963 modified: dir1/modified
965 Untracked files:
966 (use "git add <file>..." to include in what will be committed)
968 dir1/untracked
969 dir2/modified
970 dir2/untracked
971 expect
972 output
973 untracked
975 no changes added to commit (use "git add" and/or "git commit -a")
977 git commit -m "commit submodule" &&
978 git config status.submodulesummary 10 &&
979 test_must_fail git commit --dry-run >output &&
980 test_i18ncmp expect output &&
981 git status >output &&
982 test_i18ncmp expect output
985 cat >expect <<EOF
986 M dir1/modified
987 ?? dir1/untracked
988 ?? dir2/modified
989 ?? dir2/untracked
990 ?? expect
991 ?? output
992 ?? untracked
994 test_expect_success 'status -s submodule summary (clean submodule)' '
995 git status -s >output &&
996 test_cmp expect output
999 test_expect_success 'status -z implies porcelain' '
1000 git status --porcelain |
1001 "$PERL_PATH" -pe "s/\012/\000/g" >expect &&
1002 git status -z >output &&
1003 test_cmp expect output
1006 test_expect_success 'commit --dry-run submodule summary (--amend)' '
1007 cat >expect <<EOF &&
1008 On branch master
1009 Changes to be committed:
1010 (use "git reset HEAD^1 <file>..." to unstage)
1012 new file: dir2/added
1013 new file: sm
1015 Changes not staged for commit:
1016 (use "git add <file>..." to update what will be committed)
1017 (use "git checkout -- <file>..." to discard changes in working directory)
1019 modified: dir1/modified
1021 Submodule changes to be committed:
1023 * sm 0000000...$head (1):
1024 > Add foo
1026 Untracked files:
1027 (use "git add <file>..." to include in what will be committed)
1029 dir1/untracked
1030 dir2/modified
1031 dir2/untracked
1032 expect
1033 output
1034 untracked
1037 git config status.submodulesummary 10 &&
1038 git commit --dry-run --amend >output &&
1039 test_i18ncmp expect output
1042 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
1044 chmod a-w .git &&
1045 # make dir1/tracked stat-dirty
1046 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
1047 git status -s >output &&
1048 ! grep dir1/tracked output &&
1049 # make sure "status" succeeded without writing index out
1050 git diff-files | grep dir1/tracked
1052 status=$?
1053 chmod 775 .git
1054 (exit $status)
1057 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
1058 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
1059 touch .gitmodules
1061 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1062 cat > expect << EOF &&
1063 On branch master
1064 Changes to be committed:
1065 (use "git reset HEAD <file>..." to unstage)
1067 modified: sm
1069 Changes not staged for commit:
1070 (use "git add <file>..." to update what will be committed)
1071 (use "git checkout -- <file>..." to discard changes in working directory)
1073 modified: dir1/modified
1075 Submodule changes to be committed:
1077 * sm $head...$new_head (1):
1078 > Add bar
1080 Untracked files:
1081 (use "git add <file>..." to include in what will be committed)
1083 .gitmodules
1084 dir1/untracked
1085 dir2/modified
1086 dir2/untracked
1087 expect
1088 output
1089 untracked
1092 echo modified sm/untracked &&
1093 git status --ignore-submodules=untracked >output &&
1094 test_i18ncmp expect output
1097 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1098 test_config diff.ignoreSubmodules dirty &&
1099 git status >output &&
1100 test_i18ncmp expect output &&
1101 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1102 git config --add -f .gitmodules submodule.subname.path sm &&
1103 git status >output &&
1104 test_i18ncmp expect output &&
1105 git config -f .gitmodules --remove-section submodule.subname
1108 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1109 git config --add -f .gitmodules submodule.subname.ignore none &&
1110 git config --add -f .gitmodules submodule.subname.path sm &&
1111 git config --add submodule.subname.ignore untracked &&
1112 git config --add submodule.subname.path sm &&
1113 git status >output &&
1114 test_i18ncmp expect output &&
1115 git config --remove-section submodule.subname &&
1116 git config --remove-section -f .gitmodules submodule.subname
1119 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1120 git status --ignore-submodules=dirty >output &&
1121 test_i18ncmp expect output
1124 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1125 test_config diff.ignoreSubmodules dirty &&
1126 git status >output &&
1127 ! test -s actual &&
1128 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1129 git config --add -f .gitmodules submodule.subname.path sm &&
1130 git status >output &&
1131 test_i18ncmp expect output &&
1132 git config -f .gitmodules --remove-section submodule.subname
1135 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1136 git config --add -f .gitmodules submodule.subname.ignore none &&
1137 git config --add -f .gitmodules submodule.subname.path sm &&
1138 git config --add submodule.subname.ignore dirty &&
1139 git config --add submodule.subname.path sm &&
1140 git status >output &&
1141 test_i18ncmp expect output &&
1142 git config --remove-section submodule.subname &&
1143 git config -f .gitmodules --remove-section submodule.subname
1146 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1147 echo modified >sm/foo &&
1148 git status --ignore-submodules=dirty >output &&
1149 test_i18ncmp expect output
1152 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
1153 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1154 git config --add -f .gitmodules submodule.subname.path sm &&
1155 git status >output &&
1156 test_i18ncmp expect output &&
1157 git config -f .gitmodules --remove-section submodule.subname
1160 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
1161 git config --add -f .gitmodules submodule.subname.ignore none &&
1162 git config --add -f .gitmodules submodule.subname.path sm &&
1163 git config --add submodule.subname.ignore dirty &&
1164 git config --add submodule.subname.path sm &&
1165 git status >output &&
1166 test_i18ncmp expect output &&
1167 git config --remove-section submodule.subname &&
1168 git config -f .gitmodules --remove-section submodule.subname
1171 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1172 cat > expect << EOF &&
1173 On branch master
1174 Changes to be committed:
1175 (use "git reset HEAD <file>..." to unstage)
1177 modified: sm
1179 Changes not staged for commit:
1180 (use "git add <file>..." to update what will be committed)
1181 (use "git checkout -- <file>..." to discard changes in working directory)
1182 (commit or discard the untracked or modified content in submodules)
1184 modified: dir1/modified
1185 modified: sm (modified content)
1187 Submodule changes to be committed:
1189 * sm $head...$new_head (1):
1190 > Add bar
1192 Untracked files:
1193 (use "git add <file>..." to include in what will be committed)
1195 .gitmodules
1196 dir1/untracked
1197 dir2/modified
1198 dir2/untracked
1199 expect
1200 output
1201 untracked
1204 git status --ignore-submodules=untracked > output &&
1205 test_i18ncmp expect output
1208 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
1209 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1210 git config --add -f .gitmodules submodule.subname.path sm &&
1211 git status >output &&
1212 test_i18ncmp expect output &&
1213 git config -f .gitmodules --remove-section submodule.subname
1216 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1217 git config --add -f .gitmodules submodule.subname.ignore none &&
1218 git config --add -f .gitmodules submodule.subname.path sm &&
1219 git config --add submodule.subname.ignore untracked &&
1220 git config --add submodule.subname.path sm &&
1221 git status >output &&
1222 test_i18ncmp expect output &&
1223 git config --remove-section submodule.subname &&
1224 git config -f .gitmodules --remove-section submodule.subname
1227 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1229 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1230 cat > expect << EOF &&
1231 On branch master
1232 Changes to be committed:
1233 (use "git reset HEAD <file>..." to unstage)
1235 modified: sm
1237 Changes not staged for commit:
1238 (use "git add <file>..." to update what will be committed)
1239 (use "git checkout -- <file>..." to discard changes in working directory)
1241 modified: dir1/modified
1242 modified: sm (new commits)
1244 Submodule changes to be committed:
1246 * sm $head...$new_head (1):
1247 > Add bar
1249 Submodules changed but not updated:
1251 * sm $new_head...$head2 (1):
1252 > 2nd commit
1254 Untracked files:
1255 (use "git add <file>..." to include in what will be committed)
1257 .gitmodules
1258 dir1/untracked
1259 dir2/modified
1260 dir2/untracked
1261 expect
1262 output
1263 untracked
1266 git status --ignore-submodules=untracked > output &&
1267 test_i18ncmp expect output
1270 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1271 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1272 git config --add -f .gitmodules submodule.subname.path sm &&
1273 git status >output &&
1274 test_i18ncmp expect output &&
1275 git config -f .gitmodules --remove-section submodule.subname
1278 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1279 git config --add -f .gitmodules submodule.subname.ignore none &&
1280 git config --add -f .gitmodules submodule.subname.path sm &&
1281 git config --add submodule.subname.ignore untracked &&
1282 git config --add submodule.subname.path sm &&
1283 git status >output &&
1284 test_i18ncmp expect output &&
1285 git config --remove-section submodule.subname &&
1286 git config -f .gitmodules --remove-section submodule.subname
1289 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1290 git status --ignore-submodules=dirty > output &&
1291 test_i18ncmp expect output
1293 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1294 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1295 git config --add -f .gitmodules submodule.subname.path sm &&
1296 git status >output &&
1297 test_i18ncmp expect output &&
1298 git config -f .gitmodules --remove-section submodule.subname
1301 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1302 git config --add -f .gitmodules submodule.subname.ignore none &&
1303 git config --add -f .gitmodules submodule.subname.path sm &&
1304 git config --add submodule.subname.ignore dirty &&
1305 git config --add submodule.subname.path sm &&
1306 git status >output &&
1307 test_i18ncmp expect output &&
1308 git config --remove-section submodule.subname &&
1309 git config -f .gitmodules --remove-section submodule.subname
1312 cat > expect << EOF
1313 ; On branch master
1314 ; Changes to be committed:
1315 ; (use "git reset HEAD <file>..." to unstage)
1317 ; modified: sm
1319 ; Changes not staged for commit:
1320 ; (use "git add <file>..." to update what will be committed)
1321 ; (use "git checkout -- <file>..." to discard changes in working directory)
1323 ; modified: dir1/modified
1324 ; modified: sm (new commits)
1326 ; Submodule changes to be committed:
1328 ; * sm $head...$new_head (1):
1329 ; > Add bar
1331 ; Submodules changed but not updated:
1333 ; * sm $new_head...$head2 (1):
1334 ; > 2nd commit
1336 ; Untracked files:
1337 ; (use "git add <file>..." to include in what will be committed)
1339 ; .gitmodules
1340 ; dir1/untracked
1341 ; dir2/modified
1342 ; dir2/untracked
1343 ; expect
1344 ; output
1345 ; untracked
1349 test_expect_success "status (core.commentchar with submodule summary)" '
1350 test_config core.commentchar ";" &&
1351 git -c status.displayCommentPrefix=true status >output &&
1352 test_i18ncmp expect output
1355 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1356 test_config core.commentchar ";;" &&
1357 git -c status.displayCommentPrefix=true status >output &&
1358 test_i18ncmp expect output
1361 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1362 cat > expect << EOF &&
1363 On branch master
1364 Changes not staged for commit:
1365 (use "git add <file>..." to update what will be committed)
1366 (use "git checkout -- <file>..." to discard changes in working directory)
1368 modified: dir1/modified
1370 Untracked files:
1371 (use "git add <file>..." to include in what will be committed)
1373 .gitmodules
1374 dir1/untracked
1375 dir2/modified
1376 dir2/untracked
1377 expect
1378 output
1379 untracked
1381 no changes added to commit (use "git add" and/or "git commit -a")
1383 git status --ignore-submodules=all > output &&
1384 test_i18ncmp expect output
1387 test_expect_success '.gitmodules ignore=all suppresses submodule summary' '
1388 git config --add -f .gitmodules submodule.subname.ignore all &&
1389 git config --add -f .gitmodules submodule.subname.path sm &&
1390 git status > output &&
1391 test_cmp expect output &&
1392 git config -f .gitmodules --remove-section submodule.subname
1395 test_expect_success '.git/config ignore=all suppresses submodule summary' '
1396 git config --add -f .gitmodules submodule.subname.ignore none &&
1397 git config --add -f .gitmodules submodule.subname.path sm &&
1398 git config --add submodule.subname.ignore all &&
1399 git config --add submodule.subname.path sm &&
1400 git status > output &&
1401 test_cmp expect output &&
1402 git config --remove-section submodule.subname &&
1403 git config -f .gitmodules --remove-section submodule.subname
1406 test_expect_success 'setup of test environment' '
1407 git config status.showUntrackedFiles no &&
1408 git status -s >expected_short &&
1409 git status --no-short >expected_noshort
1412 test_expect_success '"status.short=true" same as "-s"' '
1413 git -c status.short=true status >actual &&
1414 test_cmp expected_short actual
1417 test_expect_success '"status.short=true" weaker than "--no-short"' '
1418 git -c status.short=true status --no-short >actual &&
1419 test_cmp expected_noshort actual
1422 test_expect_success '"status.short=false" same as "--no-short"' '
1423 git -c status.short=false status >actual &&
1424 test_cmp expected_noshort actual
1427 test_expect_success '"status.short=false" weaker than "-s"' '
1428 git -c status.short=false status -s >actual &&
1429 test_cmp expected_short actual
1432 test_expect_success '"status.branch=true" same as "-b"' '
1433 git status -sb >expected_branch &&
1434 git -c status.branch=true status -s >actual &&
1435 test_cmp expected_branch actual
1438 test_expect_success '"status.branch=true" different from "--no-branch"' '
1439 git status -s --no-branch >expected_nobranch &&
1440 git -c status.branch=true status -s >actual &&
1441 test_must_fail test_cmp expected_nobranch actual
1444 test_expect_success '"status.branch=true" weaker than "--no-branch"' '
1445 git -c status.branch=true status -s --no-branch >actual &&
1446 test_cmp expected_nobranch actual
1449 test_expect_success '"status.branch=true" weaker than "--porcelain"' '
1450 git -c status.branch=true status --porcelain >actual &&
1451 test_cmp expected_nobranch actual
1454 test_expect_success '"status.branch=false" same as "--no-branch"' '
1455 git -c status.branch=false status -s >actual &&
1456 test_cmp expected_nobranch actual
1459 test_expect_success '"status.branch=false" weaker than "-b"' '
1460 git -c status.branch=false status -sb >actual &&
1461 test_cmp expected_branch actual
1464 test_expect_success 'Restore default test environment' '
1465 git config --unset status.showUntrackedFiles
1468 test_done