3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description
='git status'
10 test_expect_success
'status -h in broken repository' '
11 git config --global advice.statusuoption false &&
13 test_when_finished "rm -fr broken" &&
17 echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
18 test_expect_code 129 git status -h >usage 2>&1
20 test_i18ngrep "[Uu]sage" broken/usage
23 test_expect_success
'commit -h in broken repository' '
25 test_when_finished "rm -fr broken" &&
29 echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
30 test_expect_code 129 git commit -h >usage 2>&1
32 test_i18ngrep "[Uu]sage" broken/usage
35 test_expect_success
'create upstream branch' '
36 git checkout -b upstream &&
37 test_commit upstream1 &&
38 test_commit upstream2 &&
39 # leave the first commit on master as root because several
40 # tests depend on this case; for our upstream we only
41 # care about commit counts anyway, so a totally divergent
43 git checkout --orphan master
46 test_expect_success
'setup' '
60 git commit -m initial &&
64 echo 1 >dir1/modified &&
65 echo 2 >dir2/modified &&
69 git branch --set-upstream-to=upstream
72 test_expect_success
'status (1)' '
73 test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output
78 sed "s/^\# //; s/^\#$//; s/^#$tab/$tab/" <"$1" >"$1".tmp
&&
79 rm "$1" && mv "$1".tmp
"$1"
82 cat >.gitignore
<<\EOF
88 test_expect_success
'status --column' '
91 # Your branch and '\''upstream'\'' have diverged,
92 # and have 1 and 2 different commits each, respectively.
93 # (use "git pull" to merge the remote branch into yours)
95 # Changes to be committed:
96 # (use "git reset HEAD <file>..." to unstage)
98 # new file: dir2/added
100 # Changes not staged for commit:
101 # (use "git add <file>..." to update what will be committed)
102 # (use "git checkout -- <file>..." to discard changes in working directory)
104 # modified: dir1/modified
107 # (use "git add <file>..." to include in what will be committed)
109 # dir1/untracked dir2/untracked
110 # dir2/modified untracked
113 COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
114 test_i18ncmp expect output
117 test_expect_success
'status --column status.displayCommentPrefix=false' '
118 strip_comments expect &&
119 COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
120 test_i18ncmp expect output
125 # Your branch and 'upstream' have diverged,
126 # and have 1 and 2 different commits each, respectively.
127 # (use "git pull" to merge the remote branch into yours)
129 # Changes to be committed:
130 # (use "git reset HEAD <file>..." to unstage)
132 # new file: dir2/added
134 # Changes not staged for commit:
135 # (use "git add <file>..." to update what will be committed)
136 # (use "git checkout -- <file>..." to discard changes in working directory)
138 # modified: dir1/modified
141 # (use "git add <file>..." to include in what will be committed)
150 test_expect_success
'status with status.displayCommentPrefix=true' '
151 git -c status.displayCommentPrefix=true status >output &&
152 test_i18ncmp expect output
155 test_expect_success
'status with status.displayCommentPrefix=false' '
156 strip_comments expect &&
157 git -c status.displayCommentPrefix=false status >output &&
158 test_i18ncmp expect output
161 test_expect_success
'status -v' '
162 (cat expect && git diff --cached) >expect-with-v &&
163 git status -v >output &&
164 test_i18ncmp expect-with-v output
167 test_expect_success
'status -v -v' '
169 echo "Changes to be committed:" &&
170 git -c diff.mnemonicprefix=true diff --cached &&
171 echo "--------------------------------------------------" &&
172 echo "Changes not staged for commit:" &&
173 git -c diff.mnemonicprefix=true diff) >expect-with-v &&
174 git status -v -v >output &&
175 test_i18ncmp expect-with-v output
178 test_expect_success
'setup fake editor' '
179 cat >.git/editor <<-\EOF &&
183 chmod 755 .git/editor
186 commit_template_commented
() {
188 EDITOR
=.git
/editor
&&
190 # Fails due to empty message
191 test_must_fail git commit
193 ! grep '^[^#]' output
196 test_expect_success
'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
197 commit_template_commented
202 Your branch and
'upstream' have diverged
,
203 and have
1 and
2 different commits each
, respectively.
205 Changes to be committed
:
208 Changes not staged
for commit
:
209 modified
: dir
1/modified
219 test_expect_success
'status (advice.statusHints false)' '
220 test_config advice.statusHints false &&
221 git status >output &&
222 test_i18ncmp expect output
235 test_expect_success
'status -s' '
237 git status -s >output &&
238 test_cmp expect output
242 test_expect_success
'status with gitignore' '
250 cat >expect <<-\EOF &&
255 git status -s >output &&
256 test_cmp expect output &&
258 cat >expect <<-\EOF &&
270 git status -s --ignored >output &&
271 test_cmp expect output &&
273 cat >expect <<\EOF &&
275 Your branch and '\''upstream'\'' have diverged,
276 and have 1 and 2 different commits each, respectively.
277 (use "git pull" to merge the remote branch into yours)
279 Changes to be committed:
280 (use "git reset HEAD <file>..." to unstage)
284 Changes not staged for commit:
285 (use "git add <file>..." to update what will be committed)
286 (use "git checkout -- <file>..." to discard changes in working directory)
288 modified: dir1/modified
291 (use "git add <file>..." to include in what will be committed)
296 (use "git add -f <file>..." to include in what will be committed)
307 git status --ignored >output &&
308 test_i18ncmp expect output
311 test_expect_success
'status with gitignore (nothing untracked)' '
315 echo "dir2/modified" &&
320 cat >expect <<-\EOF &&
324 git status -s >output &&
325 test_cmp expect output &&
327 cat >expect <<-\EOF &&
339 git status -s --ignored >output &&
340 test_cmp expect output &&
342 cat >expect <<\EOF &&
344 Your branch and '\''upstream'\'' have diverged,
345 and have 1 and 2 different commits each, respectively.
346 (use "git pull" to merge the remote branch into yours)
348 Changes to be committed:
349 (use "git reset HEAD <file>..." to unstage)
353 Changes not staged for commit:
354 (use "git add <file>..." to update what will be committed)
355 (use "git checkout -- <file>..." to discard changes in working directory)
357 modified: dir1/modified
360 (use "git add -f <file>..." to include in what will be committed)
372 git status --ignored >output &&
373 test_i18ncmp expect output
376 cat >.gitignore
<<\EOF
383 ## master...upstream [ahead 1, behind 2]
392 test_expect_success
'status -s -b' '
394 git status -s -b >output &&
395 test_i18ncmp expect output
399 test_expect_success
'status -s -z -b' '
400 tr "\\n" Q <expect >expect.q &&
401 mv expect.q expect &&
402 git status -s -z -b >output &&
403 nul_to_q <output >output.q &&
404 mv output.q output &&
405 test_i18ncmp expect output
408 test_expect_success
'setup dir3' '
410 : >dir3/untracked1 &&
414 test_expect_success
'status -uno' '
417 Your branch and '\''upstream'\'' have diverged,
418 and have 1 and 2 different commits each, respectively.
419 (use "git pull" to merge the remote branch into yours)
421 Changes to be committed:
422 (use "git reset HEAD <file>..." to unstage)
426 Changes not staged for commit:
427 (use "git add <file>..." to update what will be committed)
428 (use "git checkout -- <file>..." to discard changes in working directory)
430 modified: dir1/modified
432 Untracked files not listed (use -u option to show untracked files)
434 git status -uno >output &&
435 test_i18ncmp expect output
438 test_expect_success
'status (status.showUntrackedFiles no)' '
439 test_config status.showuntrackedfiles no &&
440 git status >output &&
441 test_i18ncmp expect output
444 test_expect_success
'status -uno (advice.statusHints false)' '
447 Your branch and '\''upstream'\'' have diverged,
448 and have 1 and 2 different commits each, respectively.
450 Changes to be committed:
453 Changes not staged for commit:
454 modified: dir1/modified
456 Untracked files not listed
458 test_config advice.statusHints false &&
459 git status -uno >output &&
460 test_i18ncmp expect output
467 test_expect_success
'status -s -uno' '
468 git status -s -uno >output &&
469 test_cmp expect output
472 test_expect_success
'status -s (status.showUntrackedFiles no)' '
473 git config status.showuntrackedfiles no &&
474 git status -s >output &&
475 test_cmp expect output
478 test_expect_success
'status -unormal' '
481 Your branch and '\''upstream'\'' have diverged,
482 and have 1 and 2 different commits each, respectively.
483 (use "git pull" to merge the remote branch into yours)
485 Changes to be committed:
486 (use "git reset HEAD <file>..." to unstage)
490 Changes not staged for commit:
491 (use "git add <file>..." to update what will be committed)
492 (use "git checkout -- <file>..." to discard changes in working directory)
494 modified: dir1/modified
497 (use "git add <file>..." to include in what will be committed)
506 git status -unormal >output &&
507 test_i18ncmp expect output
510 test_expect_success
'status (status.showUntrackedFiles normal)' '
511 test_config status.showuntrackedfiles normal &&
512 git status >output &&
513 test_i18ncmp expect output
525 test_expect_success
'status -s -unormal' '
526 git status -s -unormal >output &&
527 test_cmp expect output
530 test_expect_success
'status -s (status.showUntrackedFiles normal)' '
531 git config status.showuntrackedfiles normal &&
532 git status -s >output &&
533 test_cmp expect output
536 test_expect_success
'status -uall' '
539 Your branch and '\''upstream'\'' have diverged,
540 and have 1 and 2 different commits each, respectively.
541 (use "git pull" to merge the remote branch into yours)
543 Changes to be committed:
544 (use "git reset HEAD <file>..." to unstage)
548 Changes not staged for commit:
549 (use "git add <file>..." to update what will be committed)
550 (use "git checkout -- <file>..." to discard changes in working directory)
552 modified: dir1/modified
555 (use "git add <file>..." to include in what will be committed)
565 git status -uall >output &&
566 test_i18ncmp expect output
569 test_expect_success
'status (status.showUntrackedFiles all)' '
570 test_config status.showuntrackedfiles all &&
571 git status >output &&
572 test_i18ncmp expect output
575 test_expect_success
'teardown dir3' '
587 test_expect_success
'status -s -uall' '
588 test_unconfig status.showuntrackedfiles &&
589 git status -s -uall >output &&
590 test_cmp expect output
592 test_expect_success
'status -s (status.showUntrackedFiles all)' '
593 test_config status.showuntrackedfiles all &&
594 git status -s >output &&
596 test_cmp expect output
599 test_expect_success
'status with relative paths' '
600 cat >expect <<\EOF &&
602 Your branch and '\''upstream'\'' have diverged,
603 and have 1 and 2 different commits each, respectively.
604 (use "git pull" to merge the remote branch into yours)
606 Changes to be committed:
607 (use "git reset HEAD <file>..." to unstage)
609 new file: ../dir2/added
611 Changes not staged for commit:
612 (use "git add <file>..." to update what will be committed)
613 (use "git checkout -- <file>..." to discard changes in working directory)
618 (use "git add <file>..." to include in what will be committed)
626 (cd dir1 && git status) >output &&
627 test_i18ncmp expect output
638 test_expect_success
'status -s with relative paths' '
640 (cd dir1 && git status -s) >output &&
641 test_cmp expect output
654 test_expect_success
'status --porcelain ignores relative paths setting' '
656 (cd dir1 && git status --porcelain) >output &&
657 test_cmp expect output
661 test_expect_success
'setup unique colors' '
663 git config status.color.untracked blue &&
664 git config status.color.branch green &&
665 git config status.color.localBranch yellow &&
666 git config status.color.remoteBranch cyan
670 test_expect_success
'status with color.ui' '
671 cat >expect <<\EOF &&
672 On branch <GREEN>master<RESET>
673 Your branch and '\''upstream'\'' have diverged,
674 and have 1 and 2 different commits each, respectively.
675 (use "git pull" to merge the remote branch into yours)
677 Changes to be committed:
678 (use "git reset HEAD <file>..." to unstage)
680 <GREEN>new file: dir2/added<RESET>
682 Changes not staged for commit:
683 (use "git add <file>..." to update what will be committed)
684 (use "git checkout -- <file>..." to discard changes in working directory)
686 <RED>modified: dir1/modified<RESET>
689 (use "git add <file>..." to include in what will be committed)
691 <BLUE>dir1/untracked<RESET>
692 <BLUE>dir2/modified<RESET>
693 <BLUE>dir2/untracked<RESET>
694 <BLUE>untracked<RESET>
697 test_config color.ui always &&
698 git status | test_decode_color >output &&
699 test_i18ncmp expect output
702 test_expect_success
'status with color.status' '
703 test_config color.status always &&
704 git status | test_decode_color >output &&
705 test_i18ncmp expect output
709 <RED
>M
<RESET
> dir
1/modified
710 <GREEN
>A
<RESET
> dir
2/added
711 <BLUE
>??
<RESET
> dir
1/untracked
712 <BLUE
>??
<RESET
> dir
2/modified
713 <BLUE
>??
<RESET
> dir
2/untracked
714 <BLUE
>??
<RESET
> untracked
717 test_expect_success
'status -s with color.ui' '
719 git config color.ui always &&
720 git status -s | test_decode_color >output &&
721 test_cmp expect output
725 test_expect_success
'status -s with color.status' '
727 git config --unset color.ui &&
728 git config color.status always &&
729 git status -s | test_decode_color >output &&
730 test_cmp expect output
735 ## <YELLOW>master<RESET>...<CYAN>upstream<RESET> [ahead <YELLOW>1<RESET>, behind <CYAN>2<RESET>]
736 <RED
>M
<RESET
> dir
1/modified
737 <GREEN
>A
<RESET
> dir
2/added
738 <BLUE
>??
<RESET
> dir
1/untracked
739 <BLUE
>??
<RESET
> dir
2/modified
740 <BLUE
>??
<RESET
> dir
2/untracked
741 <BLUE
>??
<RESET
> untracked
744 test_expect_success
'status -s -b with color.status' '
746 git status -s -b | test_decode_color >output &&
747 test_i18ncmp expect output
760 test_expect_success
'status --porcelain ignores color.ui' '
762 git config --unset color.status &&
763 git config color.ui always &&
764 git status --porcelain | test_decode_color >output &&
765 test_cmp expect output
769 test_expect_success
'status --porcelain ignores color.status' '
771 git config --unset color.ui &&
772 git config color.status always &&
773 git status --porcelain | test_decode_color >output &&
774 test_cmp expect output
778 # recover unconditionally from color tests
779 git config
--unset color.status
780 git config
--unset color.ui
782 test_expect_success
'status --porcelain respects -b' '
784 git status --porcelain -b >output &&
786 echo "## master...upstream [ahead 1, behind 2]" &&
790 test_cmp expect output
796 test_expect_success
'status without relative paths' '
797 cat >expect <<\EOF &&
799 Your branch and '\''upstream'\'' have diverged,
800 and have 1 and 2 different commits each, respectively.
801 (use "git pull" to merge the remote branch into yours)
803 Changes to be committed:
804 (use "git reset HEAD <file>..." to unstage)
808 Changes not staged for commit:
809 (use "git add <file>..." to update what will be committed)
810 (use "git checkout -- <file>..." to discard changes in working directory)
812 modified: dir1/modified
815 (use "git add <file>..." to include in what will be committed)
823 test_config status.relativePaths false &&
824 (cd dir1 && git status) >output &&
825 test_i18ncmp expect output
838 test_expect_success
'status -s without relative paths' '
840 test_config status.relativePaths false &&
841 (cd dir1 && git status -s) >output &&
842 test_cmp expect output
846 test_expect_success
'dry-run of partial commit excluding new file in index' '
849 Your branch and '\''upstream'\'' have diverged,
850 and have 1 and 2 different commits each, respectively.
851 (use "git pull" to merge the remote branch into yours)
853 Changes to be committed:
854 (use "git reset HEAD <file>..." to unstage)
856 modified: dir1/modified
859 (use "git add <file>..." to include in what will be committed)
866 git commit --dry-run dir1/modified >output &&
867 test_i18ncmp expect output
871 :100644 100644 $EMPTY_BLOB 0000000000000000000000000000000000000000 M dir1/modified
873 test_expect_success
'status refreshes the index' '
876 git diff-files >output &&
877 test_cmp expect output
880 test_expect_success
'setup status submodule summary' '
881 test_create_repo sm && (
885 git commit -m "Add foo"
890 test_expect_success
'status submodule summary is disabled by default' '
893 Your branch and '\''upstream'\'' have diverged,
894 and have 1 and 2 different commits each, respectively.
895 (use "git pull" to merge the remote branch into yours)
897 Changes to be committed:
898 (use "git reset HEAD <file>..." to unstage)
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
910 (use "git add <file>..." to include in what will be committed)
918 git status >output &&
919 test_i18ncmp expect output
922 # we expect the same as the previous test
923 test_expect_success
'status --untracked-files=all does not show submodule' '
924 git status --untracked-files=all >output &&
925 test_i18ncmp expect output
937 test_expect_success
'status -s submodule summary is disabled by default' '
938 git status -s >output &&
939 test_cmp expect output
942 # we expect the same as the previous test
943 test_expect_success
'status -s --untracked-files=all does not show submodule' '
944 git status -s --untracked-files=all >output &&
945 test_cmp expect output
948 head=$
(cd sm
&& git rev-parse
--short=7 --verify HEAD
)
950 test_expect_success
'status submodule summary' '
953 Your branch and '\''upstream'\'' have diverged,
954 and have 1 and 2 different commits each, respectively.
955 (use "git pull" to merge the remote branch into yours)
957 Changes to be committed:
958 (use "git reset HEAD <file>..." to unstage)
963 Changes not staged for commit:
964 (use "git add <file>..." to update what will be committed)
965 (use "git checkout -- <file>..." to discard changes in working directory)
967 modified: dir1/modified
969 Submodule changes to be committed:
971 * sm 0000000...$head (1):
975 (use "git add <file>..." to include in what will be committed)
983 git config status.submodulesummary 10 &&
984 git status >output &&
985 test_i18ncmp expect output
988 test_expect_success
'status submodule summary with status.displayCommentPrefix=false' '
989 strip_comments expect &&
990 git -c status.displayCommentPrefix=false status >output &&
991 test_i18ncmp expect output
994 test_expect_success
'commit with submodule summary ignores status.displayCommentPrefix' '
995 commit_template_commented
1007 test_expect_success
'status -s submodule summary' '
1008 git status -s >output &&
1009 test_cmp expect output
1012 test_expect_success
'status submodule summary (clean submodule): commit' '
1013 cat >expect <<EOF &&
1015 Your branch and '\''upstream'\'' have diverged,
1016 and have 2 and 2 different commits each, respectively.
1017 (use "git pull" to merge the remote branch into yours)
1019 Changes not staged for commit:
1020 (use "git add <file>..." to update what will be committed)
1021 (use "git checkout -- <file>..." to discard changes in working directory)
1023 modified: dir1/modified
1026 (use "git add <file>..." to include in what will be committed)
1033 no changes added to commit (use "git add" and/or "git commit -a")
1035 git commit -m "commit submodule" &&
1036 git config status.submodulesummary 10 &&
1037 test_must_fail git commit --dry-run >output &&
1038 test_i18ncmp expect output &&
1039 git status >output &&
1040 test_i18ncmp expect output
1050 test_expect_success
'status -s submodule summary (clean submodule)' '
1051 git status -s >output &&
1052 test_cmp expect output
1055 test_expect_success
'status -z implies porcelain' '
1056 git status --porcelain |
1057 perl -pe "s/\012/\000/g" >expect &&
1058 git status -z >output &&
1059 test_cmp expect output
1062 test_expect_success
'commit --dry-run submodule summary (--amend)' '
1063 cat >expect <<EOF &&
1065 Your branch and '\''upstream'\'' have diverged,
1066 and have 2 and 2 different commits each, respectively.
1067 (use "git pull" to merge the remote branch into yours)
1069 Changes to be committed:
1070 (use "git reset HEAD^1 <file>..." to unstage)
1072 new file: dir2/added
1075 Changes not staged for commit:
1076 (use "git add <file>..." to update what will be committed)
1077 (use "git checkout -- <file>..." to discard changes in working directory)
1079 modified: dir1/modified
1081 Submodule changes to be committed:
1083 * sm 0000000...$head (1):
1087 (use "git add <file>..." to include in what will be committed)
1095 git config status.submodulesummary 10 &&
1096 git commit --dry-run --amend >output &&
1097 test_i18ncmp expect output
1100 test_expect_success POSIXPERM
,SANITY
'status succeeds in a read-only repository' '
1103 # make dir1/tracked stat-dirty
1104 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
1105 git status -s >output &&
1106 ! grep dir1/tracked output &&
1107 # make sure "status" succeeded without writing index out
1108 git diff-files | grep dir1/tracked
1115 (cd sm
&& echo > bar
&& git add bar
&& git commit
-q -m 'Add bar') && git add sm
1116 new_head
=$
(cd sm
&& git rev-parse
--short=7 --verify HEAD
)
1119 test_expect_success
'--ignore-submodules=untracked suppresses submodules with untracked content' '
1120 cat > expect << EOF &&
1122 Your branch and '\''upstream'\'' have diverged,
1123 and have 2 and 2 different commits each, respectively.
1124 (use "git pull" to merge the remote branch into yours)
1126 Changes to be committed:
1127 (use "git reset HEAD <file>..." to unstage)
1131 Changes not staged for commit:
1132 (use "git add <file>..." to update what will be committed)
1133 (use "git checkout -- <file>..." to discard changes in working directory)
1135 modified: dir1/modified
1137 Submodule changes to be committed:
1139 * sm $head...$new_head (1):
1143 (use "git add <file>..." to include in what will be committed)
1152 echo modified sm/untracked &&
1153 git status --ignore-submodules=untracked >output &&
1154 test_i18ncmp expect output
1157 test_expect_success
'.gitmodules ignore=untracked suppresses submodules with untracked content' '
1158 test_config diff.ignoreSubmodules dirty &&
1159 git status >output &&
1160 test_i18ncmp expect output &&
1161 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1162 git config --add -f .gitmodules submodule.subname.path sm &&
1163 git status >output &&
1164 test_i18ncmp expect output &&
1165 git config -f .gitmodules --remove-section submodule.subname
1168 test_expect_success
'.git/config ignore=untracked suppresses submodules with untracked content' '
1169 git config --add -f .gitmodules submodule.subname.ignore none &&
1170 git config --add -f .gitmodules submodule.subname.path sm &&
1171 git config --add submodule.subname.ignore untracked &&
1172 git config --add submodule.subname.path sm &&
1173 git status >output &&
1174 test_i18ncmp expect output &&
1175 git config --remove-section submodule.subname &&
1176 git config --remove-section -f .gitmodules submodule.subname
1179 test_expect_success
'--ignore-submodules=dirty suppresses submodules with untracked content' '
1180 git status --ignore-submodules=dirty >output &&
1181 test_i18ncmp expect output
1184 test_expect_success
'.gitmodules ignore=dirty suppresses submodules with untracked content' '
1185 test_config diff.ignoreSubmodules dirty &&
1186 git status >output &&
1188 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1189 git config --add -f .gitmodules submodule.subname.path sm &&
1190 git status >output &&
1191 test_i18ncmp expect output &&
1192 git config -f .gitmodules --remove-section submodule.subname
1195 test_expect_success
'.git/config ignore=dirty suppresses submodules with untracked content' '
1196 git config --add -f .gitmodules submodule.subname.ignore none &&
1197 git config --add -f .gitmodules submodule.subname.path sm &&
1198 git config --add submodule.subname.ignore dirty &&
1199 git config --add submodule.subname.path sm &&
1200 git status >output &&
1201 test_i18ncmp expect output &&
1202 git config --remove-section submodule.subname &&
1203 git config -f .gitmodules --remove-section submodule.subname
1206 test_expect_success
'--ignore-submodules=dirty suppresses submodules with modified content' '
1207 echo modified >sm/foo &&
1208 git status --ignore-submodules=dirty >output &&
1209 test_i18ncmp expect output
1212 test_expect_success
'.gitmodules ignore=dirty suppresses submodules with modified content' '
1213 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1214 git config --add -f .gitmodules submodule.subname.path sm &&
1215 git status >output &&
1216 test_i18ncmp expect output &&
1217 git config -f .gitmodules --remove-section submodule.subname
1220 test_expect_success
'.git/config ignore=dirty suppresses submodules with modified content' '
1221 git config --add -f .gitmodules submodule.subname.ignore none &&
1222 git config --add -f .gitmodules submodule.subname.path sm &&
1223 git config --add submodule.subname.ignore dirty &&
1224 git config --add submodule.subname.path sm &&
1225 git status >output &&
1226 test_i18ncmp expect output &&
1227 git config --remove-section submodule.subname &&
1228 git config -f .gitmodules --remove-section submodule.subname
1231 test_expect_success
"--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1232 cat > expect << EOF &&
1234 Your branch and '\''upstream'\'' have diverged,
1235 and have 2 and 2 different commits each, respectively.
1236 (use "git pull" to merge the remote branch into yours)
1238 Changes to be committed:
1239 (use "git reset HEAD <file>..." to unstage)
1243 Changes not staged for commit:
1244 (use "git add <file>..." to update what will be committed)
1245 (use "git checkout -- <file>..." to discard changes in working directory)
1246 (commit or discard the untracked or modified content in submodules)
1248 modified: dir1/modified
1249 modified: sm (modified content)
1251 Submodule changes to be committed:
1253 * sm $head...$new_head (1):
1257 (use "git add <file>..." to include in what will be committed)
1266 git status --ignore-submodules=untracked > output &&
1267 test_i18ncmp expect output
1270 test_expect_success
".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
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 submodules with modified content" '
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 head2
=$
(cd sm
&& git commit
-q -m "2nd commit" foo
&& git rev-parse
--short=7 --verify HEAD
)
1291 test_expect_success
"--ignore-submodules=untracked doesn't suppress submodule summary" '
1292 cat > expect << EOF &&
1294 Your branch and '\''upstream'\'' have diverged,
1295 and have 2 and 2 different commits each, respectively.
1296 (use "git pull" to merge the remote branch into yours)
1298 Changes to be committed:
1299 (use "git reset HEAD <file>..." to unstage)
1303 Changes not staged for commit:
1304 (use "git add <file>..." to update what will be committed)
1305 (use "git checkout -- <file>..." to discard changes in working directory)
1307 modified: dir1/modified
1308 modified: sm (new commits)
1310 Submodule changes to be committed:
1312 * sm $head...$new_head (1):
1315 Submodules changed but not updated:
1317 * sm $new_head...$head2 (1):
1321 (use "git add <file>..." to include in what will be committed)
1330 git status --ignore-submodules=untracked > output &&
1331 test_i18ncmp expect output
1334 test_expect_success
".gitmodules ignore=untracked doesn't suppress submodule summary" '
1335 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1336 git config --add -f .gitmodules submodule.subname.path sm &&
1337 git status >output &&
1338 test_i18ncmp expect output &&
1339 git config -f .gitmodules --remove-section submodule.subname
1342 test_expect_success
".git/config ignore=untracked doesn't suppress submodule summary" '
1343 git config --add -f .gitmodules submodule.subname.ignore none &&
1344 git config --add -f .gitmodules submodule.subname.path sm &&
1345 git config --add submodule.subname.ignore untracked &&
1346 git config --add submodule.subname.path sm &&
1347 git status >output &&
1348 test_i18ncmp expect output &&
1349 git config --remove-section submodule.subname &&
1350 git config -f .gitmodules --remove-section submodule.subname
1353 test_expect_success
"--ignore-submodules=dirty doesn't suppress submodule summary" '
1354 git status --ignore-submodules=dirty > output &&
1355 test_i18ncmp expect output
1357 test_expect_success
".gitmodules ignore=dirty doesn't suppress submodule summary" '
1358 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1359 git config --add -f .gitmodules submodule.subname.path sm &&
1360 git status >output &&
1361 test_i18ncmp expect output &&
1362 git config -f .gitmodules --remove-section submodule.subname
1365 test_expect_success
".git/config ignore=dirty doesn't suppress submodule summary" '
1366 git config --add -f .gitmodules submodule.subname.ignore none &&
1367 git config --add -f .gitmodules submodule.subname.path sm &&
1368 git config --add submodule.subname.ignore dirty &&
1369 git config --add submodule.subname.path sm &&
1370 git status >output &&
1371 test_i18ncmp expect output &&
1372 git config --remove-section submodule.subname &&
1373 git config -f .gitmodules --remove-section submodule.subname
1378 ; Your branch and 'upstream' have diverged,
1379 ; and have 2 and 2 different commits each, respectively.
1380 ; (use "git pull" to merge the remote branch into yours)
1382 ; Changes to be committed:
1383 ; (use "git reset HEAD <file>..." to unstage)
1387 ; Changes not staged for commit:
1388 ; (use "git add <file>..." to update what will be committed)
1389 ; (use "git checkout -- <file>..." to discard changes in working directory)
1391 ; modified: dir1/modified
1392 ; modified: sm (new commits)
1394 ; Submodule changes to be committed:
1396 ; * sm $head...$new_head (1):
1399 ; Submodules changed but not updated:
1401 ; * sm $new_head...$head2 (1):
1405 ; (use "git add <file>..." to include in what will be committed)
1415 test_expect_success
"status (core.commentchar with submodule summary)" '
1416 test_config core.commentchar ";" &&
1417 git -c status.displayCommentPrefix=true status >output &&
1418 test_i18ncmp expect output
1421 test_expect_success
"status (core.commentchar with two chars with submodule summary)" '
1422 test_config core.commentchar ";;" &&
1423 test_must_fail git -c status.displayCommentPrefix=true status
1426 test_expect_success
"--ignore-submodules=all suppresses submodule summary" '
1427 cat > expect << EOF &&
1429 Your branch and '\''upstream'\'' have diverged,
1430 and have 2 and 2 different commits each, respectively.
1431 (use "git pull" to merge the remote branch into yours)
1433 Changes not staged for commit:
1434 (use "git add <file>..." to update what will be committed)
1435 (use "git checkout -- <file>..." to discard changes in working directory)
1437 modified: dir1/modified
1440 (use "git add <file>..." to include in what will be committed)
1448 no changes added to commit (use "git add" and/or "git commit -a")
1450 git status --ignore-submodules=all > output &&
1451 test_i18ncmp expect output
1454 test_expect_success
'.gitmodules ignore=all suppresses unstaged submodule summary' '
1455 cat > expect << EOF &&
1457 Your branch and '\''upstream'\'' have diverged,
1458 and have 2 and 2 different commits each, respectively.
1459 (use "git pull" to merge the remote branch into yours)
1461 Changes to be committed:
1462 (use "git reset HEAD <file>..." to unstage)
1466 Changes not staged for commit:
1467 (use "git add <file>..." to update what will be committed)
1468 (use "git checkout -- <file>..." to discard changes in working directory)
1470 modified: dir1/modified
1473 (use "git add <file>..." to include in what will be committed)
1482 git config --add -f .gitmodules submodule.subname.ignore all &&
1483 git config --add -f .gitmodules submodule.subname.path sm &&
1484 git status > output &&
1485 test_i18ncmp expect output &&
1486 git config -f .gitmodules --remove-section submodule.subname
1489 test_expect_success
'.git/config ignore=all suppresses unstaged submodule summary' '
1490 git config --add -f .gitmodules submodule.subname.ignore none &&
1491 git config --add -f .gitmodules submodule.subname.path sm &&
1492 git config --add submodule.subname.ignore all &&
1493 git config --add submodule.subname.path sm &&
1494 git status > output &&
1495 test_i18ncmp expect output &&
1496 git config --remove-section submodule.subname &&
1497 git config -f .gitmodules --remove-section submodule.subname
1500 test_expect_success
'setup of test environment' '
1501 git config status.showUntrackedFiles no &&
1502 git status -s >expected_short &&
1503 git status --no-short >expected_noshort
1506 test_expect_success
'"status.short=true" same as "-s"' '
1507 git -c status.short=true status >actual &&
1508 test_cmp expected_short actual
1511 test_expect_success
'"status.short=true" weaker than "--no-short"' '
1512 git -c status.short=true status --no-short >actual &&
1513 test_cmp expected_noshort actual
1516 test_expect_success
'"status.short=false" same as "--no-short"' '
1517 git -c status.short=false status >actual &&
1518 test_cmp expected_noshort actual
1521 test_expect_success
'"status.short=false" weaker than "-s"' '
1522 git -c status.short=false status -s >actual &&
1523 test_cmp expected_short actual
1526 test_expect_success
'"status.branch=true" same as "-b"' '
1527 git status -sb >expected_branch &&
1528 git -c status.branch=true status -s >actual &&
1529 test_cmp expected_branch actual
1532 test_expect_success
'"status.branch=true" different from "--no-branch"' '
1533 git status -s --no-branch >expected_nobranch &&
1534 git -c status.branch=true status -s >actual &&
1535 test_must_fail test_cmp expected_nobranch actual
1538 test_expect_success
'"status.branch=true" weaker than "--no-branch"' '
1539 git -c status.branch=true status -s --no-branch >actual &&
1540 test_cmp expected_nobranch actual
1543 test_expect_success
'"status.branch=true" weaker than "--porcelain"' '
1544 git -c status.branch=true status --porcelain >actual &&
1545 test_cmp expected_nobranch actual
1548 test_expect_success
'"status.branch=false" same as "--no-branch"' '
1549 git -c status.branch=false status -s >actual &&
1550 test_cmp expected_nobranch actual
1553 test_expect_success
'"status.branch=false" weaker than "-b"' '
1554 git -c status.branch=false status -sb >actual &&
1555 test_cmp expected_branch actual
1558 test_expect_success
'Restore default test environment' '
1559 git config --unset status.showUntrackedFiles
1562 test_expect_success
'git commit will commit a staged but ignored submodule' '
1563 git config --add -f .gitmodules submodule.subname.ignore all &&
1564 git config --add -f .gitmodules submodule.subname.path sm &&
1565 git config --add submodule.subname.ignore all &&
1566 git status -s --ignore-submodules=dirty >output &&
1567 test_i18ngrep "^M. sm" output &&
1568 GIT_EDITOR="echo hello >>\"\$1\"" &&
1569 export GIT_EDITOR &&
1571 git status -s --ignore-submodules=dirty >output &&
1572 test_i18ngrep ! "^M. sm" output
1575 test_expect_success
'git commit --dry-run will show a staged but ignored submodule' '
1578 cat >expect << EOF &&
1580 Your branch and '\''upstream'\'' have diverged,
1581 and have 2 and 2 different commits each, respectively.
1582 (use "git pull" to merge the remote branch into yours)
1584 Changes to be committed:
1585 (use "git reset HEAD <file>..." to unstage)
1589 Changes not staged for commit:
1590 (use "git add <file>..." to update what will be committed)
1591 (use "git checkout -- <file>..." to discard changes in working directory)
1593 modified: dir1/modified
1595 Untracked files not listed (use -u option to show untracked files)
1597 git commit -uno --dry-run >output &&
1598 test_i18ncmp expect output &&
1599 git status -s --ignore-submodules=dirty >output &&
1600 test_i18ngrep "^M. sm" output
1603 test_expect_success
'git commit -m will commit a staged but ignored submodule' '
1604 git commit -uno -m message &&
1605 git status -s --ignore-submodules=dirty >output &&
1606 test_i18ngrep ! "^M. sm" output &&
1607 git config --remove-section submodule.subname &&
1608 git config -f .gitmodules --remove-section submodule.subname
1611 test_expect_success
'show stash info with "--show-stash"' '
1617 git status >expected_default &&
1618 git status --show-stash >expected_with_stash &&
1619 test_i18ngrep "^Your stash currently has 1 entry$" expected_with_stash
1622 test_expect_success
'no stash info with "--show-stash --no-show-stash"' '
1623 git status --show-stash --no-show-stash >expected_without_stash &&
1624 test_cmp expected_default expected_without_stash
1627 test_expect_success
'"status.showStash=false" weaker than "--show-stash"' '
1628 git -c status.showStash=false status --show-stash >actual &&
1629 test_cmp expected_with_stash actual
1632 test_expect_success
'"status.showStash=true" weaker than "--no-show-stash"' '
1633 git -c status.showStash=true status --no-show-stash >actual &&
1634 test_cmp expected_without_stash actual
1637 test_expect_success
'no additionnal info if no stash entries' '
1639 git -c status.showStash=true status >actual &&
1640 test_cmp expected_without_stash actual