Merge branch 'master' of git://repo.or.cz/alt-git
[git/mingw.git] / t / t7508-status.sh
blobf74c8cdadda4d80c63547fd812e8bae0896794c4
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 cat >.gitignore <<\EOF
74 .gitignore
75 expect*
76 output*
77 EOF
79 test_expect_success 'status --column' '
80 cat >expect <<\EOF &&
81 # On branch master
82 # Changes to be committed:
83 # (use "git reset HEAD <file>..." to unstage)
85 # new file: dir2/added
87 # Changes not staged for commit:
88 # (use "git add <file>..." to update what will be committed)
89 # (use "git checkout -- <file>..." to discard changes in working directory)
91 # modified: dir1/modified
93 # Untracked files:
94 # (use "git add <file>..." to include in what will be committed)
96 # dir1/untracked dir2/untracked
97 # dir2/modified untracked
99 EOF
100 COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
101 test_i18ncmp expect output
104 test_expect_success 'status --column status.displayCommentPrefix=false' '
105 strip_comments expect &&
106 COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
107 test_i18ncmp expect output
110 cat >expect <<\EOF
111 # On branch master
112 # Changes to be committed:
113 # (use "git reset HEAD <file>..." to unstage)
115 # new file: dir2/added
117 # Changes not staged for commit:
118 # (use "git add <file>..." to update what will be committed)
119 # (use "git checkout -- <file>..." to discard changes in working directory)
121 # modified: dir1/modified
123 # Untracked files:
124 # (use "git add <file>..." to include in what will be committed)
126 # dir1/untracked
127 # dir2/modified
128 # dir2/untracked
129 # untracked
133 test_expect_success 'status with status.displayCommentPrefix=true' '
134 git -c status.displayCommentPrefix=true status >output &&
135 test_i18ncmp expect output
138 test_expect_success 'status with status.displayCommentPrefix=false' '
139 strip_comments expect &&
140 git -c status.displayCommentPrefix=false status >output &&
141 test_i18ncmp expect output
144 test_expect_success 'status -v' '
145 (cat expect && git diff --cached) >expect-with-v &&
146 git status -v >output &&
147 test_i18ncmp expect-with-v output
150 test_expect_success 'status -v -v' '
151 (cat expect &&
152 echo "Changes to be committed:" &&
153 git -c diff.mnemonicprefix=true diff --cached &&
154 echo "--------------------------------------------------" &&
155 echo "Changes not staged for commit:" &&
156 git -c diff.mnemonicprefix=true diff) >expect-with-v &&
157 git status -v -v >output &&
158 test_i18ncmp expect-with-v output
161 test_expect_success 'setup fake editor' '
162 cat >.git/editor <<-\EOF &&
163 #! /bin/sh
164 cp "$1" output
166 chmod 755 .git/editor
169 commit_template_commented () {
171 EDITOR=.git/editor &&
172 export EDITOR &&
173 # Fails due to empty message
174 test_must_fail git commit
175 ) &&
176 ! grep '^[^#]' output
179 test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
180 commit_template_commented
183 cat >expect <<\EOF
184 On branch master
185 Changes to be committed:
186 new file: dir2/added
188 Changes not staged for commit:
189 modified: dir1/modified
191 Untracked files:
192 dir1/untracked
193 dir2/modified
194 dir2/untracked
195 untracked
199 test_expect_success 'status (advice.statusHints false)' '
200 test_config advice.statusHints false &&
201 git status >output &&
202 test_i18ncmp expect output
206 cat >expect <<\EOF
207 M dir1/modified
208 A dir2/added
209 ?? dir1/untracked
210 ?? dir2/modified
211 ?? dir2/untracked
212 ?? untracked
215 test_expect_success 'status -s' '
217 git status -s >output &&
218 test_cmp expect output
222 test_expect_success 'status with gitignore' '
224 echo ".gitignore" &&
225 echo "expect*" &&
226 echo "output" &&
227 echo "untracked"
228 } >.gitignore &&
230 cat >expect <<-\EOF &&
231 M dir1/modified
232 A dir2/added
233 ?? dir2/modified
235 git status -s >output &&
236 test_cmp expect output &&
238 cat >expect <<-\EOF &&
239 M dir1/modified
240 A dir2/added
241 ?? dir2/modified
242 !! .gitignore
243 !! dir1/untracked
244 !! dir2/untracked
245 !! expect
246 !! expect-with-v
247 !! output
248 !! untracked
250 git status -s --ignored >output &&
251 test_cmp expect output &&
253 cat >expect <<\EOF &&
254 On branch master
255 Changes to be committed:
256 (use "git reset HEAD <file>..." to unstage)
258 new file: dir2/added
260 Changes not staged for commit:
261 (use "git add <file>..." to update what will be committed)
262 (use "git checkout -- <file>..." to discard changes in working directory)
264 modified: dir1/modified
266 Untracked files:
267 (use "git add <file>..." to include in what will be committed)
269 dir2/modified
271 Ignored files:
272 (use "git add -f <file>..." to include in what will be committed)
274 .gitignore
275 dir1/untracked
276 dir2/untracked
277 expect
278 expect-with-v
279 output
280 untracked
283 git status --ignored >output &&
284 test_i18ncmp expect output
287 test_expect_success 'status with gitignore (nothing untracked)' '
289 echo ".gitignore" &&
290 echo "expect*" &&
291 echo "dir2/modified" &&
292 echo "output" &&
293 echo "untracked"
294 } >.gitignore &&
296 cat >expect <<-\EOF &&
297 M dir1/modified
298 A dir2/added
300 git status -s >output &&
301 test_cmp expect output &&
303 cat >expect <<-\EOF &&
304 M dir1/modified
305 A dir2/added
306 !! .gitignore
307 !! dir1/untracked
308 !! dir2/modified
309 !! dir2/untracked
310 !! expect
311 !! expect-with-v
312 !! output
313 !! untracked
315 git status -s --ignored >output &&
316 test_cmp expect output &&
318 cat >expect <<\EOF &&
319 On branch master
320 Changes to be committed:
321 (use "git reset HEAD <file>..." to unstage)
323 new file: dir2/added
325 Changes not staged for commit:
326 (use "git add <file>..." to update what will be committed)
327 (use "git checkout -- <file>..." to discard changes in working directory)
329 modified: dir1/modified
331 Ignored files:
332 (use "git add -f <file>..." to include in what will be committed)
334 .gitignore
335 dir1/untracked
336 dir2/modified
337 dir2/untracked
338 expect
339 expect-with-v
340 output
341 untracked
344 git status --ignored >output &&
345 test_i18ncmp expect output
348 cat >.gitignore <<\EOF
349 .gitignore
350 expect*
351 output*
354 cat >expect <<\EOF
355 ## master
356 M dir1/modified
357 A dir2/added
358 ?? dir1/untracked
359 ?? dir2/modified
360 ?? dir2/untracked
361 ?? untracked
364 test_expect_success 'status -s -b' '
366 git status -s -b >output &&
367 test_cmp expect output
371 test_expect_success 'status -s -z -b' '
372 tr "\\n" Q <expect >expect.q &&
373 mv expect.q expect &&
374 git status -s -z -b >output &&
375 nul_to_q <output >output.q &&
376 mv output.q output &&
377 test_cmp expect output
380 test_expect_success 'setup dir3' '
381 mkdir dir3 &&
382 : >dir3/untracked1 &&
383 : >dir3/untracked2
386 test_expect_success 'status -uno' '
387 cat >expect <<EOF &&
388 On branch master
389 Changes to be committed:
390 (use "git reset HEAD <file>..." to unstage)
392 new file: dir2/added
394 Changes not staged for commit:
395 (use "git add <file>..." to update what will be committed)
396 (use "git checkout -- <file>..." to discard changes in working directory)
398 modified: dir1/modified
400 Untracked files not listed (use -u option to show untracked files)
402 git status -uno >output &&
403 test_i18ncmp expect output
406 test_expect_success 'status (status.showUntrackedFiles no)' '
407 test_config status.showuntrackedfiles no &&
408 git status >output &&
409 test_i18ncmp expect output
412 test_expect_success 'status -uno (advice.statusHints false)' '
413 cat >expect <<EOF &&
414 On branch master
415 Changes to be committed:
416 new file: dir2/added
418 Changes not staged for commit:
419 modified: dir1/modified
421 Untracked files not listed
423 test_config advice.statusHints false &&
424 git status -uno >output &&
425 test_i18ncmp expect output
428 cat >expect << EOF
429 M dir1/modified
430 A dir2/added
432 test_expect_success 'status -s -uno' '
433 git status -s -uno >output &&
434 test_cmp expect output
437 test_expect_success 'status -s (status.showUntrackedFiles no)' '
438 git config status.showuntrackedfiles no &&
439 git status -s >output &&
440 test_cmp expect output
443 test_expect_success 'status -unormal' '
444 cat >expect <<EOF &&
445 On branch master
446 Changes to be committed:
447 (use "git reset HEAD <file>..." to unstage)
449 new file: dir2/added
451 Changes not staged for commit:
452 (use "git add <file>..." to update what will be committed)
453 (use "git checkout -- <file>..." to discard changes in working directory)
455 modified: dir1/modified
457 Untracked files:
458 (use "git add <file>..." to include in what will be committed)
460 dir1/untracked
461 dir2/modified
462 dir2/untracked
463 dir3/
464 untracked
467 git status -unormal >output &&
468 test_i18ncmp expect output
471 test_expect_success 'status (status.showUntrackedFiles normal)' '
472 test_config status.showuntrackedfiles normal &&
473 git status >output &&
474 test_i18ncmp expect output
477 cat >expect <<EOF
478 M dir1/modified
479 A dir2/added
480 ?? dir1/untracked
481 ?? dir2/modified
482 ?? dir2/untracked
483 ?? dir3/
484 ?? untracked
486 test_expect_success 'status -s -unormal' '
487 git status -s -unormal >output &&
488 test_cmp expect output
491 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
492 git config status.showuntrackedfiles normal &&
493 git status -s >output &&
494 test_cmp expect output
497 test_expect_success 'status -uall' '
498 cat >expect <<EOF &&
499 On branch master
500 Changes to be committed:
501 (use "git reset HEAD <file>..." to unstage)
503 new file: dir2/added
505 Changes not staged for commit:
506 (use "git add <file>..." to update what will be committed)
507 (use "git checkout -- <file>..." to discard changes in working directory)
509 modified: dir1/modified
511 Untracked files:
512 (use "git add <file>..." to include in what will be committed)
514 dir1/untracked
515 dir2/modified
516 dir2/untracked
517 dir3/untracked1
518 dir3/untracked2
519 untracked
522 git status -uall >output &&
523 test_i18ncmp expect output
526 test_expect_success 'status (status.showUntrackedFiles all)' '
527 test_config status.showuntrackedfiles all &&
528 git status >output &&
529 test_i18ncmp expect output
532 test_expect_success 'teardown dir3' '
533 rm -rf dir3
536 cat >expect <<EOF
537 M dir1/modified
538 A dir2/added
539 ?? dir1/untracked
540 ?? dir2/modified
541 ?? dir2/untracked
542 ?? untracked
544 test_expect_success 'status -s -uall' '
545 test_unconfig status.showuntrackedfiles &&
546 git status -s -uall >output &&
547 test_cmp expect output
549 test_expect_success 'status -s (status.showUntrackedFiles all)' '
550 test_config status.showuntrackedfiles all &&
551 git status -s >output &&
552 rm -rf dir3 &&
553 test_cmp expect output
556 test_expect_success 'status with relative paths' '
557 cat >expect <<\EOF &&
558 On branch master
559 Changes to be committed:
560 (use "git reset HEAD <file>..." to unstage)
562 new file: ../dir2/added
564 Changes not staged for commit:
565 (use "git add <file>..." to update what will be committed)
566 (use "git checkout -- <file>..." to discard changes in working directory)
568 modified: modified
570 Untracked files:
571 (use "git add <file>..." to include in what will be committed)
573 untracked
574 ../dir2/modified
575 ../dir2/untracked
576 ../untracked
579 (cd dir1 && git status) >output &&
580 test_i18ncmp expect output
583 cat >expect <<\EOF
584 M modified
585 A ../dir2/added
586 ?? untracked
587 ?? ../dir2/modified
588 ?? ../dir2/untracked
589 ?? ../untracked
591 test_expect_success 'status -s with relative paths' '
593 (cd dir1 && git status -s) >output &&
594 test_cmp expect output
598 cat >expect <<\EOF
599 M dir1/modified
600 A dir2/added
601 ?? dir1/untracked
602 ?? dir2/modified
603 ?? dir2/untracked
604 ?? untracked
607 test_expect_success 'status --porcelain ignores relative paths setting' '
609 (cd dir1 && git status --porcelain) >output &&
610 test_cmp expect output
614 test_expect_success 'setup unique colors' '
616 git config status.color.untracked blue &&
617 git config status.color.branch green
621 test_expect_success 'status with color.ui' '
622 cat >expect <<\EOF &&
623 On branch <GREEN>master<RESET>
624 Changes to be committed:
625 (use "git reset HEAD <file>..." to unstage)
627 <GREEN>new file: dir2/added<RESET>
629 Changes not staged for commit:
630 (use "git add <file>..." to update what will be committed)
631 (use "git checkout -- <file>..." to discard changes in working directory)
633 <RED>modified: dir1/modified<RESET>
635 Untracked files:
636 (use "git add <file>..." to include in what will be committed)
638 <BLUE>dir1/untracked<RESET>
639 <BLUE>dir2/modified<RESET>
640 <BLUE>dir2/untracked<RESET>
641 <BLUE>untracked<RESET>
644 test_config color.ui always &&
645 git status | test_decode_color >output &&
646 test_i18ncmp expect output
649 test_expect_success 'status with color.status' '
650 test_config color.status always &&
651 git status | test_decode_color >output &&
652 test_i18ncmp expect output
655 cat >expect <<\EOF
656 <RED>M<RESET> dir1/modified
657 <GREEN>A<RESET> dir2/added
658 <BLUE>??<RESET> dir1/untracked
659 <BLUE>??<RESET> dir2/modified
660 <BLUE>??<RESET> dir2/untracked
661 <BLUE>??<RESET> untracked
664 test_expect_success 'status -s with color.ui' '
666 git config color.ui always &&
667 git status -s | test_decode_color >output &&
668 test_cmp expect output
672 test_expect_success 'status -s with color.status' '
674 git config --unset color.ui &&
675 git config color.status always &&
676 git status -s | test_decode_color >output &&
677 test_cmp expect output
681 cat >expect <<\EOF
682 ## <GREEN>master<RESET>
683 <RED>M<RESET> dir1/modified
684 <GREEN>A<RESET> dir2/added
685 <BLUE>??<RESET> dir1/untracked
686 <BLUE>??<RESET> dir2/modified
687 <BLUE>??<RESET> dir2/untracked
688 <BLUE>??<RESET> untracked
691 test_expect_success 'status -s -b with color.status' '
693 git status -s -b | test_decode_color >output &&
694 test_cmp expect output
698 cat >expect <<\EOF
699 M dir1/modified
700 A dir2/added
701 ?? dir1/untracked
702 ?? dir2/modified
703 ?? dir2/untracked
704 ?? untracked
707 test_expect_success 'status --porcelain ignores color.ui' '
709 git config --unset color.status &&
710 git config color.ui always &&
711 git status --porcelain | test_decode_color >output &&
712 test_cmp expect output
716 test_expect_success 'status --porcelain ignores color.status' '
718 git config --unset color.ui &&
719 git config color.status always &&
720 git status --porcelain | test_decode_color >output &&
721 test_cmp expect output
725 # recover unconditionally from color tests
726 git config --unset color.status
727 git config --unset color.ui
729 test_expect_success 'status --porcelain respects -b' '
731 git status --porcelain -b >output &&
733 echo "## master" &&
734 cat expect
735 } >tmp &&
736 mv tmp expect &&
737 test_cmp expect output
743 test_expect_success 'status without relative paths' '
744 cat >expect <<\EOF &&
745 On branch master
746 Changes to be committed:
747 (use "git reset HEAD <file>..." to unstage)
749 new file: dir2/added
751 Changes not staged for commit:
752 (use "git add <file>..." to update what will be committed)
753 (use "git checkout -- <file>..." to discard changes in working directory)
755 modified: dir1/modified
757 Untracked files:
758 (use "git add <file>..." to include in what will be committed)
760 dir1/untracked
761 dir2/modified
762 dir2/untracked
763 untracked
766 test_config status.relativePaths false &&
767 (cd dir1 && git status) >output &&
768 test_i18ncmp expect output
772 cat >expect <<\EOF
773 M dir1/modified
774 A dir2/added
775 ?? dir1/untracked
776 ?? dir2/modified
777 ?? dir2/untracked
778 ?? untracked
781 test_expect_success 'status -s without relative paths' '
783 test_config status.relativePaths false &&
784 (cd dir1 && git status -s) >output &&
785 test_cmp expect output
789 test_expect_success 'dry-run of partial commit excluding new file in index' '
790 cat >expect <<EOF &&
791 On branch master
792 Changes to be committed:
793 (use "git reset HEAD <file>..." to unstage)
795 modified: dir1/modified
797 Untracked files:
798 (use "git add <file>..." to include in what will be committed)
800 dir1/untracked
801 dir2/
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 untracked
853 git status >output &&
854 test_i18ncmp expect output
857 # we expect the same as the previous test
858 test_expect_success 'status --untracked-files=all does not show submodule' '
859 git status --untracked-files=all >output &&
860 test_i18ncmp expect output
863 cat >expect <<EOF
864 M dir1/modified
865 A dir2/added
866 A sm
867 ?? dir1/untracked
868 ?? dir2/modified
869 ?? dir2/untracked
870 ?? untracked
872 test_expect_success 'status -s submodule summary is disabled by default' '
873 git status -s >output &&
874 test_cmp expect output
877 # we expect the same as the previous test
878 test_expect_success 'status -s --untracked-files=all does not show submodule' '
879 git status -s --untracked-files=all >output &&
880 test_cmp expect output
883 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
885 test_expect_success 'status submodule summary' '
886 cat >expect <<EOF &&
887 On branch master
888 Changes to be committed:
889 (use "git reset HEAD <file>..." to unstage)
891 new file: dir2/added
892 new file: sm
894 Changes not staged for commit:
895 (use "git add <file>..." to update what will be committed)
896 (use "git checkout -- <file>..." to discard changes in working directory)
898 modified: dir1/modified
900 Submodule changes to be committed:
902 * sm 0000000...$head (1):
903 > Add foo
905 Untracked files:
906 (use "git add <file>..." to include in what will be committed)
908 dir1/untracked
909 dir2/modified
910 dir2/untracked
911 untracked
914 git config status.submodulesummary 10 &&
915 git status >output &&
916 test_i18ncmp expect output
919 test_expect_success 'status submodule summary with status.displayCommentPrefix=false' '
920 strip_comments expect &&
921 git -c status.displayCommentPrefix=false status >output &&
922 test_i18ncmp expect output
925 test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' '
926 commit_template_commented
929 cat >expect <<EOF
930 M dir1/modified
931 A dir2/added
932 A sm
933 ?? dir1/untracked
934 ?? dir2/modified
935 ?? dir2/untracked
936 ?? untracked
938 test_expect_success 'status -s submodule summary' '
939 git status -s >output &&
940 test_cmp expect output
943 test_expect_success 'status submodule summary (clean submodule): commit' '
944 cat >expect <<EOF &&
945 On branch master
946 Changes not staged for commit:
947 (use "git add <file>..." to update what will be committed)
948 (use "git checkout -- <file>..." to discard changes in working directory)
950 modified: dir1/modified
952 Untracked files:
953 (use "git add <file>..." to include in what will be committed)
955 dir1/untracked
956 dir2/modified
957 dir2/untracked
958 untracked
960 no changes added to commit (use "git add" and/or "git commit -a")
962 git commit -m "commit submodule" &&
963 git config status.submodulesummary 10 &&
964 test_must_fail git commit --dry-run >output &&
965 test_i18ncmp expect output &&
966 git status >output &&
967 test_i18ncmp expect output
970 cat >expect <<EOF
971 M dir1/modified
972 ?? dir1/untracked
973 ?? dir2/modified
974 ?? dir2/untracked
975 ?? untracked
977 test_expect_success 'status -s submodule summary (clean submodule)' '
978 git status -s >output &&
979 test_cmp expect output
982 test_expect_success 'status -z implies porcelain' '
983 git status --porcelain |
984 perl -pe "s/\012/\000/g" >expect &&
985 git status -z >output &&
986 test_cmp expect output
989 test_expect_success 'commit --dry-run submodule summary (--amend)' '
990 cat >expect <<EOF &&
991 On branch master
992 Changes to be committed:
993 (use "git reset HEAD^1 <file>..." to unstage)
995 new file: dir2/added
996 new file: sm
998 Changes not staged for commit:
999 (use "git add <file>..." to update what will be committed)
1000 (use "git checkout -- <file>..." to discard changes in working directory)
1002 modified: dir1/modified
1004 Submodule changes to be committed:
1006 * sm 0000000...$head (1):
1007 > Add foo
1009 Untracked files:
1010 (use "git add <file>..." to include in what will be committed)
1012 dir1/untracked
1013 dir2/modified
1014 dir2/untracked
1015 untracked
1018 git config status.submodulesummary 10 &&
1019 git commit --dry-run --amend >output &&
1020 test_i18ncmp expect output
1023 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
1025 chmod a-w .git &&
1026 # make dir1/tracked stat-dirty
1027 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
1028 git status -s >output &&
1029 ! grep dir1/tracked output &&
1030 # make sure "status" succeeded without writing index out
1031 git diff-files | grep dir1/tracked
1033 status=$?
1034 chmod 775 .git
1035 (exit $status)
1038 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
1039 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
1040 touch .gitmodules
1042 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1043 cat > expect << EOF &&
1044 On branch master
1045 Changes to be committed:
1046 (use "git reset HEAD <file>..." to unstage)
1048 modified: sm
1050 Changes not staged for commit:
1051 (use "git add <file>..." to update what will be committed)
1052 (use "git checkout -- <file>..." to discard changes in working directory)
1054 modified: dir1/modified
1056 Submodule changes to be committed:
1058 * sm $head...$new_head (1):
1059 > Add bar
1061 Untracked files:
1062 (use "git add <file>..." to include in what will be committed)
1064 .gitmodules
1065 dir1/untracked
1066 dir2/modified
1067 dir2/untracked
1068 untracked
1071 echo modified sm/untracked &&
1072 git status --ignore-submodules=untracked >output &&
1073 test_i18ncmp expect output
1076 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1077 test_config diff.ignoreSubmodules dirty &&
1078 git status >output &&
1079 test_i18ncmp expect output &&
1080 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1081 git config --add -f .gitmodules submodule.subname.path sm &&
1082 git status >output &&
1083 test_i18ncmp expect output &&
1084 git config -f .gitmodules --remove-section submodule.subname
1087 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1088 git config --add -f .gitmodules submodule.subname.ignore none &&
1089 git config --add -f .gitmodules submodule.subname.path sm &&
1090 git config --add submodule.subname.ignore untracked &&
1091 git config --add submodule.subname.path sm &&
1092 git status >output &&
1093 test_i18ncmp expect output &&
1094 git config --remove-section submodule.subname &&
1095 git config --remove-section -f .gitmodules submodule.subname
1098 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1099 git status --ignore-submodules=dirty >output &&
1100 test_i18ncmp expect output
1103 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1104 test_config diff.ignoreSubmodules dirty &&
1105 git status >output &&
1106 ! test -s actual &&
1107 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1108 git config --add -f .gitmodules submodule.subname.path sm &&
1109 git status >output &&
1110 test_i18ncmp expect output &&
1111 git config -f .gitmodules --remove-section submodule.subname
1114 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1115 git config --add -f .gitmodules submodule.subname.ignore none &&
1116 git config --add -f .gitmodules submodule.subname.path sm &&
1117 git config --add submodule.subname.ignore dirty &&
1118 git config --add submodule.subname.path sm &&
1119 git status >output &&
1120 test_i18ncmp expect output &&
1121 git config --remove-section submodule.subname &&
1122 git config -f .gitmodules --remove-section submodule.subname
1125 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1126 echo modified >sm/foo &&
1127 git status --ignore-submodules=dirty >output &&
1128 test_i18ncmp expect output
1131 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
1132 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1133 git config --add -f .gitmodules submodule.subname.path sm &&
1134 git status >output &&
1135 test_i18ncmp expect output &&
1136 git config -f .gitmodules --remove-section submodule.subname
1139 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
1140 git config --add -f .gitmodules submodule.subname.ignore none &&
1141 git config --add -f .gitmodules submodule.subname.path sm &&
1142 git config --add submodule.subname.ignore dirty &&
1143 git config --add submodule.subname.path sm &&
1144 git status >output &&
1145 test_i18ncmp expect output &&
1146 git config --remove-section submodule.subname &&
1147 git config -f .gitmodules --remove-section submodule.subname
1150 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1151 cat > expect << EOF &&
1152 On branch master
1153 Changes to be committed:
1154 (use "git reset HEAD <file>..." to unstage)
1156 modified: sm
1158 Changes not staged for commit:
1159 (use "git add <file>..." to update what will be committed)
1160 (use "git checkout -- <file>..." to discard changes in working directory)
1161 (commit or discard the untracked or modified content in submodules)
1163 modified: dir1/modified
1164 modified: sm (modified content)
1166 Submodule changes to be committed:
1168 * sm $head...$new_head (1):
1169 > Add bar
1171 Untracked files:
1172 (use "git add <file>..." to include in what will be committed)
1174 .gitmodules
1175 dir1/untracked
1176 dir2/modified
1177 dir2/untracked
1178 untracked
1181 git status --ignore-submodules=untracked > output &&
1182 test_i18ncmp expect output
1185 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
1186 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1187 git config --add -f .gitmodules submodule.subname.path sm &&
1188 git status >output &&
1189 test_i18ncmp expect output &&
1190 git config -f .gitmodules --remove-section submodule.subname
1193 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1194 git config --add -f .gitmodules submodule.subname.ignore none &&
1195 git config --add -f .gitmodules submodule.subname.path sm &&
1196 git config --add submodule.subname.ignore untracked &&
1197 git config --add submodule.subname.path sm &&
1198 git status >output &&
1199 test_i18ncmp expect output &&
1200 git config --remove-section submodule.subname &&
1201 git config -f .gitmodules --remove-section submodule.subname
1204 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1206 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1207 cat > expect << EOF &&
1208 On branch master
1209 Changes to be committed:
1210 (use "git reset HEAD <file>..." to unstage)
1212 modified: sm
1214 Changes not staged for commit:
1215 (use "git add <file>..." to update what will be committed)
1216 (use "git checkout -- <file>..." to discard changes in working directory)
1218 modified: dir1/modified
1219 modified: sm (new commits)
1221 Submodule changes to be committed:
1223 * sm $head...$new_head (1):
1224 > Add bar
1226 Submodules changed but not updated:
1228 * sm $new_head...$head2 (1):
1229 > 2nd commit
1231 Untracked files:
1232 (use "git add <file>..." to include in what will be committed)
1234 .gitmodules
1235 dir1/untracked
1236 dir2/modified
1237 dir2/untracked
1238 untracked
1241 git status --ignore-submodules=untracked > output &&
1242 test_i18ncmp expect output
1245 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1246 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1247 git config --add -f .gitmodules submodule.subname.path sm &&
1248 git status >output &&
1249 test_i18ncmp expect output &&
1250 git config -f .gitmodules --remove-section submodule.subname
1253 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1254 git config --add -f .gitmodules submodule.subname.ignore none &&
1255 git config --add -f .gitmodules submodule.subname.path sm &&
1256 git config --add submodule.subname.ignore untracked &&
1257 git config --add submodule.subname.path sm &&
1258 git status >output &&
1259 test_i18ncmp expect output &&
1260 git config --remove-section submodule.subname &&
1261 git config -f .gitmodules --remove-section submodule.subname
1264 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1265 git status --ignore-submodules=dirty > output &&
1266 test_i18ncmp expect output
1268 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1269 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1270 git config --add -f .gitmodules submodule.subname.path sm &&
1271 git status >output &&
1272 test_i18ncmp expect output &&
1273 git config -f .gitmodules --remove-section submodule.subname
1276 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1277 git config --add -f .gitmodules submodule.subname.ignore none &&
1278 git config --add -f .gitmodules submodule.subname.path sm &&
1279 git config --add submodule.subname.ignore dirty &&
1280 git config --add submodule.subname.path sm &&
1281 git status >output &&
1282 test_i18ncmp expect output &&
1283 git config --remove-section submodule.subname &&
1284 git config -f .gitmodules --remove-section submodule.subname
1287 cat > expect << EOF
1288 ; On branch master
1289 ; Changes to be committed:
1290 ; (use "git reset HEAD <file>..." to unstage)
1292 ; modified: sm
1294 ; Changes not staged for commit:
1295 ; (use "git add <file>..." to update what will be committed)
1296 ; (use "git checkout -- <file>..." to discard changes in working directory)
1298 ; modified: dir1/modified
1299 ; modified: sm (new commits)
1301 ; Submodule changes to be committed:
1303 ; * sm $head...$new_head (1):
1304 ; > Add bar
1306 ; Submodules changed but not updated:
1308 ; * sm $new_head...$head2 (1):
1309 ; > 2nd commit
1311 ; Untracked files:
1312 ; (use "git add <file>..." to include in what will be committed)
1314 ; .gitmodules
1315 ; dir1/untracked
1316 ; dir2/modified
1317 ; dir2/untracked
1318 ; untracked
1322 test_expect_success "status (core.commentchar with submodule summary)" '
1323 test_config core.commentchar ";" &&
1324 git -c status.displayCommentPrefix=true status >output &&
1325 test_i18ncmp expect output
1328 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1329 test_config core.commentchar ";;" &&
1330 test_must_fail git -c status.displayCommentPrefix=true status
1333 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1334 cat > expect << EOF &&
1335 On branch master
1336 Changes not staged for commit:
1337 (use "git add <file>..." to update what will be committed)
1338 (use "git checkout -- <file>..." to discard changes in working directory)
1340 modified: dir1/modified
1342 Untracked files:
1343 (use "git add <file>..." to include in what will be committed)
1345 .gitmodules
1346 dir1/untracked
1347 dir2/modified
1348 dir2/untracked
1349 untracked
1351 no changes added to commit (use "git add" and/or "git commit -a")
1353 git status --ignore-submodules=all > output &&
1354 test_i18ncmp expect output
1357 test_expect_success '.gitmodules ignore=all suppresses unstaged submodule summary' '
1358 cat > expect << EOF &&
1359 On branch master
1360 Changes to be committed:
1361 (use "git reset HEAD <file>..." to unstage)
1363 modified: sm
1365 Changes not staged for commit:
1366 (use "git add <file>..." to update what will be committed)
1367 (use "git checkout -- <file>..." to discard changes in working directory)
1369 modified: dir1/modified
1371 Untracked files:
1372 (use "git add <file>..." to include in what will be committed)
1374 .gitmodules
1375 dir1/untracked
1376 dir2/modified
1377 dir2/untracked
1378 untracked
1381 git config --add -f .gitmodules submodule.subname.ignore all &&
1382 git config --add -f .gitmodules submodule.subname.path sm &&
1383 git status > output &&
1384 test_cmp expect output &&
1385 git config -f .gitmodules --remove-section submodule.subname
1388 test_expect_success '.git/config ignore=all suppresses unstaged submodule summary' '
1389 git config --add -f .gitmodules submodule.subname.ignore none &&
1390 git config --add -f .gitmodules submodule.subname.path sm &&
1391 git config --add submodule.subname.ignore all &&
1392 git config --add submodule.subname.path sm &&
1393 git status > output &&
1394 test_cmp expect output &&
1395 git config --remove-section submodule.subname &&
1396 git config -f .gitmodules --remove-section submodule.subname
1399 test_expect_success 'setup of test environment' '
1400 git config status.showUntrackedFiles no &&
1401 git status -s >expected_short &&
1402 git status --no-short >expected_noshort
1405 test_expect_success '"status.short=true" same as "-s"' '
1406 git -c status.short=true status >actual &&
1407 test_cmp expected_short actual
1410 test_expect_success '"status.short=true" weaker than "--no-short"' '
1411 git -c status.short=true status --no-short >actual &&
1412 test_cmp expected_noshort actual
1415 test_expect_success '"status.short=false" same as "--no-short"' '
1416 git -c status.short=false status >actual &&
1417 test_cmp expected_noshort actual
1420 test_expect_success '"status.short=false" weaker than "-s"' '
1421 git -c status.short=false status -s >actual &&
1422 test_cmp expected_short actual
1425 test_expect_success '"status.branch=true" same as "-b"' '
1426 git status -sb >expected_branch &&
1427 git -c status.branch=true status -s >actual &&
1428 test_cmp expected_branch actual
1431 test_expect_success '"status.branch=true" different from "--no-branch"' '
1432 git status -s --no-branch >expected_nobranch &&
1433 git -c status.branch=true status -s >actual &&
1434 test_must_fail test_cmp expected_nobranch actual
1437 test_expect_success '"status.branch=true" weaker than "--no-branch"' '
1438 git -c status.branch=true status -s --no-branch >actual &&
1439 test_cmp expected_nobranch actual
1442 test_expect_success '"status.branch=true" weaker than "--porcelain"' '
1443 git -c status.branch=true status --porcelain >actual &&
1444 test_cmp expected_nobranch actual
1447 test_expect_success '"status.branch=false" same as "--no-branch"' '
1448 git -c status.branch=false status -s >actual &&
1449 test_cmp expected_nobranch actual
1452 test_expect_success '"status.branch=false" weaker than "-b"' '
1453 git -c status.branch=false status -sb >actual &&
1454 test_cmp expected_branch actual
1457 test_expect_success 'Restore default test environment' '
1458 git config --unset status.showUntrackedFiles
1461 test_expect_success 'git commit will commit a staged but ignored submodule' '
1462 git config --add -f .gitmodules submodule.subname.ignore all &&
1463 git config --add -f .gitmodules submodule.subname.path sm &&
1464 git config --add submodule.subname.ignore all &&
1465 git status -s --ignore-submodules=dirty >output &&
1466 test_i18ngrep "^M. sm" output &&
1467 GIT_EDITOR="echo hello >>\"\$1\"" &&
1468 export GIT_EDITOR &&
1469 git commit -uno &&
1470 git status -s --ignore-submodules=dirty >output &&
1471 test_i18ngrep ! "^M. sm" output
1474 test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '
1475 git reset HEAD^ &&
1476 git add sm &&
1477 cat >expect << EOF &&
1478 On branch master
1479 Changes to be committed:
1480 (use "git reset HEAD <file>..." to unstage)
1482 modified: sm
1484 Changes not staged for commit:
1485 (use "git add <file>..." to update what will be committed)
1486 (use "git checkout -- <file>..." to discard changes in working directory)
1488 modified: dir1/modified
1490 Untracked files not listed (use -u option to show untracked files)
1492 git commit -uno --dry-run >output &&
1493 test_i18ncmp expect output &&
1494 git status -s --ignore-submodules=dirty >output &&
1495 test_i18ngrep "^M. sm" output
1498 test_expect_success 'git commit -m will commit a staged but ignored submodule' '
1499 git commit -uno -m message &&
1500 git status -s --ignore-submodules=dirty >output &&
1501 test_i18ngrep ! "^M. sm" output &&
1502 git config --remove-section submodule.subname &&
1503 git config -f .gitmodules --remove-section submodule.subname
1506 test_done