3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description
='git status'
9 *MINGW
*) GIT_TEST_CMP
="diff -uw";;
14 test_expect_success
'setup' '
28 git commit -m initial &&
32 echo 1 >dir1/modified &&
33 echo 2 >dir2/modified &&
38 test_expect_success
'status (1)' '
40 grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
46 # Changes to be committed:
47 # (use "git reset HEAD <file>..." to unstage)
49 # new file: dir2/added
51 # Changed but not updated:
52 # (use "git add <file>..." to update what will be committed)
53 # (use "git checkout -- <file>..." to discard changes in working directory)
55 # modified: dir1/modified
58 # (use "git add <file>..." to include in what will be committed)
68 test_expect_success
'status (2)' '
71 test_cmp expect output
77 # Changes to be committed:
78 # new file: dir2/added
80 # Changed but not updated:
81 # modified: dir1/modified
92 git config advice.statusHints false
94 test_expect_success
'status (advice.statusHints false)' '
97 test_cmp expect output
101 git config
--unset advice.statusHints
114 test_expect_success
'status -s' '
116 git status -s >output &&
117 test_cmp expect output
133 test_expect_success
'status -s -b' '
135 git status -s -b >output &&
136 test_cmp expect output
142 # Changes to be committed:
143 # (use "git reset HEAD <file>..." to unstage)
145 # new file: dir2/added
147 # Changed but not updated:
148 # (use "git add <file>..." to update what will be committed)
149 # (use "git checkout -- <file>..." to discard changes in working directory)
151 # modified: dir1/modified
153 # Untracked files not listed (use -u option to show untracked files)
155 test_expect_success
'status -uno' '
157 : >dir3/untracked1 &&
158 : >dir3/untracked2 &&
159 git status -uno >output &&
160 test_cmp expect output
163 test_expect_success
'status (status.showUntrackedFiles no)' '
164 git config status.showuntrackedfiles no
165 git status >output &&
166 test_cmp expect output
171 # Changes to be committed:
172 # new file: dir2/added
174 # Changed but not updated:
175 # modified: dir1/modified
177 # Untracked files not listed
179 git config advice.statusHints false
180 test_expect_success
'status -uno (advice.statusHints false)' '
181 git status -uno >output &&
182 test_cmp expect output
184 git config
--unset advice.statusHints
190 test_expect_success
'status -s -uno' '
191 git config --unset status.showuntrackedfiles
192 git status -s -uno >output &&
193 test_cmp expect output
196 test_expect_success
'status -s (status.showUntrackedFiles no)' '
197 git config status.showuntrackedfiles no
198 git status -s >output &&
199 test_cmp expect output
204 # Changes to be committed:
205 # (use "git reset HEAD <file>..." to unstage)
207 # new file: dir2/added
209 # Changed but not updated:
210 # (use "git add <file>..." to update what will be committed)
211 # (use "git checkout -- <file>..." to discard changes in working directory)
213 # modified: dir1/modified
216 # (use "git add <file>..." to include in what will be committed)
226 test_expect_success
'status -unormal' '
227 git status -unormal >output &&
228 test_cmp expect output
231 test_expect_success
'status (status.showUntrackedFiles normal)' '
232 git config status.showuntrackedfiles normal
233 git status >output &&
234 test_cmp expect output
248 test_expect_success
'status -s -unormal' '
249 git config --unset status.showuntrackedfiles
250 git status -s -unormal >output &&
251 test_cmp expect output
254 test_expect_success
'status -s (status.showUntrackedFiles normal)' '
255 git config status.showuntrackedfiles normal
256 git status -s >output &&
257 test_cmp expect output
262 # Changes to be committed:
263 # (use "git reset HEAD <file>..." to unstage)
265 # new file: dir2/added
267 # Changed but not updated:
268 # (use "git add <file>..." to update what will be committed)
269 # (use "git checkout -- <file>..." to discard changes in working directory)
271 # modified: dir1/modified
274 # (use "git add <file>..." to include in what will be committed)
285 test_expect_success
'status -uall' '
286 git status -uall >output &&
287 test_cmp expect output
289 test_expect_success
'status (status.showUntrackedFiles all)' '
290 git config status.showuntrackedfiles all
291 git status >output &&
293 git config --unset status.showuntrackedfiles &&
294 test_cmp expect output
307 test_expect_success
'status -s -uall' '
308 git config --unset status.showuntrackedfiles
309 git status -s -uall >output &&
310 test_cmp expect output
312 test_expect_success
'status -s (status.showUntrackedFiles all)' '
313 git config status.showuntrackedfiles all
314 git status -s >output &&
316 git config --unset status.showuntrackedfiles &&
317 test_cmp expect output
322 # Changes to be committed:
323 # (use "git reset HEAD <file>..." to unstage)
325 # new file: ../dir2/added
327 # Changed but not updated:
328 # (use "git add <file>..." to update what will be committed)
329 # (use "git checkout -- <file>..." to discard changes in working directory)
334 # (use "git add <file>..." to include in what will be committed)
344 test_expect_success
'status with relative paths' '
346 (cd dir1 && git status) >output &&
347 test_cmp expect output
361 test_expect_success
'status -s with relative paths' '
363 (cd dir1 && git status -s) >output &&
364 test_cmp expect output
379 test_expect_success
'status --porcelain ignores relative paths setting' '
381 (cd dir1 && git status --porcelain) >output &&
382 test_cmp expect output
386 test_expect_success
'setup unique colors' '
388 git config status.color.untracked blue
394 # Changes to be committed:
395 # (use "git reset HEAD <file>..." to unstage)
397 # <GREEN>new file: dir2/added<RESET>
399 # Changed but not updated:
400 # (use "git add <file>..." to update what will be committed)
401 # (use "git checkout -- <file>..." to discard changes in working directory)
403 # <RED>modified: dir1/modified<RESET>
406 # (use "git add <file>..." to include in what will be committed)
408 # <BLUE>dir1/untracked<RESET>
409 # <BLUE>dir2/modified<RESET>
410 # <BLUE>dir2/untracked<RESET>
411 # <BLUE>expect<RESET>
412 # <BLUE>output<RESET>
413 # <BLUE>untracked<RESET>
416 test_expect_success
'status with color.ui' '
418 git config color.ui always &&
419 git status | test_decode_color >output &&
420 test_cmp expect output
424 test_expect_success
'status with color.status' '
426 git config --unset color.ui &&
427 git config color.status always &&
428 git status | test_decode_color >output &&
429 test_cmp expect output
434 <RED
>M
<RESET
> dir
1/modified
435 <GREEN
>A
<RESET
> dir
2/added
436 <BLUE
>??
<RESET
> dir
1/untracked
437 <BLUE
>??
<RESET
> dir
2/modified
438 <BLUE
>??
<RESET
> dir
2/untracked
439 <BLUE
>??
<RESET
> expect
440 <BLUE
>??
<RESET
> output
441 <BLUE
>??
<RESET
> untracked
444 test_expect_success
'status -s with color.ui' '
446 git config --unset color.status &&
447 git config color.ui always &&
448 git status -s | test_decode_color >output &&
449 test_cmp expect output
453 test_expect_success
'status -s with color.status' '
455 git config --unset color.ui &&
456 git config color.status always &&
457 git status -s | test_decode_color >output &&
458 test_cmp expect output
463 ## <GREEN>master<RESET>
464 <RED
>M
<RESET
> dir
1/modified
465 <GREEN
>A
<RESET
> dir
2/added
466 <BLUE
>??
<RESET
> dir
1/untracked
467 <BLUE
>??
<RESET
> dir
2/modified
468 <BLUE
>??
<RESET
> dir
2/untracked
469 <BLUE
>??
<RESET
> expect
470 <BLUE
>??
<RESET
> output
471 <BLUE
>??
<RESET
> untracked
474 test_expect_success
'status -s -b with color.status' '
476 git status -s -b | test_decode_color >output &&
477 test_cmp expect output
492 test_expect_success
'status --porcelain ignores color.ui' '
494 git config --unset color.status &&
495 git config color.ui always &&
496 git status --porcelain | test_decode_color >output &&
497 test_cmp expect output
501 test_expect_success
'status --porcelain ignores color.status' '
503 git config --unset color.ui &&
504 git config color.status always &&
505 git status --porcelain | test_decode_color >output &&
506 test_cmp expect output
510 # recover unconditionally from color tests
511 git config
--unset color.status
512 git config
--unset color.ui
514 test_expect_success
'status --porcelain ignores -b' '
516 git status --porcelain -b >output &&
517 test_cmp expect output
523 # Changes to be committed:
524 # (use "git reset HEAD <file>..." to unstage)
526 # new file: dir2/added
528 # Changed but not updated:
529 # (use "git add <file>..." to update what will be committed)
530 # (use "git checkout -- <file>..." to discard changes in working directory)
532 # modified: dir1/modified
535 # (use "git add <file>..." to include in what will be committed)
546 test_expect_success
'status without relative paths' '
548 git config status.relativePaths false
549 (cd dir1 && git status) >output &&
550 test_cmp expect output
565 test_expect_success
'status -s without relative paths' '
567 (cd dir1 && git status -s) >output &&
568 test_cmp expect output
574 # Changes to be committed:
575 # (use "git reset HEAD <file>..." to unstage)
577 # modified: dir1/modified
580 # (use "git add <file>..." to include in what will be committed)
588 test_expect_success
'dry-run of partial commit excluding new file in index' '
589 git commit --dry-run dir1/modified >output &&
590 test_cmp expect output
594 :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
596 test_expect_success
'status refreshes the index' '
599 git diff-files >output &&
600 test_cmp expect output
603 test_expect_success
'setup status submodule summary' '
604 test_create_repo sm && (
608 git commit -m "Add foo"
615 # Changes to be committed:
616 # (use "git reset HEAD <file>..." to unstage)
618 # new file: dir2/added
621 # Changed but not updated:
622 # (use "git add <file>..." to update what will be committed)
623 # (use "git checkout -- <file>..." to discard changes in working directory)
625 # modified: dir1/modified
628 # (use "git add <file>..." to include in what will be committed)
637 test_expect_success
'status submodule summary is disabled by default' '
638 git status >output &&
639 test_cmp expect output
642 # we expect the same as the previous test
643 test_expect_success
'status --untracked-files=all does not show submodule' '
644 git status --untracked-files=all >output &&
645 test_cmp expect output
659 test_expect_success
'status -s submodule summary is disabled by default' '
660 git status -s >output &&
661 test_cmp expect output
664 # we expect the same as the previous test
665 test_expect_success
'status -s --untracked-files=all does not show submodule' '
666 git status -s --untracked-files=all >output &&
667 test_cmp expect output
670 head=$
(cd sm
&& git rev-parse
--short=7 --verify HEAD
)
674 # Changes to be committed:
675 # (use "git reset HEAD <file>..." to unstage)
677 # new file: dir2/added
680 # Changed but not updated:
681 # (use "git add <file>..." to update what will be committed)
682 # (use "git checkout -- <file>..." to discard changes in working directory)
684 # modified: dir1/modified
686 # Submodule changes to be committed:
688 # * sm 0000000...$head (1):
692 # (use "git add <file>..." to include in what will be committed)
701 test_expect_success
'status submodule summary' '
702 git config status.submodulesummary 10 &&
703 git status >output &&
704 test_cmp expect output
718 test_expect_success
'status -s submodule summary' '
719 git status -s >output &&
720 test_cmp expect output
725 # Changed but not updated:
726 # (use "git add <file>..." to update what will be committed)
727 # (use "git checkout -- <file>..." to discard changes in working directory)
729 # modified: dir1/modified
732 # (use "git add <file>..." to include in what will be committed)
740 no changes added to commit (use "git add" and/or "git commit -a")
742 test_expect_success
'status submodule summary (clean submodule)' '
743 git commit -m "commit submodule" &&
744 git config status.submodulesummary 10 &&
745 test_must_fail git commit --dry-run >output &&
746 test_cmp expect output &&
747 git status >output &&
748 test_cmp expect output
760 test_expect_success
'status -s submodule summary (clean submodule)' '
761 git status -s >output &&
762 test_cmp expect output
767 # Changes to be committed:
768 # (use "git reset HEAD^1 <file>..." to unstage)
770 # new file: dir2/added
773 # Changed but not updated:
774 # (use "git add <file>..." to update what will be committed)
775 # (use "git checkout -- <file>..." to discard changes in working directory)
777 # modified: dir1/modified
779 # Submodule changes to be committed:
781 # * sm 0000000...$head (1):
785 # (use "git add <file>..." to include in what will be committed)
794 test_expect_success
'commit --dry-run submodule summary (--amend)' '
795 git config status.submodulesummary 10 &&
796 git commit --dry-run --amend >output &&
797 test_cmp expect output
800 test_expect_success POSIXPERM
,SANITY
'status succeeds in a read-only repository' '
803 # make dir1/tracked stat-dirty
804 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
805 git status -s >output &&
806 ! grep dir1/tracked output &&
807 # make sure "status" succeeded without writing index out
808 git diff-files | grep dir1/tracked
815 (cd sm
&& echo > bar
&& git add bar
&& git commit
-q -m 'Add bar') && git add sm
816 new_head
=$
(cd sm
&& git rev-parse
--short=7 --verify HEAD
)
821 # Changes to be committed:
822 # (use "git reset HEAD <file>..." to unstage)
826 # Changed but not updated:
827 # (use "git add <file>..." to update what will be committed)
828 # (use "git checkout -- <file>..." to discard changes in working directory)
830 # modified: dir1/modified
832 # Submodule changes to be committed:
834 # * sm $head...$new_head (1):
838 # (use "git add <file>..." to include in what will be committed)
849 test_expect_success
'--ignore-submodules=untracked suppresses submodules with untracked content' '
850 echo modified > sm/untracked &&
851 git status --ignore-submodules=untracked > output &&
852 test_cmp expect output
855 test_expect_success
'.gitmodules ignore=untracked suppresses submodules with untracked content' '
856 git config diff.ignoreSubmodules dirty &&
857 git status >output &&
858 test_cmp expect output &&
859 git config --add -f .gitmodules submodule.subname.ignore untracked &&
860 git config --add -f .gitmodules submodule.subname.path sm &&
861 git status > output &&
862 test_cmp expect output &&
863 git config -f .gitmodules --remove-section submodule.subname &&
864 git config --unset diff.ignoreSubmodules
867 test_expect_success
'.git/config ignore=untracked suppresses submodules with untracked content' '
868 git config --add -f .gitmodules submodule.subname.ignore none &&
869 git config --add -f .gitmodules submodule.subname.path sm &&
870 git config --add submodule.subname.ignore untracked &&
871 git config --add submodule.subname.path sm &&
872 git status > output &&
873 test_cmp expect output &&
874 git config --remove-section submodule.subname &&
875 git config --remove-section -f .gitmodules submodule.subname
878 test_expect_success
'--ignore-submodules=dirty suppresses submodules with untracked content' '
879 git status --ignore-submodules=dirty > output &&
880 test_cmp expect output
883 test_expect_success
'.gitmodules ignore=dirty suppresses submodules with untracked content' '
884 git config diff.ignoreSubmodules dirty &&
885 git status >output &&
887 git config --add -f .gitmodules submodule.subname.ignore dirty &&
888 git config --add -f .gitmodules submodule.subname.path sm &&
889 git status > output &&
890 test_cmp expect output &&
891 git config -f .gitmodules --remove-section submodule.subname &&
892 git config --unset diff.ignoreSubmodules
895 test_expect_success
'.git/config ignore=dirty suppresses submodules with untracked content' '
896 git config --add -f .gitmodules submodule.subname.ignore none &&
897 git config --add -f .gitmodules submodule.subname.path sm &&
898 git config --add submodule.subname.ignore dirty &&
899 git config --add submodule.subname.path sm &&
900 git status > output &&
901 test_cmp expect output &&
902 git config --remove-section submodule.subname &&
903 git config -f .gitmodules --remove-section submodule.subname
906 test_expect_success
'--ignore-submodules=dirty suppresses submodules with modified content' '
907 echo modified > sm/foo &&
908 git status --ignore-submodules=dirty > output &&
909 test_cmp expect output
912 test_expect_success
'.gitmodules ignore=dirty suppresses submodules with modified content' '
913 git config --add -f .gitmodules submodule.subname.ignore dirty &&
914 git config --add -f .gitmodules submodule.subname.path sm &&
915 git status > output &&
916 test_cmp expect output &&
917 git config -f .gitmodules --remove-section submodule.subname
920 test_expect_success
'.git/config ignore=dirty suppresses submodules with modified content' '
921 git config --add -f .gitmodules submodule.subname.ignore none &&
922 git config --add -f .gitmodules submodule.subname.path sm &&
923 git config --add submodule.subname.ignore dirty &&
924 git config --add submodule.subname.path sm &&
925 git status > output &&
926 test_cmp expect output &&
927 git config --remove-section submodule.subname &&
928 git config -f .gitmodules --remove-section submodule.subname
933 # Changes to be committed:
934 # (use "git reset HEAD <file>..." to unstage)
938 # Changed but not updated:
939 # (use "git add <file>..." to update what will be committed)
940 # (use "git checkout -- <file>..." to discard changes in working directory)
941 # (commit or discard the untracked or modified content in submodules)
943 # modified: dir1/modified
944 # modified: sm (modified content)
946 # Submodule changes to be committed:
948 # * sm $head...$new_head (1):
952 # (use "git add <file>..." to include in what will be committed)
963 test_expect_success
"--ignore-submodules=untracked doesn't suppress submodules with modified content" '
964 git status --ignore-submodules=untracked > output &&
965 test_cmp expect output
968 test_expect_success
".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
969 git config --add -f .gitmodules submodule.subname.ignore untracked &&
970 git config --add -f .gitmodules submodule.subname.path sm &&
971 git status > output &&
972 test_cmp expect output &&
973 git config -f .gitmodules --remove-section submodule.subname
976 test_expect_success
".git/config ignore=untracked doesn't suppress submodules with modified content" '
977 git config --add -f .gitmodules submodule.subname.ignore none &&
978 git config --add -f .gitmodules submodule.subname.path sm &&
979 git config --add submodule.subname.ignore untracked &&
980 git config --add submodule.subname.path sm &&
981 git status > output &&
982 test_cmp expect output &&
983 git config --remove-section submodule.subname &&
984 git config -f .gitmodules --remove-section submodule.subname
987 head2
=$
(cd sm
&& git commit
-q -m "2nd commit" foo
&& git rev-parse
--short=7 --verify HEAD
)
991 # Changes to be committed:
992 # (use "git reset HEAD <file>..." to unstage)
996 # Changed but not updated:
997 # (use "git add <file>..." to update what will be committed)
998 # (use "git checkout -- <file>..." to discard changes in working directory)
1000 # modified: dir1/modified
1001 # modified: sm (new commits)
1003 # Submodule changes to be committed:
1005 # * sm $head...$new_head (1):
1008 # Submodules changed but not updated:
1010 # * sm $new_head...$head2 (1):
1014 # (use "git add <file>..." to include in what will be committed)
1025 test_expect_success
"--ignore-submodules=untracked doesn't suppress submodule summary" '
1026 git status --ignore-submodules=untracked > output &&
1027 test_cmp expect output
1030 test_expect_success
".gitmodules ignore=untracked doesn't suppress submodule summary" '
1031 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1032 git config --add -f .gitmodules submodule.subname.path sm &&
1033 git status > output &&
1034 test_cmp expect output &&
1035 git config -f .gitmodules --remove-section submodule.subname
1038 test_expect_success
".git/config ignore=untracked doesn't suppress submodule summary" '
1039 git config --add -f .gitmodules submodule.subname.ignore none &&
1040 git config --add -f .gitmodules submodule.subname.path sm &&
1041 git config --add submodule.subname.ignore untracked &&
1042 git config --add submodule.subname.path sm &&
1043 git status > output &&
1044 test_cmp expect output &&
1045 git config --remove-section submodule.subname &&
1046 git config -f .gitmodules --remove-section submodule.subname
1049 test_expect_success
"--ignore-submodules=dirty doesn't suppress submodule summary" '
1050 git status --ignore-submodules=dirty > output &&
1051 test_cmp expect output
1053 test_expect_success
".gitmodules ignore=dirty doesn't suppress submodule summary" '
1054 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1055 git config --add -f .gitmodules submodule.subname.path sm &&
1056 git status > output &&
1057 test_cmp expect output &&
1058 git config -f .gitmodules --remove-section submodule.subname
1061 test_expect_success
".git/config ignore=dirty doesn't suppress submodule summary" '
1062 git config --add -f .gitmodules submodule.subname.ignore none &&
1063 git config --add -f .gitmodules submodule.subname.path sm &&
1064 git config --add submodule.subname.ignore dirty &&
1065 git config --add submodule.subname.path sm &&
1066 git status > output &&
1067 test_cmp expect output &&
1068 git config --remove-section submodule.subname &&
1069 git config -f .gitmodules --remove-section submodule.subname
1074 # Changed but not updated:
1075 # (use "git add <file>..." to update what will be committed)
1076 # (use "git checkout -- <file>..." to discard changes in working directory)
1078 # modified: dir1/modified
1081 # (use "git add <file>..." to include in what will be committed)
1090 no changes added to commit (use "git add" and/or "git commit -a")
1093 test_expect_success
"--ignore-submodules=all suppresses submodule summary" '
1094 git status --ignore-submodules=all > output &&
1095 test_cmp expect output
1098 test_expect_failure
'.gitmodules ignore=all suppresses submodule summary' '
1099 git config --add -f .gitmodules submodule.subname.ignore all &&
1100 git config --add -f .gitmodules submodule.subname.path sm &&
1101 git status > output &&
1102 test_cmp expect output &&
1103 git config -f .gitmodules --remove-section submodule.subname
1106 test_expect_failure
'.git/config ignore=all suppresses submodule summary' '
1107 git config --add -f .gitmodules submodule.subname.ignore none &&
1108 git config --add -f .gitmodules submodule.subname.path sm &&
1109 git config --add submodule.subname.ignore all &&
1110 git config --add submodule.subname.path sm &&
1111 git status > output &&
1112 test_cmp expect output &&
1113 git config --remove-section submodule.subname &&
1114 git config -f .gitmodules --remove-section submodule.subname