3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='git status'
9 . "$TEST_DIRECTORY"/lib-terminal.sh
11 test_expect_success 'status -h in broken repository' '
12 git config --global advice.statusuoption false &&
14 test_when_finished "rm -fr broken" &&
18 echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
19 test_expect_code 129 git status -h >usage 2>&1
21 test_i18ngrep "[Uu]sage" broken/usage
24 test_expect_success 'commit -h in broken repository' '
26 test_when_finished "rm -fr broken" &&
30 echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
31 test_expect_code 129 git commit -h >usage 2>&1
33 test_i18ngrep "[Uu]sage" broken/usage
36 test_expect_success 'create upstream branch' '
37 git checkout -b upstream &&
38 test_commit upstream1 &&
39 test_commit upstream2 &&
40 # leave the first commit on master as root because several
41 # tests depend on this case; for our upstream we only
42 # care about commit counts anyway, so a totally divergent
44 git checkout --orphan master
47 test_expect_success 'setup' '
61 git commit -m initial &&
65 echo 1 >dir1/modified &&
66 echo 2 >dir2/modified &&
70 git branch --set-upstream-to=upstream
73 test_expect_success 'status (1)' '
74 test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output
79 sed "s/^\# //; s/^\#$//; s/^#$tab/$tab/" <"$1" >"$1".tmp &&
80 rm "$1" && mv "$1".tmp "$1"
83 cat >.gitignore <<\EOF
89 test_expect_success 'status --column' '
92 # Your branch and '\''upstream'\'' have diverged,
93 # and have 1 and 2 different commits each, respectively.
94 # (use "git pull" to merge the remote branch into yours)
96 # Changes to be committed:
97 # (use "git reset HEAD <file>..." to unstage)
99 # new file: dir2/added
101 # Changes not staged for commit:
102 # (use "git add <file>..." to update what will be committed)
103 # (use "git checkout -- <file>..." to discard changes in working directory)
105 # modified: dir1/modified
108 # (use "git add <file>..." to include in what will be committed)
110 # dir1/untracked dir2/untracked
111 # dir2/modified untracked
114 COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
115 test_i18ncmp expect output
118 test_expect_success 'status --column status.displayCommentPrefix=false' '
119 strip_comments expect &&
120 COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
121 test_i18ncmp expect output
126 # Your branch and 'upstream' have diverged,
127 # and have 1 and 2 different commits each, respectively.
128 # (use "git pull" to merge the remote branch into yours)
130 # Changes to be committed:
131 # (use "git reset HEAD <file>..." to unstage)
133 # new file: dir2/added
135 # Changes not staged for commit:
136 # (use "git add <file>..." to update what will be committed)
137 # (use "git checkout -- <file>..." to discard changes in working directory)
139 # modified: dir1/modified
142 # (use "git add <file>..." to include in what will be committed)
151 test_expect_success 'status with status.displayCommentPrefix=true' '
152 git -c status.displayCommentPrefix=true status >output &&
153 test_i18ncmp expect output
156 test_expect_success 'status with status.displayCommentPrefix=false' '
157 strip_comments expect &&
158 git -c status.displayCommentPrefix=false status >output &&
159 test_i18ncmp expect output
162 test_expect_success 'status -v' '
163 (cat expect && git diff --cached) >expect-with-v &&
164 git status -v >output &&
165 test_i18ncmp expect-with-v output
168 test_expect_success 'status -v -v' '
170 echo "Changes to be committed:" &&
171 git -c diff.mnemonicprefix=true diff --cached &&
172 echo "--------------------------------------------------" &&
173 echo "Changes not staged for commit:" &&
174 git -c diff.mnemonicprefix=true diff) >expect-with-v &&
175 git status -v -v >output &&
176 test_i18ncmp expect-with-v output
179 test_expect_success 'setup fake editor' '
180 cat >.git/editor <<-\EOF &&
184 chmod 755 .git/editor
187 commit_template_commented () {
189 EDITOR=.git/editor &&
191 # Fails due to empty message
192 test_must_fail git commit
194 ! grep '^[^#]' output
197 test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
198 commit_template_commented
203 Your branch and 'upstream' have diverged,
204 and have 1 and 2 different commits each, respectively.
206 Changes to be committed:
209 Changes not staged for commit:
210 modified: dir1/modified
220 test_expect_success 'status (advice.statusHints false)' '
221 test_config advice.statusHints false &&
222 git status >output &&
223 test_i18ncmp expect output
236 test_expect_success 'status -s' '
238 git status -s >output &&
239 test_cmp expect output
243 test_expect_success 'status with gitignore' '
251 cat >expect <<-\EOF &&
256 git status -s >output &&
257 test_cmp expect output &&
259 cat >expect <<-\EOF &&
271 git status -s --ignored >output &&
272 test_cmp expect output &&
274 cat >expect <<\EOF &&
276 Your branch and '\''upstream'\'' have diverged,
277 and have 1 and 2 different commits each, respectively.
278 (use "git pull" to merge the remote branch into yours)
280 Changes to be committed:
281 (use "git reset HEAD <file>..." to unstage)
285 Changes not staged for commit:
286 (use "git add <file>..." to update what will be committed)
287 (use "git checkout -- <file>..." to discard changes in working directory)
289 modified: dir1/modified
292 (use "git add <file>..." to include in what will be committed)
297 (use "git add -f <file>..." to include in what will be committed)
308 git status --ignored >output &&
309 test_i18ncmp expect output
312 test_expect_success 'status with gitignore (nothing untracked)' '
316 echo "dir2/modified" &&
321 cat >expect <<-\EOF &&
325 git status -s >output &&
326 test_cmp expect output &&
328 cat >expect <<-\EOF &&
340 git status -s --ignored >output &&
341 test_cmp expect output &&
343 cat >expect <<\EOF &&
345 Your branch and '\''upstream'\'' have diverged,
346 and have 1 and 2 different commits each, respectively.
347 (use "git pull" to merge the remote branch into yours)
349 Changes to be committed:
350 (use "git reset HEAD <file>..." to unstage)
354 Changes not staged for commit:
355 (use "git add <file>..." to update what will be committed)
356 (use "git checkout -- <file>..." to discard changes in working directory)
358 modified: dir1/modified
361 (use "git add -f <file>..." to include in what will be committed)
373 git status --ignored >output &&
374 test_i18ncmp expect output
377 cat >.gitignore <<\EOF
384 ## master...upstream [ahead 1, behind 2]
393 test_expect_success 'status -s -b' '
395 git status -s -b >output &&
396 test_i18ncmp expect output
400 test_expect_success 'status -s -z -b' '
401 tr "\\n" Q <expect >expect.q &&
402 mv expect.q expect &&
403 git status -s -z -b >output &&
404 nul_to_q <output >output.q &&
405 mv output.q output &&
406 test_i18ncmp expect output
409 test_expect_success 'setup dir3' '
411 : >dir3/untracked1 &&
415 test_expect_success 'status -uno' '
418 Your branch and '\''upstream'\'' have diverged,
419 and have 1 and 2 different commits each, respectively.
420 (use "git pull" to merge the remote branch into yours)
422 Changes to be committed:
423 (use "git reset HEAD <file>..." to unstage)
427 Changes not staged for commit:
428 (use "git add <file>..." to update what will be committed)
429 (use "git checkout -- <file>..." to discard changes in working directory)
431 modified: dir1/modified
433 Untracked files not listed (use -u option to show untracked files)
435 git status -uno >output &&
436 test_i18ncmp expect output
439 test_expect_success 'status (status.showUntrackedFiles no)' '
440 test_config status.showuntrackedfiles no &&
441 git status >output &&
442 test_i18ncmp expect output
445 test_expect_success 'status -uno (advice.statusHints false)' '
448 Your branch and '\''upstream'\'' have diverged,
449 and have 1 and 2 different commits each, respectively.
451 Changes to be committed:
454 Changes not staged for commit:
455 modified: dir1/modified
457 Untracked files not listed
459 test_config advice.statusHints false &&
460 git status -uno >output &&
461 test_i18ncmp expect output
468 test_expect_success 'status -s -uno' '
469 git status -s -uno >output &&
470 test_cmp expect output
473 test_expect_success 'status -s (status.showUntrackedFiles no)' '
474 git config status.showuntrackedfiles no &&
475 git status -s >output &&
476 test_cmp expect output
479 test_expect_success 'status -unormal' '
482 Your branch and '\''upstream'\'' have diverged,
483 and have 1 and 2 different commits each, respectively.
484 (use "git pull" to merge the remote branch into yours)
486 Changes to be committed:
487 (use "git reset HEAD <file>..." to unstage)
491 Changes not staged for commit:
492 (use "git add <file>..." to update what will be committed)
493 (use "git checkout -- <file>..." to discard changes in working directory)
495 modified: dir1/modified
498 (use "git add <file>..." to include in what will be committed)
507 git status -unormal >output &&
508 test_i18ncmp expect output
511 test_expect_success 'status (status.showUntrackedFiles normal)' '
512 test_config status.showuntrackedfiles normal &&
513 git status >output &&
514 test_i18ncmp expect output
526 test_expect_success 'status -s -unormal' '
527 git status -s -unormal >output &&
528 test_cmp expect output
531 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
532 git config status.showuntrackedfiles normal &&
533 git status -s >output &&
534 test_cmp expect output
537 test_expect_success 'status -uall' '
540 Your branch and '\''upstream'\'' have diverged,
541 and have 1 and 2 different commits each, respectively.
542 (use "git pull" to merge the remote branch into yours)
544 Changes to be committed:
545 (use "git reset HEAD <file>..." to unstage)
549 Changes not staged for commit:
550 (use "git add <file>..." to update what will be committed)
551 (use "git checkout -- <file>..." to discard changes in working directory)
553 modified: dir1/modified
556 (use "git add <file>..." to include in what will be committed)
566 git status -uall >output &&
567 test_i18ncmp expect output
570 test_expect_success 'status (status.showUntrackedFiles all)' '
571 test_config status.showuntrackedfiles all &&
572 git status >output &&
573 test_i18ncmp expect output
576 test_expect_success 'teardown dir3' '
588 test_expect_success 'status -s -uall' '
589 test_unconfig status.showuntrackedfiles &&
590 git status -s -uall >output &&
591 test_cmp expect output
593 test_expect_success 'status -s (status.showUntrackedFiles all)' '
594 test_config status.showuntrackedfiles all &&
595 git status -s >output &&
597 test_cmp expect output
600 test_expect_success 'status with relative paths' '
601 cat >expect <<\EOF &&
603 Your branch and '\''upstream'\'' have diverged,
604 and have 1 and 2 different commits each, respectively.
605 (use "git pull" to merge the remote branch into yours)
607 Changes to be committed:
608 (use "git reset HEAD <file>..." to unstage)
610 new file: ../dir2/added
612 Changes not staged for commit:
613 (use "git add <file>..." to update what will be committed)
614 (use "git checkout -- <file>..." to discard changes in working directory)
619 (use "git add <file>..." to include in what will be committed)
627 (cd dir1 && git status) >output &&
628 test_i18ncmp expect output
639 test_expect_success 'status -s with relative paths' '
641 (cd dir1 && git status -s) >output &&
642 test_cmp expect output
655 test_expect_success 'status --porcelain ignores relative paths setting' '
657 (cd dir1 && git status --porcelain) >output &&
658 test_cmp expect output
662 test_expect_success 'setup unique colors' '
664 git config status.color.untracked blue &&
665 git config status.color.branch green &&
666 git config status.color.localBranch yellow &&
667 git config status.color.remoteBranch cyan
671 test_expect_success TTY 'status with color.ui' '
672 cat >expect <<\EOF &&
673 On branch <GREEN>master<RESET>
674 Your branch and '\''upstream'\'' have diverged,
675 and have 1 and 2 different commits each, respectively.
676 (use "git pull" to merge the remote branch into yours)
678 Changes to be committed:
679 (use "git reset HEAD <file>..." to unstage)
681 <GREEN>new file: dir2/added<RESET>
683 Changes not staged for commit:
684 (use "git add <file>..." to update what will be committed)
685 (use "git checkout -- <file>..." to discard changes in working directory)
687 <RED>modified: dir1/modified<RESET>
690 (use "git add <file>..." to include in what will be committed)
692 <BLUE>dir1/untracked<RESET>
693 <BLUE>dir2/modified<RESET>
694 <BLUE>dir2/untracked<RESET>
695 <BLUE>untracked<RESET>
698 test_config color.ui auto &&
699 test_terminal git status | test_decode_color >output &&
700 test_i18ncmp expect output
703 test_expect_success TTY 'status with color.status' '
704 test_config color.status auto &&
705 test_terminal git status | test_decode_color >output &&
706 test_i18ncmp expect output
710 <RED>M<RESET> dir1/modified
711 <GREEN>A<RESET> dir2/added
712 <BLUE>??<RESET> dir1/untracked
713 <BLUE>??<RESET> dir2/modified
714 <BLUE>??<RESET> dir2/untracked
715 <BLUE>??<RESET> untracked
718 test_expect_success TTY 'status -s with color.ui' '
720 git config color.ui auto &&
721 test_terminal git status -s | test_decode_color >output &&
722 test_cmp expect output
726 test_expect_success TTY 'status -s with color.status' '
728 git config --unset color.ui &&
729 git config color.status auto &&
730 test_terminal git status -s | test_decode_color >output &&
731 test_cmp expect output
736 ## <YELLOW>master<RESET>...<CYAN>upstream<RESET> [ahead <YELLOW>1<RESET>, behind <CYAN>2<RESET>]
737 <RED>M<RESET> dir1/modified
738 <GREEN>A<RESET> dir2/added
739 <BLUE>??<RESET> dir1/untracked
740 <BLUE>??<RESET> dir2/modified
741 <BLUE>??<RESET> dir2/untracked
742 <BLUE>??<RESET> untracked
745 test_expect_success TTY 'status -s -b with color.status' '
747 test_terminal git status -s -b | test_decode_color >output &&
748 test_i18ncmp expect output
761 test_expect_success TTY 'status --porcelain ignores color.ui' '
763 git config --unset color.status &&
764 git config color.ui auto &&
765 test_terminal git status --porcelain | test_decode_color >output &&
766 test_cmp expect output
770 test_expect_success TTY 'status --porcelain ignores color.status' '
772 git config --unset color.ui &&
773 git config color.status auto &&
774 test_terminal git status --porcelain | test_decode_color >output &&
775 test_cmp expect output
779 # recover unconditionally from color tests
780 git config --unset color.status
781 git config --unset color.ui
783 test_expect_success 'status --porcelain respects -b' '
785 git status --porcelain -b >output &&
787 echo "## master...upstream [ahead 1, behind 2]" &&
791 test_cmp expect output
797 test_expect_success 'status without relative paths' '
798 cat >expect <<\EOF &&
800 Your branch and '\''upstream'\'' have diverged,
801 and have 1 and 2 different commits each, respectively.
802 (use "git pull" to merge the remote branch into yours)
804 Changes to be committed:
805 (use "git reset HEAD <file>..." to unstage)
809 Changes not staged for commit:
810 (use "git add <file>..." to update what will be committed)
811 (use "git checkout -- <file>..." to discard changes in working directory)
813 modified: dir1/modified
816 (use "git add <file>..." to include in what will be committed)
824 test_config status.relativePaths false &&
825 (cd dir1 && git status) >output &&
826 test_i18ncmp expect output
839 test_expect_success 'status -s without relative paths' '
841 test_config status.relativePaths false &&
842 (cd dir1 && git status -s) >output &&
843 test_cmp expect output
847 test_expect_success 'dry-run of partial commit excluding new file in index' '
850 Your branch and '\''upstream'\'' have diverged,
851 and have 1 and 2 different commits each, respectively.
852 (use "git pull" to merge the remote branch into yours)
854 Changes to be committed:
855 (use "git reset HEAD <file>..." to unstage)
857 modified: dir1/modified
860 (use "git add <file>..." to include in what will be committed)
867 git commit --dry-run dir1/modified >output &&
868 test_i18ncmp expect output
872 :100644 100644 $EMPTY_BLOB 0000000000000000000000000000000000000000 M dir1/modified
874 test_expect_success 'status refreshes the index' '
877 git diff-files >output &&
878 test_cmp expect output
881 test_expect_success 'setup status submodule summary' '
882 test_create_repo sm && (
886 git commit -m "Add foo"
891 test_expect_success 'status submodule summary is disabled by default' '
894 Your branch and '\''upstream'\'' have diverged,
895 and have 1 and 2 different commits each, respectively.
896 (use "git pull" to merge the remote branch into yours)
898 Changes to be committed:
899 (use "git reset HEAD <file>..." to unstage)
904 Changes not staged for commit:
905 (use "git add <file>..." to update what will be committed)
906 (use "git checkout -- <file>..." to discard changes in working directory)
908 modified: dir1/modified
911 (use "git add <file>..." to include in what will be committed)
919 git status >output &&
920 test_i18ncmp expect output
923 # we expect the same as the previous test
924 test_expect_success 'status --untracked-files=all does not show submodule' '
925 git status --untracked-files=all >output &&
926 test_i18ncmp expect output
938 test_expect_success 'status -s submodule summary is disabled by default' '
939 git status -s >output &&
940 test_cmp expect output
943 # we expect the same as the previous test
944 test_expect_success 'status -s --untracked-files=all does not show submodule' '
945 git status -s --untracked-files=all >output &&
946 test_cmp expect output
949 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
951 test_expect_success 'status submodule summary' '
954 Your branch and '\''upstream'\'' have diverged,
955 and have 1 and 2 different commits each, respectively.
956 (use "git pull" to merge the remote branch into yours)
958 Changes to be committed:
959 (use "git reset HEAD <file>..." to unstage)
964 Changes not staged for commit:
965 (use "git add <file>..." to update what will be committed)
966 (use "git checkout -- <file>..." to discard changes in working directory)
968 modified: dir1/modified
970 Submodule changes to be committed:
972 * sm 0000000...$head (1):
976 (use "git add <file>..." to include in what will be committed)
984 git config status.submodulesummary 10 &&
985 git status >output &&
986 test_i18ncmp expect output
989 test_expect_success 'status submodule summary with status.displayCommentPrefix=false' '
990 strip_comments expect &&
991 git -c status.displayCommentPrefix=false status >output &&
992 test_i18ncmp expect output
995 test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' '
996 commit_template_commented
1008 test_expect_success 'status -s submodule summary' '
1009 git status -s >output &&
1010 test_cmp expect output
1013 test_expect_success 'status submodule summary (clean submodule): commit' '
1014 cat >expect <<EOF &&
1016 Your branch and '\''upstream'\'' have diverged,
1017 and have 2 and 2 different commits each, respectively.
1018 (use "git pull" to merge the remote branch into yours)
1020 Changes not staged for commit:
1021 (use "git add <file>..." to update what will be committed)
1022 (use "git checkout -- <file>..." to discard changes in working directory)
1024 modified: dir1/modified
1027 (use "git add <file>..." to include in what will be committed)
1034 no changes added to commit (use "git add" and/or "git commit -a")
1036 git commit -m "commit submodule" &&
1037 git config status.submodulesummary 10 &&
1038 test_must_fail git commit --dry-run >output &&
1039 test_i18ncmp expect output &&
1040 git status >output &&
1041 test_i18ncmp expect output
1051 test_expect_success 'status -s submodule summary (clean submodule)' '
1052 git status -s >output &&
1053 test_cmp expect output
1056 test_expect_success 'status -z implies porcelain' '
1057 git status --porcelain |
1058 perl -pe "s/\012/\000/g" >expect &&
1059 git status -z >output &&
1060 test_cmp expect output
1063 test_expect_success 'commit --dry-run submodule summary (--amend)' '
1064 cat >expect <<EOF &&
1066 Your branch and '\''upstream'\'' have diverged,
1067 and have 2 and 2 different commits each, respectively.
1068 (use "git pull" to merge the remote branch into yours)
1070 Changes to be committed:
1071 (use "git reset HEAD^1 <file>..." to unstage)
1073 new file: dir2/added
1076 Changes not staged for commit:
1077 (use "git add <file>..." to update what will be committed)
1078 (use "git checkout -- <file>..." to discard changes in working directory)
1080 modified: dir1/modified
1082 Submodule changes to be committed:
1084 * sm 0000000...$head (1):
1088 (use "git add <file>..." to include in what will be committed)
1096 git config status.submodulesummary 10 &&
1097 git commit --dry-run --amend >output &&
1098 test_i18ncmp expect output
1101 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
1102 test_when_finished "chmod 775 .git" &&
1105 # make dir1/tracked stat-dirty
1106 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
1107 git status -s >output &&
1108 ! grep dir1/tracked output &&
1109 # make sure "status" succeeded without writing index out
1110 git diff-files | grep dir1/tracked
1114 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
1115 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
1118 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1119 cat > expect << EOF &&
1121 Your branch and '\''upstream'\'' have diverged,
1122 and have 2 and 2 different commits each, respectively.
1123 (use "git pull" to merge the remote branch into yours)
1125 Changes to be committed:
1126 (use "git reset HEAD <file>..." to unstage)
1130 Changes not staged for commit:
1131 (use "git add <file>..." to update what will be committed)
1132 (use "git checkout -- <file>..." to discard changes in working directory)
1134 modified: dir1/modified
1136 Submodule changes to be committed:
1138 * sm $head...$new_head (1):
1142 (use "git add <file>..." to include in what will be committed)
1151 echo modified sm/untracked &&
1152 git status --ignore-submodules=untracked >output &&
1153 test_i18ncmp expect output
1156 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1157 test_config diff.ignoreSubmodules dirty &&
1158 git status >output &&
1159 test_i18ncmp expect output &&
1160 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1161 git config --add -f .gitmodules submodule.subname.path sm &&
1162 git status >output &&
1163 test_i18ncmp expect output &&
1164 git config -f .gitmodules --remove-section submodule.subname
1167 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1168 git config --add -f .gitmodules submodule.subname.ignore none &&
1169 git config --add -f .gitmodules submodule.subname.path sm &&
1170 git config --add submodule.subname.ignore untracked &&
1171 git config --add submodule.subname.path sm &&
1172 git status >output &&
1173 test_i18ncmp expect output &&
1174 git config --remove-section submodule.subname &&
1175 git config --remove-section -f .gitmodules submodule.subname
1178 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1179 git status --ignore-submodules=dirty >output &&
1180 test_i18ncmp expect output
1183 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1184 test_config diff.ignoreSubmodules dirty &&
1185 git status >output &&
1187 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1188 git config --add -f .gitmodules submodule.subname.path sm &&
1189 git status >output &&
1190 test_i18ncmp expect output &&
1191 git config -f .gitmodules --remove-section submodule.subname
1194 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1195 git config --add -f .gitmodules submodule.subname.ignore none &&
1196 git config --add -f .gitmodules submodule.subname.path sm &&
1197 git config --add submodule.subname.ignore dirty &&
1198 git config --add submodule.subname.path sm &&
1199 git status >output &&
1200 test_i18ncmp expect output &&
1201 git config --remove-section submodule.subname &&
1202 git config -f .gitmodules --remove-section submodule.subname
1205 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1206 echo modified >sm/foo &&
1207 git status --ignore-submodules=dirty >output &&
1208 test_i18ncmp expect output
1211 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
1212 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1213 git config --add -f .gitmodules submodule.subname.path sm &&
1214 git status >output &&
1215 test_i18ncmp expect output &&
1216 git config -f .gitmodules --remove-section submodule.subname
1219 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
1220 git config --add -f .gitmodules submodule.subname.ignore none &&
1221 git config --add -f .gitmodules submodule.subname.path sm &&
1222 git config --add submodule.subname.ignore dirty &&
1223 git config --add submodule.subname.path sm &&
1224 git status >output &&
1225 test_i18ncmp expect output &&
1226 git config --remove-section submodule.subname &&
1227 git config -f .gitmodules --remove-section submodule.subname
1230 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1231 cat > expect << EOF &&
1233 Your branch and '\''upstream'\'' have diverged,
1234 and have 2 and 2 different commits each, respectively.
1235 (use "git pull" to merge the remote branch into yours)
1237 Changes to be committed:
1238 (use "git reset HEAD <file>..." to unstage)
1242 Changes not staged for commit:
1243 (use "git add <file>..." to update what will be committed)
1244 (use "git checkout -- <file>..." to discard changes in working directory)
1245 (commit or discard the untracked or modified content in submodules)
1247 modified: dir1/modified
1248 modified: sm (modified content)
1250 Submodule changes to be committed:
1252 * sm $head...$new_head (1):
1256 (use "git add <file>..." to include in what will be committed)
1265 git status --ignore-submodules=untracked > output &&
1266 test_i18ncmp expect output
1269 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
1270 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1271 git config --add -f .gitmodules submodule.subname.path sm &&
1272 git status >output &&
1273 test_i18ncmp expect output &&
1274 git config -f .gitmodules --remove-section submodule.subname
1277 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1278 git config --add -f .gitmodules submodule.subname.ignore none &&
1279 git config --add -f .gitmodules submodule.subname.path sm &&
1280 git config --add submodule.subname.ignore untracked &&
1281 git config --add submodule.subname.path sm &&
1282 git status >output &&
1283 test_i18ncmp expect output &&
1284 git config --remove-section submodule.subname &&
1285 git config -f .gitmodules --remove-section submodule.subname
1288 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1290 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1291 cat > expect << EOF &&
1293 Your branch and '\''upstream'\'' have diverged,
1294 and have 2 and 2 different commits each, respectively.
1295 (use "git pull" to merge the remote branch into yours)
1297 Changes to be committed:
1298 (use "git reset HEAD <file>..." to unstage)
1302 Changes not staged for commit:
1303 (use "git add <file>..." to update what will be committed)
1304 (use "git checkout -- <file>..." to discard changes in working directory)
1306 modified: dir1/modified
1307 modified: sm (new commits)
1309 Submodule changes to be committed:
1311 * sm $head...$new_head (1):
1314 Submodules changed but not updated:
1316 * sm $new_head...$head2 (1):
1320 (use "git add <file>..." to include in what will be committed)
1329 git status --ignore-submodules=untracked > output &&
1330 test_i18ncmp expect output
1333 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1334 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1335 git config --add -f .gitmodules submodule.subname.path sm &&
1336 git status >output &&
1337 test_i18ncmp expect output &&
1338 git config -f .gitmodules --remove-section submodule.subname
1341 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1342 git config --add -f .gitmodules submodule.subname.ignore none &&
1343 git config --add -f .gitmodules submodule.subname.path sm &&
1344 git config --add submodule.subname.ignore untracked &&
1345 git config --add submodule.subname.path sm &&
1346 git status >output &&
1347 test_i18ncmp expect output &&
1348 git config --remove-section submodule.subname &&
1349 git config -f .gitmodules --remove-section submodule.subname
1352 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1353 git status --ignore-submodules=dirty > output &&
1354 test_i18ncmp expect output
1356 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1357 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1358 git config --add -f .gitmodules submodule.subname.path sm &&
1359 git status >output &&
1360 test_i18ncmp expect output &&
1361 git config -f .gitmodules --remove-section submodule.subname
1364 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1365 git config --add -f .gitmodules submodule.subname.ignore none &&
1366 git config --add -f .gitmodules submodule.subname.path sm &&
1367 git config --add submodule.subname.ignore dirty &&
1368 git config --add submodule.subname.path sm &&
1369 git status >output &&
1370 test_i18ncmp expect output &&
1371 git config --remove-section submodule.subname &&
1372 git config -f .gitmodules --remove-section submodule.subname
1377 ; Your branch and 'upstream' have diverged,
1378 ; and have 2 and 2 different commits each, respectively.
1379 ; (use "git pull" to merge the remote branch into yours)
1381 ; Changes to be committed:
1382 ; (use "git reset HEAD <file>..." to unstage)
1386 ; Changes not staged for commit:
1387 ; (use "git add <file>..." to update what will be committed)
1388 ; (use "git checkout -- <file>..." to discard changes in working directory)
1390 ; modified: dir1/modified
1391 ; modified: sm (new commits)
1393 ; Submodule changes to be committed:
1395 ; * sm $head...$new_head (1):
1398 ; Submodules changed but not updated:
1400 ; * sm $new_head...$head2 (1):
1404 ; (use "git add <file>..." to include in what will be committed)
1414 test_expect_success "status (core.commentchar with submodule summary)" '
1415 test_config core.commentchar ";" &&
1416 git -c status.displayCommentPrefix=true status >output &&
1417 test_i18ncmp expect output
1420 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1421 test_config core.commentchar ";;" &&
1422 test_must_fail git -c status.displayCommentPrefix=true status
1425 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1426 cat > expect << EOF &&
1428 Your branch and '\''upstream'\'' have diverged,
1429 and have 2 and 2 different commits each, respectively.
1430 (use "git pull" to merge the remote branch into yours)
1432 Changes not staged for commit:
1433 (use "git add <file>..." to update what will be committed)
1434 (use "git checkout -- <file>..." to discard changes in working directory)
1436 modified: dir1/modified
1439 (use "git add <file>..." to include in what will be committed)
1447 no changes added to commit (use "git add" and/or "git commit -a")
1449 git status --ignore-submodules=all > output &&
1450 test_i18ncmp expect output
1453 test_expect_success '.gitmodules ignore=all suppresses unstaged submodule summary' '
1454 cat > expect << EOF &&
1456 Your branch and '\''upstream'\'' have diverged,
1457 and have 2 and 2 different commits each, respectively.
1458 (use "git pull" to merge the remote branch into yours)
1460 Changes to be committed:
1461 (use "git reset HEAD <file>..." to unstage)
1465 Changes not staged for commit:
1466 (use "git add <file>..." to update what will be committed)
1467 (use "git checkout -- <file>..." to discard changes in working directory)
1469 modified: dir1/modified
1472 (use "git add <file>..." to include in what will be committed)
1481 git config --add -f .gitmodules submodule.subname.ignore all &&
1482 git config --add -f .gitmodules submodule.subname.path sm &&
1483 git status > output &&
1484 test_i18ncmp expect output &&
1485 git config -f .gitmodules --remove-section submodule.subname
1488 test_expect_success '.git/config ignore=all suppresses unstaged submodule summary' '
1489 git config --add -f .gitmodules submodule.subname.ignore none &&
1490 git config --add -f .gitmodules submodule.subname.path sm &&
1491 git config --add submodule.subname.ignore all &&
1492 git config --add submodule.subname.path sm &&
1493 git status > output &&
1494 test_i18ncmp expect output &&
1495 git config --remove-section submodule.subname &&
1496 git config -f .gitmodules --remove-section submodule.subname
1499 test_expect_success 'setup of test environment' '
1500 git config status.showUntrackedFiles no &&
1501 git status -s >expected_short &&
1502 git status --no-short >expected_noshort
1505 test_expect_success '"status.short=true" same as "-s"' '
1506 git -c status.short=true status >actual &&
1507 test_cmp expected_short actual
1510 test_expect_success '"status.short=true" weaker than "--no-short"' '
1511 git -c status.short=true status --no-short >actual &&
1512 test_cmp expected_noshort actual
1515 test_expect_success '"status.short=false" same as "--no-short"' '
1516 git -c status.short=false status >actual &&
1517 test_cmp expected_noshort actual
1520 test_expect_success '"status.short=false" weaker than "-s"' '
1521 git -c status.short=false status -s >actual &&
1522 test_cmp expected_short actual
1525 test_expect_success '"status.branch=true" same as "-b"' '
1526 git status -sb >expected_branch &&
1527 git -c status.branch=true status -s >actual &&
1528 test_cmp expected_branch actual
1531 test_expect_success '"status.branch=true" different from "--no-branch"' '
1532 git status -s --no-branch >expected_nobranch &&
1533 git -c status.branch=true status -s >actual &&
1534 test_must_fail test_cmp expected_nobranch actual
1537 test_expect_success '"status.branch=true" weaker than "--no-branch"' '
1538 git -c status.branch=true status -s --no-branch >actual &&
1539 test_cmp expected_nobranch actual
1542 test_expect_success '"status.branch=true" weaker than "--porcelain"' '
1543 git -c status.branch=true status --porcelain >actual &&
1544 test_cmp expected_nobranch actual
1547 test_expect_success '"status.branch=false" same as "--no-branch"' '
1548 git -c status.branch=false status -s >actual &&
1549 test_cmp expected_nobranch actual
1552 test_expect_success '"status.branch=false" weaker than "-b"' '
1553 git -c status.branch=false status -sb >actual &&
1554 test_cmp expected_branch actual
1557 test_expect_success 'Restore default test environment' '
1558 git config --unset status.showUntrackedFiles
1561 test_expect_success 'git commit will commit a staged but ignored submodule' '
1562 git config --add -f .gitmodules submodule.subname.ignore all &&
1563 git config --add -f .gitmodules submodule.subname.path sm &&
1564 git config --add submodule.subname.ignore all &&
1565 git status -s --ignore-submodules=dirty >output &&
1566 test_i18ngrep "^M. sm" output &&
1567 GIT_EDITOR="echo hello >>\"\$1\"" &&
1568 export GIT_EDITOR &&
1570 git status -s --ignore-submodules=dirty >output &&
1571 test_i18ngrep ! "^M. sm" output
1574 test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '
1577 cat >expect << EOF &&
1579 Your branch and '\''upstream'\'' have diverged,
1580 and have 2 and 2 different commits each, respectively.
1581 (use "git pull" to merge the remote branch into yours)
1583 Changes to be committed:
1584 (use "git reset HEAD <file>..." to unstage)
1588 Changes not staged for commit:
1589 (use "git add <file>..." to update what will be committed)
1590 (use "git checkout -- <file>..." to discard changes in working directory)
1592 modified: dir1/modified
1594 Untracked files not listed (use -u option to show untracked files)
1596 git commit -uno --dry-run >output &&
1597 test_i18ncmp expect output &&
1598 git status -s --ignore-submodules=dirty >output &&
1599 test_i18ngrep "^M. sm" output
1602 test_expect_success 'git commit -m will commit a staged but ignored submodule' '
1603 git commit -uno -m message &&
1604 git status -s --ignore-submodules=dirty >output &&
1605 test_i18ngrep ! "^M. sm" output &&
1606 git config --remove-section submodule.subname &&
1607 git config -f .gitmodules --remove-section submodule.subname
1610 test_expect_success 'show stash info with "--show-stash"' '
1616 git status >expected_default &&
1617 git status --show-stash >expected_with_stash &&
1618 test_i18ngrep "^Your stash currently has 1 entry$" expected_with_stash
1621 test_expect_success 'no stash info with "--show-stash --no-show-stash"' '
1622 git status --show-stash --no-show-stash >expected_without_stash &&
1623 test_cmp expected_default expected_without_stash
1626 test_expect_success '"status.showStash=false" weaker than "--show-stash"' '
1627 git -c status.showStash=false status --show-stash >actual &&
1628 test_cmp expected_with_stash actual
1631 test_expect_success '"status.showStash=true" weaker than "--no-show-stash"' '
1632 git -c status.showStash=true status --no-show-stash >actual &&
1633 test_cmp expected_without_stash actual
1636 test_expect_success 'no additionnal info if no stash entries' '
1638 git -c status.showStash=true status >actual &&
1639 test_cmp expected_without_stash actual
1642 test_expect_success '"No commits yet" should be noted in status output' '
1643 git checkout --orphan empty-branch-1 &&
1644 git status >output &&
1645 test_i18ngrep "No commits yet" output
1648 test_expect_success '"No commits yet" should not be noted in status output' '
1649 git checkout --orphan empty-branch-2 &&
1650 test_commit test-commit-1 &&
1651 git status >output &&
1652 test_i18ngrep ! "No commits yet" output
1655 test_expect_success '"Initial commit" should be noted in commit template' '
1656 git checkout --orphan empty-branch-3 &&
1657 touch to_be_committed_1 &&
1658 git add to_be_committed_1 &&
1659 git commit --dry-run >output &&
1660 test_i18ngrep "Initial commit" output
1663 test_expect_success '"Initial commit" should not be noted in commit template' '
1664 git checkout --orphan empty-branch-4 &&
1665 test_commit test-commit-2 &&
1666 touch to_be_committed_2 &&
1667 git add to_be_committed_2 &&
1668 git commit --dry-run >output &&
1669 test_i18ngrep ! "Initial commit" output
1672 test_expect_success '--no-optional-locks prevents index update' '
1673 test-tool chmtime =1234567890 .git/index &&
1674 git --no-optional-locks status &&
1675 test-tool chmtime --get .git/index >out &&
1676 grep ^1234567890 out &&
1678 test-tool chmtime --get .git/index >out &&
1679 ! grep ^1234567890 out