Sync with 2.4.3
[git.git] / t / t7508-status.sh
blobc3ed7cb51c9a73b5bb6152b56824e6c6b8347d2c
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 cat >.gitignore <<\EOF
70 .gitignore
71 expect*
72 output*
73 EOF
75 test_expect_success 'status --column' '
76 cat >expect <<\EOF &&
77 # On branch master
78 # Changes to be committed:
79 # (use "git reset HEAD <file>..." to unstage)
81 # new file: dir2/added
83 # Changes not staged for commit:
84 # (use "git add <file>..." to update what will be committed)
85 # (use "git checkout -- <file>..." to discard changes in working directory)
87 # modified: dir1/modified
89 # Untracked files:
90 # (use "git add <file>..." to include in what will be committed)
92 # dir1/untracked dir2/untracked
93 # dir2/modified untracked
95 EOF
96 COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
97 test_i18ncmp expect output
100 test_expect_success 'status --column status.displayCommentPrefix=false' '
101 strip_comments expect &&
102 COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
103 test_i18ncmp expect output
106 cat >expect <<\EOF
107 # On branch master
108 # Changes to be committed:
109 # (use "git reset HEAD <file>..." to unstage)
111 # new file: dir2/added
113 # Changes not staged for commit:
114 # (use "git add <file>..." to update what will be committed)
115 # (use "git checkout -- <file>..." to discard changes in working directory)
117 # modified: dir1/modified
119 # Untracked files:
120 # (use "git add <file>..." to include in what will be committed)
122 # dir1/untracked
123 # dir2/modified
124 # dir2/untracked
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 'status -v' '
141 (cat expect && git diff --cached) >expect-with-v &&
142 git status -v >output &&
143 test_i18ncmp expect-with-v output
146 test_expect_success 'status -v -v' '
147 (cat expect &&
148 echo "Changes to be committed:" &&
149 git -c diff.mnemonicprefix=true diff --cached &&
150 echo "--------------------------------------------------" &&
151 echo "Changes not staged for commit:" &&
152 git -c diff.mnemonicprefix=true diff) >expect-with-v &&
153 git status -v -v >output &&
154 test_i18ncmp expect-with-v output
157 test_expect_success 'setup fake editor' '
158 cat >.git/editor <<-\EOF &&
159 #! /bin/sh
160 cp "$1" output
162 chmod 755 .git/editor
165 commit_template_commented () {
167 EDITOR=.git/editor &&
168 export EDITOR &&
169 # Fails due to empty message
170 test_must_fail git commit
171 ) &&
172 ! grep '^[^#]' output
175 test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
176 commit_template_commented
179 cat >expect <<\EOF
180 On branch master
181 Changes to be committed:
182 new file: dir2/added
184 Changes not staged for commit:
185 modified: dir1/modified
187 Untracked files:
188 dir1/untracked
189 dir2/modified
190 dir2/untracked
191 untracked
195 test_expect_success 'status (advice.statusHints false)' '
196 test_config advice.statusHints false &&
197 git status >output &&
198 test_i18ncmp expect output
202 cat >expect <<\EOF
203 M dir1/modified
204 A dir2/added
205 ?? dir1/untracked
206 ?? dir2/modified
207 ?? dir2/untracked
208 ?? untracked
211 test_expect_success 'status -s' '
213 git status -s >output &&
214 test_cmp expect output
218 test_expect_success 'status with gitignore' '
220 echo ".gitignore" &&
221 echo "expect*" &&
222 echo "output" &&
223 echo "untracked"
224 } >.gitignore &&
226 cat >expect <<-\EOF &&
227 M dir1/modified
228 A dir2/added
229 ?? dir2/modified
231 git status -s >output &&
232 test_cmp expect output &&
234 cat >expect <<-\EOF &&
235 M dir1/modified
236 A dir2/added
237 ?? dir2/modified
238 !! .gitignore
239 !! dir1/untracked
240 !! dir2/untracked
241 !! expect
242 !! expect-with-v
243 !! output
244 !! untracked
246 git status -s --ignored >output &&
247 test_cmp expect output &&
249 cat >expect <<\EOF &&
250 On branch master
251 Changes to be committed:
252 (use "git reset HEAD <file>..." to unstage)
254 new file: dir2/added
256 Changes not staged for commit:
257 (use "git add <file>..." to update what will be committed)
258 (use "git checkout -- <file>..." to discard changes in working directory)
260 modified: dir1/modified
262 Untracked files:
263 (use "git add <file>..." to include in what will be committed)
265 dir2/modified
267 Ignored files:
268 (use "git add -f <file>..." to include in what will be committed)
270 .gitignore
271 dir1/untracked
272 dir2/untracked
273 expect
274 expect-with-v
275 output
276 untracked
279 git status --ignored >output &&
280 test_i18ncmp expect output
283 test_expect_success 'status with gitignore (nothing untracked)' '
285 echo ".gitignore" &&
286 echo "expect*" &&
287 echo "dir2/modified" &&
288 echo "output" &&
289 echo "untracked"
290 } >.gitignore &&
292 cat >expect <<-\EOF &&
293 M dir1/modified
294 A dir2/added
296 git status -s >output &&
297 test_cmp expect output &&
299 cat >expect <<-\EOF &&
300 M dir1/modified
301 A dir2/added
302 !! .gitignore
303 !! dir1/untracked
304 !! dir2/modified
305 !! dir2/untracked
306 !! expect
307 !! expect-with-v
308 !! output
309 !! untracked
311 git status -s --ignored >output &&
312 test_cmp expect output &&
314 cat >expect <<\EOF &&
315 On branch master
316 Changes to be committed:
317 (use "git reset HEAD <file>..." to unstage)
319 new file: dir2/added
321 Changes not staged for commit:
322 (use "git add <file>..." to update what will be committed)
323 (use "git checkout -- <file>..." to discard changes in working directory)
325 modified: dir1/modified
327 Ignored files:
328 (use "git add -f <file>..." to include in what will be committed)
330 .gitignore
331 dir1/untracked
332 dir2/modified
333 dir2/untracked
334 expect
335 expect-with-v
336 output
337 untracked
340 git status --ignored >output &&
341 test_i18ncmp expect output
344 cat >.gitignore <<\EOF
345 .gitignore
346 expect*
347 output*
350 cat >expect <<\EOF
351 ## master
352 M dir1/modified
353 A dir2/added
354 ?? dir1/untracked
355 ?? dir2/modified
356 ?? dir2/untracked
357 ?? untracked
360 test_expect_success 'status -s -b' '
362 git status -s -b >output &&
363 test_cmp expect output
367 test_expect_success 'status -s -z -b' '
368 tr "\\n" Q <expect >expect.q &&
369 mv expect.q expect &&
370 git status -s -z -b >output &&
371 nul_to_q <output >output.q &&
372 mv output.q output &&
373 test_cmp expect output
376 test_expect_success 'setup dir3' '
377 mkdir dir3 &&
378 : >dir3/untracked1 &&
379 : >dir3/untracked2
382 test_expect_success 'status -uno' '
383 cat >expect <<EOF &&
384 On branch master
385 Changes to be committed:
386 (use "git reset HEAD <file>..." to unstage)
388 new file: dir2/added
390 Changes not staged for commit:
391 (use "git add <file>..." to update what will be committed)
392 (use "git checkout -- <file>..." to discard changes in working directory)
394 modified: dir1/modified
396 Untracked files not listed (use -u option to show untracked files)
398 git status -uno >output &&
399 test_i18ncmp expect output
402 test_expect_success 'status (status.showUntrackedFiles no)' '
403 test_config status.showuntrackedfiles no &&
404 git status >output &&
405 test_i18ncmp expect output
408 test_expect_success 'status -uno (advice.statusHints false)' '
409 cat >expect <<EOF &&
410 On branch master
411 Changes to be committed:
412 new file: dir2/added
414 Changes not staged for commit:
415 modified: dir1/modified
417 Untracked files not listed
419 test_config advice.statusHints false &&
420 git status -uno >output &&
421 test_i18ncmp expect output
424 cat >expect << EOF
425 M dir1/modified
426 A dir2/added
428 test_expect_success 'status -s -uno' '
429 git status -s -uno >output &&
430 test_cmp expect output
433 test_expect_success 'status -s (status.showUntrackedFiles no)' '
434 git config status.showuntrackedfiles no &&
435 git status -s >output &&
436 test_cmp expect output
439 test_expect_success 'status -unormal' '
440 cat >expect <<EOF &&
441 On branch master
442 Changes to be committed:
443 (use "git reset HEAD <file>..." to unstage)
445 new file: dir2/added
447 Changes not staged for commit:
448 (use "git add <file>..." to update what will be committed)
449 (use "git checkout -- <file>..." to discard changes in working directory)
451 modified: dir1/modified
453 Untracked files:
454 (use "git add <file>..." to include in what will be committed)
456 dir1/untracked
457 dir2/modified
458 dir2/untracked
459 dir3/
460 untracked
463 git status -unormal >output &&
464 test_i18ncmp expect output
467 test_expect_success 'status (status.showUntrackedFiles normal)' '
468 test_config status.showuntrackedfiles normal &&
469 git status >output &&
470 test_i18ncmp expect output
473 cat >expect <<EOF
474 M dir1/modified
475 A dir2/added
476 ?? dir1/untracked
477 ?? dir2/modified
478 ?? dir2/untracked
479 ?? dir3/
480 ?? untracked
482 test_expect_success 'status -s -unormal' '
483 git status -s -unormal >output &&
484 test_cmp expect output
487 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
488 git config status.showuntrackedfiles normal &&
489 git status -s >output &&
490 test_cmp expect output
493 test_expect_success 'status -uall' '
494 cat >expect <<EOF &&
495 On branch master
496 Changes to be committed:
497 (use "git reset HEAD <file>..." to unstage)
499 new file: dir2/added
501 Changes not staged for commit:
502 (use "git add <file>..." to update what will be committed)
503 (use "git checkout -- <file>..." to discard changes in working directory)
505 modified: dir1/modified
507 Untracked files:
508 (use "git add <file>..." to include in what will be committed)
510 dir1/untracked
511 dir2/modified
512 dir2/untracked
513 dir3/untracked1
514 dir3/untracked2
515 untracked
518 git status -uall >output &&
519 test_i18ncmp expect output
522 test_expect_success 'status (status.showUntrackedFiles all)' '
523 test_config status.showuntrackedfiles all &&
524 git status >output &&
525 test_i18ncmp expect output
528 test_expect_success 'teardown dir3' '
529 rm -rf dir3
532 cat >expect <<EOF
533 M dir1/modified
534 A dir2/added
535 ?? dir1/untracked
536 ?? dir2/modified
537 ?? dir2/untracked
538 ?? untracked
540 test_expect_success 'status -s -uall' '
541 test_unconfig status.showuntrackedfiles &&
542 git status -s -uall >output &&
543 test_cmp expect output
545 test_expect_success 'status -s (status.showUntrackedFiles all)' '
546 test_config status.showuntrackedfiles all &&
547 git status -s >output &&
548 rm -rf dir3 &&
549 test_cmp expect output
552 test_expect_success 'status with relative paths' '
553 cat >expect <<\EOF &&
554 On branch master
555 Changes to be committed:
556 (use "git reset HEAD <file>..." to unstage)
558 new file: ../dir2/added
560 Changes not staged for commit:
561 (use "git add <file>..." to update what will be committed)
562 (use "git checkout -- <file>..." to discard changes in working directory)
564 modified: modified
566 Untracked files:
567 (use "git add <file>..." to include in what will be committed)
569 untracked
570 ../dir2/modified
571 ../dir2/untracked
572 ../untracked
575 (cd dir1 && git status) >output &&
576 test_i18ncmp expect output
579 cat >expect <<\EOF
580 M modified
581 A ../dir2/added
582 ?? untracked
583 ?? ../dir2/modified
584 ?? ../dir2/untracked
585 ?? ../untracked
587 test_expect_success 'status -s with relative paths' '
589 (cd dir1 && git status -s) >output &&
590 test_cmp expect output
594 cat >expect <<\EOF
595 M dir1/modified
596 A dir2/added
597 ?? dir1/untracked
598 ?? dir2/modified
599 ?? dir2/untracked
600 ?? untracked
603 test_expect_success 'status --porcelain ignores relative paths setting' '
605 (cd dir1 && git status --porcelain) >output &&
606 test_cmp expect output
610 test_expect_success 'setup unique colors' '
612 git config status.color.untracked blue &&
613 git config status.color.branch green
617 test_expect_success 'status with color.ui' '
618 cat >expect <<\EOF &&
619 On branch <GREEN>master<RESET>
620 Changes to be committed:
621 (use "git reset HEAD <file>..." to unstage)
623 <GREEN>new file: dir2/added<RESET>
625 Changes not staged for commit:
626 (use "git add <file>..." to update what will be committed)
627 (use "git checkout -- <file>..." to discard changes in working directory)
629 <RED>modified: dir1/modified<RESET>
631 Untracked files:
632 (use "git add <file>..." to include in what will be committed)
634 <BLUE>dir1/untracked<RESET>
635 <BLUE>dir2/modified<RESET>
636 <BLUE>dir2/untracked<RESET>
637 <BLUE>untracked<RESET>
640 test_config color.ui always &&
641 git status | test_decode_color >output &&
642 test_i18ncmp expect output
645 test_expect_success 'status with color.status' '
646 test_config color.status always &&
647 git status | test_decode_color >output &&
648 test_i18ncmp expect output
651 cat >expect <<\EOF
652 <RED>M<RESET> dir1/modified
653 <GREEN>A<RESET> dir2/added
654 <BLUE>??<RESET> dir1/untracked
655 <BLUE>??<RESET> dir2/modified
656 <BLUE>??<RESET> dir2/untracked
657 <BLUE>??<RESET> untracked
660 test_expect_success 'status -s with color.ui' '
662 git config color.ui always &&
663 git status -s | test_decode_color >output &&
664 test_cmp expect output
668 test_expect_success 'status -s with color.status' '
670 git config --unset color.ui &&
671 git config color.status always &&
672 git status -s | test_decode_color >output &&
673 test_cmp expect output
677 cat >expect <<\EOF
678 ## <GREEN>master<RESET>
679 <RED>M<RESET> dir1/modified
680 <GREEN>A<RESET> dir2/added
681 <BLUE>??<RESET> dir1/untracked
682 <BLUE>??<RESET> dir2/modified
683 <BLUE>??<RESET> dir2/untracked
684 <BLUE>??<RESET> untracked
687 test_expect_success 'status -s -b with color.status' '
689 git status -s -b | test_decode_color >output &&
690 test_cmp expect output
694 cat >expect <<\EOF
695 M dir1/modified
696 A dir2/added
697 ?? dir1/untracked
698 ?? dir2/modified
699 ?? dir2/untracked
700 ?? untracked
703 test_expect_success 'status --porcelain ignores color.ui' '
705 git config --unset color.status &&
706 git config color.ui always &&
707 git status --porcelain | test_decode_color >output &&
708 test_cmp expect output
712 test_expect_success 'status --porcelain ignores color.status' '
714 git config --unset color.ui &&
715 git config color.status always &&
716 git status --porcelain | test_decode_color >output &&
717 test_cmp expect output
721 # recover unconditionally from color tests
722 git config --unset color.status
723 git config --unset color.ui
725 test_expect_success 'status --porcelain respects -b' '
727 git status --porcelain -b >output &&
729 echo "## master" &&
730 cat expect
731 } >tmp &&
732 mv tmp expect &&
733 test_cmp expect output
739 test_expect_success 'status without relative paths' '
740 cat >expect <<\EOF &&
741 On branch master
742 Changes to be committed:
743 (use "git reset HEAD <file>..." to unstage)
745 new file: dir2/added
747 Changes not staged for commit:
748 (use "git add <file>..." to update what will be committed)
749 (use "git checkout -- <file>..." to discard changes in working directory)
751 modified: dir1/modified
753 Untracked files:
754 (use "git add <file>..." to include in what will be committed)
756 dir1/untracked
757 dir2/modified
758 dir2/untracked
759 untracked
762 test_config status.relativePaths false &&
763 (cd dir1 && git status) >output &&
764 test_i18ncmp expect output
768 cat >expect <<\EOF
769 M dir1/modified
770 A dir2/added
771 ?? dir1/untracked
772 ?? dir2/modified
773 ?? dir2/untracked
774 ?? untracked
777 test_expect_success 'status -s without relative paths' '
779 test_config status.relativePaths false &&
780 (cd dir1 && git status -s) >output &&
781 test_cmp expect output
785 test_expect_success 'dry-run of partial commit excluding new file in index' '
786 cat >expect <<EOF &&
787 On branch master
788 Changes to be committed:
789 (use "git reset HEAD <file>..." to unstage)
791 modified: dir1/modified
793 Untracked files:
794 (use "git add <file>..." to include in what will be committed)
796 dir1/untracked
797 dir2/
798 untracked
801 git commit --dry-run dir1/modified >output &&
802 test_i18ncmp expect output
805 cat >expect <<EOF
806 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
808 test_expect_success 'status refreshes the index' '
809 touch dir2/added &&
810 git status &&
811 git diff-files >output &&
812 test_cmp expect output
815 test_expect_success 'setup status submodule summary' '
816 test_create_repo sm && (
817 cd sm &&
818 >foo &&
819 git add foo &&
820 git commit -m "Add foo"
821 ) &&
822 git add sm
825 test_expect_success 'status submodule summary is disabled by default' '
826 cat >expect <<EOF &&
827 On branch master
828 Changes to be committed:
829 (use "git reset HEAD <file>..." to unstage)
831 new file: dir2/added
832 new file: sm
834 Changes not staged for commit:
835 (use "git add <file>..." to update what will be committed)
836 (use "git checkout -- <file>..." to discard changes in working directory)
838 modified: dir1/modified
840 Untracked files:
841 (use "git add <file>..." to include in what will be committed)
843 dir1/untracked
844 dir2/modified
845 dir2/untracked
846 untracked
849 git status >output &&
850 test_i18ncmp expect output
853 # we expect the same as the previous test
854 test_expect_success 'status --untracked-files=all does not show submodule' '
855 git status --untracked-files=all >output &&
856 test_i18ncmp expect output
859 cat >expect <<EOF
860 M dir1/modified
861 A dir2/added
862 A sm
863 ?? dir1/untracked
864 ?? dir2/modified
865 ?? dir2/untracked
866 ?? untracked
868 test_expect_success 'status -s submodule summary is disabled by default' '
869 git status -s >output &&
870 test_cmp expect output
873 # we expect the same as the previous test
874 test_expect_success 'status -s --untracked-files=all does not show submodule' '
875 git status -s --untracked-files=all >output &&
876 test_cmp expect output
879 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
881 test_expect_success 'status submodule summary' '
882 cat >expect <<EOF &&
883 On branch master
884 Changes to be committed:
885 (use "git reset HEAD <file>..." to unstage)
887 new file: dir2/added
888 new file: sm
890 Changes not staged for commit:
891 (use "git add <file>..." to update what will be committed)
892 (use "git checkout -- <file>..." to discard changes in working directory)
894 modified: dir1/modified
896 Submodule changes to be committed:
898 * sm 0000000...$head (1):
899 > Add foo
901 Untracked files:
902 (use "git add <file>..." to include in what will be committed)
904 dir1/untracked
905 dir2/modified
906 dir2/untracked
907 untracked
910 git config status.submodulesummary 10 &&
911 git status >output &&
912 test_i18ncmp expect output
915 test_expect_success 'status submodule summary with status.displayCommentPrefix=false' '
916 strip_comments expect &&
917 git -c status.displayCommentPrefix=false status >output &&
918 test_i18ncmp expect output
921 test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' '
922 commit_template_commented
925 cat >expect <<EOF
926 M dir1/modified
927 A dir2/added
928 A sm
929 ?? dir1/untracked
930 ?? dir2/modified
931 ?? dir2/untracked
932 ?? untracked
934 test_expect_success 'status -s submodule summary' '
935 git status -s >output &&
936 test_cmp expect output
939 test_expect_success 'status submodule summary (clean submodule): commit' '
940 cat >expect <<EOF &&
941 On branch master
942 Changes not staged for commit:
943 (use "git add <file>..." to update what will be committed)
944 (use "git checkout -- <file>..." to discard changes in working directory)
946 modified: dir1/modified
948 Untracked files:
949 (use "git add <file>..." to include in what will be committed)
951 dir1/untracked
952 dir2/modified
953 dir2/untracked
954 untracked
956 no changes added to commit (use "git add" and/or "git commit -a")
958 git commit -m "commit submodule" &&
959 git config status.submodulesummary 10 &&
960 test_must_fail git commit --dry-run >output &&
961 test_i18ncmp expect output &&
962 git status >output &&
963 test_i18ncmp expect output
966 cat >expect <<EOF
967 M dir1/modified
968 ?? dir1/untracked
969 ?? dir2/modified
970 ?? dir2/untracked
971 ?? untracked
973 test_expect_success 'status -s submodule summary (clean submodule)' '
974 git status -s >output &&
975 test_cmp expect output
978 test_expect_success 'status -z implies porcelain' '
979 git status --porcelain |
980 perl -pe "s/\012/\000/g" >expect &&
981 git status -z >output &&
982 test_cmp expect output
985 test_expect_success 'commit --dry-run submodule summary (--amend)' '
986 cat >expect <<EOF &&
987 On branch master
988 Changes to be committed:
989 (use "git reset HEAD^1 <file>..." to unstage)
991 new file: dir2/added
992 new file: sm
994 Changes not staged for commit:
995 (use "git add <file>..." to update what will be committed)
996 (use "git checkout -- <file>..." to discard changes in working directory)
998 modified: dir1/modified
1000 Submodule changes to be committed:
1002 * sm 0000000...$head (1):
1003 > Add foo
1005 Untracked files:
1006 (use "git add <file>..." to include in what will be committed)
1008 dir1/untracked
1009 dir2/modified
1010 dir2/untracked
1011 untracked
1014 git config status.submodulesummary 10 &&
1015 git commit --dry-run --amend >output &&
1016 test_i18ncmp expect output
1019 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
1021 chmod a-w .git &&
1022 # make dir1/tracked stat-dirty
1023 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
1024 git status -s >output &&
1025 ! grep dir1/tracked output &&
1026 # make sure "status" succeeded without writing index out
1027 git diff-files | grep dir1/tracked
1029 status=$?
1030 chmod 775 .git
1031 (exit $status)
1034 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
1035 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
1036 touch .gitmodules
1038 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1039 cat > expect << EOF &&
1040 On branch master
1041 Changes to be committed:
1042 (use "git reset HEAD <file>..." to unstage)
1044 modified: sm
1046 Changes not staged for commit:
1047 (use "git add <file>..." to update what will be committed)
1048 (use "git checkout -- <file>..." to discard changes in working directory)
1050 modified: dir1/modified
1052 Submodule changes to be committed:
1054 * sm $head...$new_head (1):
1055 > Add bar
1057 Untracked files:
1058 (use "git add <file>..." to include in what will be committed)
1060 .gitmodules
1061 dir1/untracked
1062 dir2/modified
1063 dir2/untracked
1064 untracked
1067 echo modified sm/untracked &&
1068 git status --ignore-submodules=untracked >output &&
1069 test_i18ncmp expect output
1072 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1073 test_config diff.ignoreSubmodules dirty &&
1074 git status >output &&
1075 test_i18ncmp expect output &&
1076 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1077 git config --add -f .gitmodules submodule.subname.path sm &&
1078 git status >output &&
1079 test_i18ncmp expect output &&
1080 git config -f .gitmodules --remove-section submodule.subname
1083 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1084 git config --add -f .gitmodules submodule.subname.ignore none &&
1085 git config --add -f .gitmodules submodule.subname.path sm &&
1086 git config --add submodule.subname.ignore untracked &&
1087 git config --add submodule.subname.path sm &&
1088 git status >output &&
1089 test_i18ncmp expect output &&
1090 git config --remove-section submodule.subname &&
1091 git config --remove-section -f .gitmodules submodule.subname
1094 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1095 git status --ignore-submodules=dirty >output &&
1096 test_i18ncmp expect output
1099 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1100 test_config diff.ignoreSubmodules dirty &&
1101 git status >output &&
1102 ! test -s actual &&
1103 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1104 git config --add -f .gitmodules submodule.subname.path sm &&
1105 git status >output &&
1106 test_i18ncmp expect output &&
1107 git config -f .gitmodules --remove-section submodule.subname
1110 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1111 git config --add -f .gitmodules submodule.subname.ignore none &&
1112 git config --add -f .gitmodules submodule.subname.path sm &&
1113 git config --add submodule.subname.ignore dirty &&
1114 git config --add submodule.subname.path sm &&
1115 git status >output &&
1116 test_i18ncmp expect output &&
1117 git config --remove-section submodule.subname &&
1118 git config -f .gitmodules --remove-section submodule.subname
1121 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1122 echo modified >sm/foo &&
1123 git status --ignore-submodules=dirty >output &&
1124 test_i18ncmp expect output
1127 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
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 modified 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=untracked doesn't suppress submodules with modified content" '
1147 cat > expect << EOF &&
1148 On branch master
1149 Changes to be committed:
1150 (use "git reset HEAD <file>..." to unstage)
1152 modified: sm
1154 Changes not staged for commit:
1155 (use "git add <file>..." to update what will be committed)
1156 (use "git checkout -- <file>..." to discard changes in working directory)
1157 (commit or discard the untracked or modified content in submodules)
1159 modified: dir1/modified
1160 modified: sm (modified content)
1162 Submodule changes to be committed:
1164 * sm $head...$new_head (1):
1165 > Add bar
1167 Untracked files:
1168 (use "git add <file>..." to include in what will be committed)
1170 .gitmodules
1171 dir1/untracked
1172 dir2/modified
1173 dir2/untracked
1174 untracked
1177 git status --ignore-submodules=untracked > output &&
1178 test_i18ncmp expect output
1181 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
1182 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1183 git config --add -f .gitmodules submodule.subname.path sm &&
1184 git status >output &&
1185 test_i18ncmp expect output &&
1186 git config -f .gitmodules --remove-section submodule.subname
1189 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1190 git config --add -f .gitmodules submodule.subname.ignore none &&
1191 git config --add -f .gitmodules submodule.subname.path sm &&
1192 git config --add submodule.subname.ignore untracked &&
1193 git config --add submodule.subname.path sm &&
1194 git status >output &&
1195 test_i18ncmp expect output &&
1196 git config --remove-section submodule.subname &&
1197 git config -f .gitmodules --remove-section submodule.subname
1200 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1202 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1203 cat > expect << EOF &&
1204 On branch master
1205 Changes to be committed:
1206 (use "git reset HEAD <file>..." to unstage)
1208 modified: sm
1210 Changes not staged for commit:
1211 (use "git add <file>..." to update what will be committed)
1212 (use "git checkout -- <file>..." to discard changes in working directory)
1214 modified: dir1/modified
1215 modified: sm (new commits)
1217 Submodule changes to be committed:
1219 * sm $head...$new_head (1):
1220 > Add bar
1222 Submodules changed but not updated:
1224 * sm $new_head...$head2 (1):
1225 > 2nd commit
1227 Untracked files:
1228 (use "git add <file>..." to include in what will be committed)
1230 .gitmodules
1231 dir1/untracked
1232 dir2/modified
1233 dir2/untracked
1234 untracked
1237 git status --ignore-submodules=untracked > output &&
1238 test_i18ncmp expect output
1241 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1242 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1243 git config --add -f .gitmodules submodule.subname.path sm &&
1244 git status >output &&
1245 test_i18ncmp expect output &&
1246 git config -f .gitmodules --remove-section submodule.subname
1249 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1250 git config --add -f .gitmodules submodule.subname.ignore none &&
1251 git config --add -f .gitmodules submodule.subname.path sm &&
1252 git config --add submodule.subname.ignore untracked &&
1253 git config --add submodule.subname.path sm &&
1254 git status >output &&
1255 test_i18ncmp expect output &&
1256 git config --remove-section submodule.subname &&
1257 git config -f .gitmodules --remove-section submodule.subname
1260 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1261 git status --ignore-submodules=dirty > output &&
1262 test_i18ncmp expect output
1264 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1265 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1266 git config --add -f .gitmodules submodule.subname.path sm &&
1267 git status >output &&
1268 test_i18ncmp expect output &&
1269 git config -f .gitmodules --remove-section submodule.subname
1272 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1273 git config --add -f .gitmodules submodule.subname.ignore none &&
1274 git config --add -f .gitmodules submodule.subname.path sm &&
1275 git config --add submodule.subname.ignore dirty &&
1276 git config --add submodule.subname.path sm &&
1277 git status >output &&
1278 test_i18ncmp expect output &&
1279 git config --remove-section submodule.subname &&
1280 git config -f .gitmodules --remove-section submodule.subname
1283 cat > expect << EOF
1284 ; On branch master
1285 ; Changes to be committed:
1286 ; (use "git reset HEAD <file>..." to unstage)
1288 ; modified: sm
1290 ; Changes not staged for commit:
1291 ; (use "git add <file>..." to update what will be committed)
1292 ; (use "git checkout -- <file>..." to discard changes in working directory)
1294 ; modified: dir1/modified
1295 ; modified: sm (new commits)
1297 ; Submodule changes to be committed:
1299 ; * sm $head...$new_head (1):
1300 ; > Add bar
1302 ; Submodules changed but not updated:
1304 ; * sm $new_head...$head2 (1):
1305 ; > 2nd commit
1307 ; Untracked files:
1308 ; (use "git add <file>..." to include in what will be committed)
1310 ; .gitmodules
1311 ; dir1/untracked
1312 ; dir2/modified
1313 ; dir2/untracked
1314 ; untracked
1318 test_expect_success "status (core.commentchar with submodule summary)" '
1319 test_config core.commentchar ";" &&
1320 git -c status.displayCommentPrefix=true status >output &&
1321 test_i18ncmp expect output
1324 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1325 test_config core.commentchar ";;" &&
1326 test_must_fail git -c status.displayCommentPrefix=true status
1329 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1330 cat > expect << EOF &&
1331 On branch master
1332 Changes not staged for commit:
1333 (use "git add <file>..." to update what will be committed)
1334 (use "git checkout -- <file>..." to discard changes in working directory)
1336 modified: dir1/modified
1338 Untracked files:
1339 (use "git add <file>..." to include in what will be committed)
1341 .gitmodules
1342 dir1/untracked
1343 dir2/modified
1344 dir2/untracked
1345 untracked
1347 no changes added to commit (use "git add" and/or "git commit -a")
1349 git status --ignore-submodules=all > output &&
1350 test_i18ncmp expect output
1353 test_expect_success '.gitmodules ignore=all suppresses unstaged submodule summary' '
1354 cat > expect << EOF &&
1355 On branch master
1356 Changes to be committed:
1357 (use "git reset HEAD <file>..." to unstage)
1359 modified: sm
1361 Changes not staged for commit:
1362 (use "git add <file>..." to update what will be committed)
1363 (use "git checkout -- <file>..." to discard changes in working directory)
1365 modified: dir1/modified
1367 Untracked files:
1368 (use "git add <file>..." to include in what will be committed)
1370 .gitmodules
1371 dir1/untracked
1372 dir2/modified
1373 dir2/untracked
1374 untracked
1377 git config --add -f .gitmodules submodule.subname.ignore all &&
1378 git config --add -f .gitmodules submodule.subname.path sm &&
1379 git status > output &&
1380 test_cmp expect output &&
1381 git config -f .gitmodules --remove-section submodule.subname
1384 test_expect_success '.git/config ignore=all suppresses unstaged submodule summary' '
1385 git config --add -f .gitmodules submodule.subname.ignore none &&
1386 git config --add -f .gitmodules submodule.subname.path sm &&
1387 git config --add submodule.subname.ignore all &&
1388 git config --add submodule.subname.path sm &&
1389 git status > output &&
1390 test_cmp expect output &&
1391 git config --remove-section submodule.subname &&
1392 git config -f .gitmodules --remove-section submodule.subname
1395 test_expect_success 'setup of test environment' '
1396 git config status.showUntrackedFiles no &&
1397 git status -s >expected_short &&
1398 git status --no-short >expected_noshort
1401 test_expect_success '"status.short=true" same as "-s"' '
1402 git -c status.short=true status >actual &&
1403 test_cmp expected_short actual
1406 test_expect_success '"status.short=true" weaker than "--no-short"' '
1407 git -c status.short=true status --no-short >actual &&
1408 test_cmp expected_noshort actual
1411 test_expect_success '"status.short=false" same as "--no-short"' '
1412 git -c status.short=false status >actual &&
1413 test_cmp expected_noshort actual
1416 test_expect_success '"status.short=false" weaker than "-s"' '
1417 git -c status.short=false status -s >actual &&
1418 test_cmp expected_short actual
1421 test_expect_success '"status.branch=true" same as "-b"' '
1422 git status -sb >expected_branch &&
1423 git -c status.branch=true status -s >actual &&
1424 test_cmp expected_branch actual
1427 test_expect_success '"status.branch=true" different from "--no-branch"' '
1428 git status -s --no-branch >expected_nobranch &&
1429 git -c status.branch=true status -s >actual &&
1430 test_must_fail test_cmp expected_nobranch actual
1433 test_expect_success '"status.branch=true" weaker than "--no-branch"' '
1434 git -c status.branch=true status -s --no-branch >actual &&
1435 test_cmp expected_nobranch actual
1438 test_expect_success '"status.branch=true" weaker than "--porcelain"' '
1439 git -c status.branch=true status --porcelain >actual &&
1440 test_cmp expected_nobranch actual
1443 test_expect_success '"status.branch=false" same as "--no-branch"' '
1444 git -c status.branch=false status -s >actual &&
1445 test_cmp expected_nobranch actual
1448 test_expect_success '"status.branch=false" weaker than "-b"' '
1449 git -c status.branch=false status -sb >actual &&
1450 test_cmp expected_branch actual
1453 test_expect_success 'Restore default test environment' '
1454 git config --unset status.showUntrackedFiles
1457 test_expect_success 'git commit will commit a staged but ignored submodule' '
1458 git config --add -f .gitmodules submodule.subname.ignore all &&
1459 git config --add -f .gitmodules submodule.subname.path sm &&
1460 git config --add submodule.subname.ignore all &&
1461 git status -s --ignore-submodules=dirty >output &&
1462 test_i18ngrep "^M. sm" output &&
1463 GIT_EDITOR="echo hello >>\"\$1\"" &&
1464 export GIT_EDITOR &&
1465 git commit -uno &&
1466 git status -s --ignore-submodules=dirty >output &&
1467 test_i18ngrep ! "^M. sm" output
1470 test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '
1471 git reset HEAD^ &&
1472 git add sm &&
1473 cat >expect << EOF &&
1474 On branch master
1475 Changes to be committed:
1476 (use "git reset HEAD <file>..." to unstage)
1478 modified: sm
1480 Changes not staged for commit:
1481 (use "git add <file>..." to update what will be committed)
1482 (use "git checkout -- <file>..." to discard changes in working directory)
1484 modified: dir1/modified
1486 Untracked files not listed (use -u option to show untracked files)
1488 git commit -uno --dry-run >output &&
1489 test_i18ncmp expect output &&
1490 git status -s --ignore-submodules=dirty >output &&
1491 test_i18ngrep "^M. sm" output
1494 test_expect_success 'git commit -m will commit a staged but ignored submodule' '
1495 git commit -uno -m message &&
1496 git status -s --ignore-submodules=dirty >output &&
1497 test_i18ngrep ! "^M. sm" output &&
1498 git config --remove-section submodule.subname &&
1499 git config -f .gitmodules --remove-section submodule.subname
1502 test_done