1#!/bin/sh
2#
3# Copyright (c) 2007 Johannes E. Schindelin
4#
5
6test_description='git status'
7
8. ./test-lib.sh
9
10test_expect_success 'setup' '
11 : >tracked &&
12 : >modified &&
13 mkdir dir1 &&
14 : >dir1/tracked &&
15 : >dir1/modified &&
16 mkdir dir2 &&
17 : >dir1/tracked &&
18 : >dir1/modified &&
19 git add . &&
20
21 git status >output &&
22
23 test_tick &&
24 git commit -m initial &&
25 : >untracked &&
26 : >dir1/untracked &&
27 : >dir2/untracked &&
28 echo 1 >dir1/modified &&
29 echo 2 >dir2/modified &&
30 echo 3 >dir2/added &&
31 git add dir2/added
32'
33
34test_expect_success 'status (1)' '
35
36 grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
37
38'
39
40cat >expect <<\EOF
41# On branch master
42# Changes to be committed:
43# (use "git reset HEAD <file>..." to unstage)
44#
45# new file: dir2/added
46#
47# Changes not staged for commit:
48# (use "git add <file>..." to update what will be committed)
49# (use "git checkout -- <file>..." to discard changes in working directory)
50#
51# modified: dir1/modified
52#
53# Untracked files:
54# (use "git add <file>..." to include in what will be committed)
55#
56# dir1/untracked
57# dir2/modified
58# dir2/untracked
59# expect
60# output
61# untracked
62EOF
63
64test_expect_success 'status (2)' '
65
66 git status >output &&
67 test_cmp expect output
68
69'
70
71cat >expect <<\EOF
72# On branch master
73# Changes to be committed:
74# new file: dir2/added
75#
76# Changes not staged for commit:
77# modified: dir1/modified
78#
79# Untracked files:
80# dir1/untracked
81# dir2/modified
82# dir2/untracked
83# expect
84# output
85# untracked
86EOF
87
88git config advice.statusHints false
89
90test_expect_success 'status (advice.statusHints false)' '
91
92 git status >output &&
93 test_cmp expect output
94
95'
96
97git config --unset advice.statusHints
98
99cat >expect <<\EOF
100 M dir1/modified
101A dir2/added
102?? dir1/untracked
103?? dir2/modified
104?? dir2/untracked
105?? expect
106?? output
107?? untracked
108EOF
109
110test_expect_success 'status -s' '
111
112 git status -s >output &&
113 test_cmp expect output
114
115'
116
117cat >expect <<\EOF
118## master
119 M dir1/modified
120A dir2/added
121?? dir1/untracked
122?? dir2/modified
123?? dir2/untracked
124?? expect
125?? output
126?? untracked
127EOF
128
129test_expect_success 'status -s -b' '
130
131 git status -s -b >output &&
132 test_cmp expect output
133
134'
135
136cat >expect <<EOF
137# On branch master
138# Changes to be committed:
139# (use "git reset HEAD <file>..." to unstage)
140#
141# new file: dir2/added
142#
143# Changes not staged for commit:
144# (use "git add <file>..." to update what will be committed)
145# (use "git checkout -- <file>..." to discard changes in working directory)
146#
147# modified: dir1/modified
148#
149# Untracked files not listed (use -u option to show untracked files)
150EOF
151test_expect_success 'status -uno' '
152 mkdir dir3 &&
153 : >dir3/untracked1 &&
154 : >dir3/untracked2 &&
155 git status -uno >output &&
156 test_cmp expect output
157'
158
159test_expect_success 'status (status.showUntrackedFiles no)' '
160 git config status.showuntrackedfiles no
161 git status >output &&
162 test_cmp expect output
163'
164
165cat >expect <<EOF
166# On branch master
167# Changes to be committed:
168# new file: dir2/added
169#
170# Changes not staged for commit:
171# modified: dir1/modified
172#
173# Untracked files not listed
174EOF
175git config advice.statusHints false
176test_expect_success 'status -uno (advice.statusHints false)' '
177 git status -uno >output &&
178 test_cmp expect output
179'
180git config --unset advice.statusHints
181
182cat >expect << EOF
183 M dir1/modified
184A dir2/added
185EOF
186test_expect_success 'status -s -uno' '
187 git config --unset status.showuntrackedfiles
188 git status -s -uno >output &&
189 test_cmp expect output
190'
191
192test_expect_success 'status -s (status.showUntrackedFiles no)' '
193 git config status.showuntrackedfiles no
194 git status -s >output &&
195 test_cmp expect output
196'
197
198cat >expect <<EOF
199# On branch master
200# Changes to be committed:
201# (use "git reset HEAD <file>..." to unstage)
202#
203# new file: dir2/added
204#
205# Changes not staged for commit:
206# (use "git add <file>..." to update what will be committed)
207# (use "git checkout -- <file>..." to discard changes in working directory)
208#
209# modified: dir1/modified
210#
211# Untracked files:
212# (use "git add <file>..." to include in what will be committed)
213#
214# dir1/untracked
215# dir2/modified
216# dir2/untracked
217# dir3/
218# expect
219# output
220# untracked
221EOF
222test_expect_success 'status -unormal' '
223 git status -unormal >output &&
224 test_cmp expect output
225'
226
227test_expect_success 'status (status.showUntrackedFiles normal)' '
228 git config status.showuntrackedfiles normal
229 git status >output &&
230 test_cmp expect output
231'
232
233cat >expect <<EOF
234 M dir1/modified
235A dir2/added
236?? dir1/untracked
237?? dir2/modified
238?? dir2/untracked
239?? dir3/
240?? expect
241?? output
242?? untracked
243EOF
244test_expect_success 'status -s -unormal' '
245 git config --unset status.showuntrackedfiles
246 git status -s -unormal >output &&
247 test_cmp expect output
248'
249
250test_expect_success 'status -s (status.showUntrackedFiles normal)' '
251 git config status.showuntrackedfiles normal
252 git status -s >output &&
253 test_cmp expect output
254'
255
256cat >expect <<EOF
257# On branch master
258# Changes to be committed:
259# (use "git reset HEAD <file>..." to unstage)
260#
261# new file: dir2/added
262#
263# Changes not staged for commit:
264# (use "git add <file>..." to update what will be committed)
265# (use "git checkout -- <file>..." to discard changes in working directory)
266#
267# modified: dir1/modified
268#
269# Untracked files:
270# (use "git add <file>..." to include in what will be committed)
271#
272# dir1/untracked
273# dir2/modified
274# dir2/untracked
275# dir3/untracked1
276# dir3/untracked2
277# expect
278# output
279# untracked
280EOF
281test_expect_success 'status -uall' '
282 git status -uall >output &&
283 test_cmp expect output
284'
285test_expect_success 'status (status.showUntrackedFiles all)' '
286 git config status.showuntrackedfiles all
287 git status >output &&
288 rm -rf dir3 &&
289 git config --unset status.showuntrackedfiles &&
290 test_cmp expect output
291'
292
293cat >expect <<EOF
294 M dir1/modified
295A dir2/added
296?? dir1/untracked
297?? dir2/modified
298?? dir2/untracked
299?? expect
300?? output
301?? untracked
302EOF
303test_expect_success 'status -s -uall' '
304 git config --unset status.showuntrackedfiles
305 git status -s -uall >output &&
306 test_cmp expect output
307'
308test_expect_success 'status -s (status.showUntrackedFiles all)' '
309 git config status.showuntrackedfiles all
310 git status -s >output &&
311 rm -rf dir3 &&
312 git config --unset status.showuntrackedfiles &&
313 test_cmp expect output
314'
315
316cat >expect <<\EOF
317# On branch master
318# Changes to be committed:
319# (use "git reset HEAD <file>..." to unstage)
320#
321# new file: ../dir2/added
322#
323# Changes not staged for commit:
324# (use "git add <file>..." to update what will be committed)
325# (use "git checkout -- <file>..." to discard changes in working directory)
326#
327# modified: modified
328#
329# Untracked files:
330# (use "git add <file>..." to include in what will be committed)
331#
332# untracked
333# ../dir2/modified
334# ../dir2/untracked
335# ../expect
336# ../output
337# ../untracked
338EOF
339
340test_expect_success 'status with relative paths' '
341
342 (cd dir1 && git status) >output &&
343 test_cmp expect output
344
345'
346
347cat >expect <<\EOF
348 M modified
349A ../dir2/added
350?? untracked
351?? ../dir2/modified
352?? ../dir2/untracked
353?? ../expect
354?? ../output
355?? ../untracked
356EOF
357test_expect_success 'status -s with relative paths' '
358
359 (cd dir1 && git status -s) >output &&
360 test_cmp expect output
361
362'
363
364cat >expect <<\EOF
365 M dir1/modified
366A dir2/added
367?? dir1/untracked
368?? dir2/modified
369?? dir2/untracked
370?? expect
371?? output
372?? untracked
373EOF
374
375test_expect_success 'status --porcelain ignores relative paths setting' '
376
377 (cd dir1 && git status --porcelain) >output &&
378 test_cmp expect output
379
380'
381
382test_expect_success 'setup unique colors' '
383
384 git config status.color.untracked blue &&
385 git config status.color.branch green
386
387'
388
389cat >expect <<\EOF
390# On branch <GREEN>master<RESET>
391# Changes to be committed:
392# (use "git reset HEAD <file>..." to unstage)
393#
394# <GREEN>new file: dir2/added<RESET>
395#
396# Changes not staged for commit:
397# (use "git add <file>..." to update what will be committed)
398# (use "git checkout -- <file>..." to discard changes in working directory)
399#
400# <RED>modified: dir1/modified<RESET>
401#
402# Untracked files:
403# (use "git add <file>..." to include in what will be committed)
404#
405# <BLUE>dir1/untracked<RESET>
406# <BLUE>dir2/modified<RESET>
407# <BLUE>dir2/untracked<RESET>
408# <BLUE>expect<RESET>
409# <BLUE>output<RESET>
410# <BLUE>untracked<RESET>
411EOF
412
413test_expect_success 'status with color.ui' '
414
415 git config color.ui always &&
416 git status | test_decode_color >output &&
417 test_cmp expect output
418
419'
420
421test_expect_success 'status with color.status' '
422
423 git config --unset color.ui &&
424 git config color.status always &&
425 git status | test_decode_color >output &&
426 test_cmp expect output
427
428'
429
430cat >expect <<\EOF
431 <RED>M<RESET> dir1/modified
432<GREEN>A<RESET> dir2/added
433<BLUE>??<RESET> dir1/untracked
434<BLUE>??<RESET> dir2/modified
435<BLUE>??<RESET> dir2/untracked
436<BLUE>??<RESET> expect
437<BLUE>??<RESET> output
438<BLUE>??<RESET> untracked
439EOF
440
441test_expect_success 'status -s with color.ui' '
442
443 git config --unset color.status &&
444 git config color.ui always &&
445 git status -s | test_decode_color >output &&
446 test_cmp expect output
447
448'
449
450test_expect_success 'status -s with color.status' '
451
452 git config --unset color.ui &&
453 git config color.status always &&
454 git status -s | test_decode_color >output &&
455 test_cmp expect output
456
457'
458
459cat >expect <<\EOF
460## <GREEN>master<RESET>
461 <RED>M<RESET> dir1/modified
462<GREEN>A<RESET> dir2/added
463<BLUE>??<RESET> dir1/untracked
464<BLUE>??<RESET> dir2/modified
465<BLUE>??<RESET> dir2/untracked
466<BLUE>??<RESET> expect
467<BLUE>??<RESET> output
468<BLUE>??<RESET> untracked
469EOF
470
471test_expect_success 'status -s -b with color.status' '
472
473 git status -s -b | test_decode_color >output &&
474 test_cmp expect output
475
476'
477
478cat >expect <<\EOF
479 M dir1/modified
480A dir2/added
481?? dir1/untracked
482?? dir2/modified
483?? dir2/untracked
484?? expect
485?? output
486?? untracked
487EOF
488
489test_expect_success 'status --porcelain ignores color.ui' '
490
491 git config --unset color.status &&
492 git config color.ui always &&
493 git status --porcelain | test_decode_color >output &&
494 test_cmp expect output
495
496'
497
498test_expect_success 'status --porcelain ignores color.status' '
499
500 git config --unset color.ui &&
501 git config color.status always &&
502 git status --porcelain | test_decode_color >output &&
503 test_cmp expect output
504
505'
506
507# recover unconditionally from color tests
508git config --unset color.status
509git config --unset color.ui
510
511test_expect_success 'status --porcelain ignores -b' '
512
513 git status --porcelain -b >output &&
514 test_cmp expect output
515
516'
517
518cat >expect <<\EOF
519# On branch master
520# Changes to be committed:
521# (use "git reset HEAD <file>..." to unstage)
522#
523# new file: dir2/added
524#
525# Changes not staged for commit:
526# (use "git add <file>..." to update what will be committed)
527# (use "git checkout -- <file>..." to discard changes in working directory)
528#
529# modified: dir1/modified
530#
531# Untracked files:
532# (use "git add <file>..." to include in what will be committed)
533#
534# dir1/untracked
535# dir2/modified
536# dir2/untracked
537# expect
538# output
539# untracked
540EOF
541
542
543test_expect_success 'status without relative paths' '
544
545 git config status.relativePaths false
546 (cd dir1 && git status) >output &&
547 test_cmp expect output
548
549'
550
551cat >expect <<\EOF
552 M dir1/modified
553A dir2/added
554?? dir1/untracked
555?? dir2/modified
556?? dir2/untracked
557?? expect
558?? output
559?? untracked
560EOF
561
562test_expect_success 'status -s without relative paths' '
563
564 (cd dir1 && git status -s) >output &&
565 test_cmp expect output
566
567'
568
569cat <<EOF >expect
570# On branch master
571# Changes to be committed:
572# (use "git reset HEAD <file>..." to unstage)
573#
574# modified: dir1/modified
575#
576# Untracked files:
577# (use "git add <file>..." to include in what will be committed)
578#
579# dir1/untracked
580# dir2/
581# expect
582# output
583# untracked
584EOF
585test_expect_success 'dry-run of partial commit excluding new file in index' '
586 git commit --dry-run dir1/modified >output &&
587 test_cmp expect output
588'
589
590cat >expect <<EOF
591:100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
592EOF
593test_expect_success 'status refreshes the index' '
594 touch dir2/added &&
595 git status &&
596 git diff-files >output &&
597 test_cmp expect output
598'
599
600test_expect_success 'setup status submodule summary' '
601 test_create_repo sm && (
602 cd sm &&
603 >foo &&
604 git add foo &&
605 git commit -m "Add foo"
606 ) &&
607 git add sm
608'
609
610cat >expect <<EOF
611# On branch master
612# Changes to be committed:
613# (use "git reset HEAD <file>..." to unstage)
614#
615# new file: dir2/added
616# new file: sm
617#
618# Changes not staged for commit:
619# (use "git add <file>..." to update what will be committed)
620# (use "git checkout -- <file>..." to discard changes in working directory)
621#
622# modified: dir1/modified
623#
624# Untracked files:
625# (use "git add <file>..." to include in what will be committed)
626#
627# dir1/untracked
628# dir2/modified
629# dir2/untracked
630# expect
631# output
632# untracked
633EOF
634test_expect_success 'status submodule summary is disabled by default' '
635 git status >output &&
636 test_cmp expect output
637'
638
639# we expect the same as the previous test
640test_expect_success 'status --untracked-files=all does not show submodule' '
641 git status --untracked-files=all >output &&
642 test_cmp expect output
643'
644
645cat >expect <<EOF
646 M dir1/modified
647A dir2/added
648A sm
649?? dir1/untracked
650?? dir2/modified
651?? dir2/untracked
652?? expect
653?? output
654?? untracked
655EOF
656test_expect_success 'status -s submodule summary is disabled by default' '
657 git status -s >output &&
658 test_cmp expect output
659'
660
661# we expect the same as the previous test
662test_expect_success 'status -s --untracked-files=all does not show submodule' '
663 git status -s --untracked-files=all >output &&
664 test_cmp expect output
665'
666
667head=$(cd sm && git rev-parse --short=7 --verify HEAD)
668
669cat >expect <<EOF
670# On branch master
671# Changes to be committed:
672# (use "git reset HEAD <file>..." to unstage)
673#
674# new file: dir2/added
675# new file: sm
676#
677# Changes not staged for commit:
678# (use "git add <file>..." to update what will be committed)
679# (use "git checkout -- <file>..." to discard changes in working directory)
680#
681# modified: dir1/modified
682#
683# Submodule changes to be committed:
684#
685# * sm 0000000...$head (1):
686# > Add foo
687#
688# Untracked files:
689# (use "git add <file>..." to include in what will be committed)
690#
691# dir1/untracked
692# dir2/modified
693# dir2/untracked
694# expect
695# output
696# untracked
697EOF
698test_expect_success 'status submodule summary' '
699 git config status.submodulesummary 10 &&
700 git status >output &&
701 test_cmp expect output
702'
703
704cat >expect <<EOF
705 M dir1/modified
706A dir2/added
707A sm
708?? dir1/untracked
709?? dir2/modified
710?? dir2/untracked
711?? expect
712?? output
713?? untracked
714EOF
715test_expect_success 'status -s submodule summary' '
716 git status -s >output &&
717 test_cmp expect output
718'
719
720cat >expect <<EOF
721# On branch master
722# Changes not staged for commit:
723# (use "git add <file>..." to update what will be committed)
724# (use "git checkout -- <file>..." to discard changes in working directory)
725#
726# modified: dir1/modified
727#
728# Untracked files:
729# (use "git add <file>..." to include in what will be committed)
730#
731# dir1/untracked
732# dir2/modified
733# dir2/untracked
734# expect
735# output
736# untracked
737no changes added to commit (use "git add" and/or "git commit -a")
738EOF
739test_expect_success 'status submodule summary (clean submodule)' '
740 git commit -m "commit submodule" &&
741 git config status.submodulesummary 10 &&
742 test_must_fail git commit --dry-run >output &&
743 test_cmp expect output &&
744 git status >output &&
745 test_cmp expect output
746'
747
748cat >expect <<EOF
749 M dir1/modified
750?? dir1/untracked
751?? dir2/modified
752?? dir2/untracked
753?? expect
754?? output
755?? untracked
756EOF
757test_expect_success 'status -s submodule summary (clean submodule)' '
758 git status -s >output &&
759 test_cmp expect output
760'
761
762cat >expect <<EOF
763# On branch master
764# Changes to be committed:
765# (use "git reset HEAD^1 <file>..." to unstage)
766#
767# new file: dir2/added
768# new file: sm
769#
770# Changes not staged for commit:
771# (use "git add <file>..." to update what will be committed)
772# (use "git checkout -- <file>..." to discard changes in working directory)
773#
774# modified: dir1/modified
775#
776# Submodule changes to be committed:
777#
778# * sm 0000000...$head (1):
779# > Add foo
780#
781# Untracked files:
782# (use "git add <file>..." to include in what will be committed)
783#
784# dir1/untracked
785# dir2/modified
786# dir2/untracked
787# expect
788# output
789# untracked
790EOF
791test_expect_success 'commit --dry-run submodule summary (--amend)' '
792 git config status.submodulesummary 10 &&
793 git commit --dry-run --amend >output &&
794 test_cmp expect output
795'
796
797test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
798 (
799 chmod a-w .git &&
800 # make dir1/tracked stat-dirty
801 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
802 git status -s >output &&
803 ! grep dir1/tracked output &&
804 # make sure "status" succeeded without writing index out
805 git diff-files | grep dir1/tracked
806 )
807 status=$?
808 chmod 775 .git
809 (exit $status)
810'
811
812(cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
813new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
814touch .gitmodules
815
816cat > expect << EOF
817# On branch master
818# Changes to be committed:
819# (use "git reset HEAD <file>..." to unstage)
820#
821# modified: sm
822#
823# Changes not staged for commit:
824# (use "git add <file>..." to update what will be committed)
825# (use "git checkout -- <file>..." to discard changes in working directory)
826#
827# modified: dir1/modified
828#
829# Submodule changes to be committed:
830#
831# * sm $head...$new_head (1):
832# > Add bar
833#
834# Untracked files:
835# (use "git add <file>..." to include in what will be committed)
836#
837# .gitmodules
838# dir1/untracked
839# dir2/modified
840# dir2/untracked
841# expect
842# output
843# untracked
844EOF
845
846test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
847 echo modified > sm/untracked &&
848 git status --ignore-submodules=untracked > output &&
849 test_cmp expect output
850'
851
852test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
853 git config diff.ignoreSubmodules dirty &&
854 git status >output &&
855 test_cmp expect output &&
856 git config --add -f .gitmodules submodule.subname.ignore untracked &&
857 git config --add -f .gitmodules submodule.subname.path sm &&
858 git status > output &&
859 test_cmp expect output &&
860 git config -f .gitmodules --remove-section submodule.subname &&
861 git config --unset diff.ignoreSubmodules
862'
863
864test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
865 git config --add -f .gitmodules submodule.subname.ignore none &&
866 git config --add -f .gitmodules submodule.subname.path sm &&
867 git config --add submodule.subname.ignore untracked &&
868 git config --add submodule.subname.path sm &&
869 git status > output &&
870 test_cmp expect output &&
871 git config --remove-section submodule.subname &&
872 git config --remove-section -f .gitmodules submodule.subname
873'
874
875test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
876 git status --ignore-submodules=dirty > output &&
877 test_cmp expect output
878'
879
880test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
881 git config diff.ignoreSubmodules dirty &&
882 git status >output &&
883 ! test -s actual &&
884 git config --add -f .gitmodules submodule.subname.ignore dirty &&
885 git config --add -f .gitmodules submodule.subname.path sm &&
886 git status > output &&
887 test_cmp expect output &&
888 git config -f .gitmodules --remove-section submodule.subname &&
889 git config --unset diff.ignoreSubmodules
890'
891
892test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
893 git config --add -f .gitmodules submodule.subname.ignore none &&
894 git config --add -f .gitmodules submodule.subname.path sm &&
895 git config --add submodule.subname.ignore dirty &&
896 git config --add submodule.subname.path sm &&
897 git status > output &&
898 test_cmp expect output &&
899 git config --remove-section submodule.subname &&
900 git config -f .gitmodules --remove-section submodule.subname
901'
902
903test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
904 echo modified > sm/foo &&
905 git status --ignore-submodules=dirty > output &&
906 test_cmp expect output
907'
908
909test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
910 git config --add -f .gitmodules submodule.subname.ignore dirty &&
911 git config --add -f .gitmodules submodule.subname.path sm &&
912 git status > output &&
913 test_cmp expect output &&
914 git config -f .gitmodules --remove-section submodule.subname
915'
916
917test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
918 git config --add -f .gitmodules submodule.subname.ignore none &&
919 git config --add -f .gitmodules submodule.subname.path sm &&
920 git config --add submodule.subname.ignore dirty &&
921 git config --add submodule.subname.path sm &&
922 git status > output &&
923 test_cmp expect output &&
924 git config --remove-section submodule.subname &&
925 git config -f .gitmodules --remove-section submodule.subname
926'
927
928cat > expect << EOF
929# On branch master
930# Changes to be committed:
931# (use "git reset HEAD <file>..." to unstage)
932#
933# modified: sm
934#
935# Changes not staged for commit:
936# (use "git add <file>..." to update what will be committed)
937# (use "git checkout -- <file>..." to discard changes in working directory)
938# (commit or discard the untracked or modified content in submodules)
939#
940# modified: dir1/modified
941# modified: sm (modified content)
942#
943# Submodule changes to be committed:
944#
945# * sm $head...$new_head (1):
946# > Add bar
947#
948# Untracked files:
949# (use "git add <file>..." to include in what will be committed)
950#
951# .gitmodules
952# dir1/untracked
953# dir2/modified
954# dir2/untracked
955# expect
956# output
957# untracked
958EOF
959
960test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
961 git status --ignore-submodules=untracked > output &&
962 test_cmp expect output
963'
964
965test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
966 git config --add -f .gitmodules submodule.subname.ignore untracked &&
967 git config --add -f .gitmodules submodule.subname.path sm &&
968 git status > output &&
969 test_cmp expect output &&
970 git config -f .gitmodules --remove-section submodule.subname
971'
972
973test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
974 git config --add -f .gitmodules submodule.subname.ignore none &&
975 git config --add -f .gitmodules submodule.subname.path sm &&
976 git config --add submodule.subname.ignore untracked &&
977 git config --add submodule.subname.path sm &&
978 git status > output &&
979 test_cmp expect output &&
980 git config --remove-section submodule.subname &&
981 git config -f .gitmodules --remove-section submodule.subname
982'
983
984head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
985
986cat > expect << EOF
987# On branch master
988# Changes to be committed:
989# (use "git reset HEAD <file>..." to unstage)
990#
991# modified: sm
992#
993# Changes not staged for commit:
994# (use "git add <file>..." to update what will be committed)
995# (use "git checkout -- <file>..." to discard changes in working directory)
996#
997# modified: dir1/modified
998# modified: sm (new commits)
999#
1000# Submodule changes to be committed:
1001#
1002# * sm $head...$new_head (1):
1003# > Add bar
1004#
1005# Submodules changed but not updated:
1006#
1007# * sm $new_head...$head2 (1):
1008# > 2nd commit
1009#
1010# Untracked files:
1011# (use "git add <file>..." to include in what will be committed)
1012#
1013# .gitmodules
1014# dir1/untracked
1015# dir2/modified
1016# dir2/untracked
1017# expect
1018# output
1019# untracked
1020EOF
1021
1022test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1023 git status --ignore-submodules=untracked > output &&
1024 test_cmp expect output
1025'
1026
1027test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1028 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1029 git config --add -f .gitmodules submodule.subname.path sm &&
1030 git status > output &&
1031 test_cmp expect output &&
1032 git config -f .gitmodules --remove-section submodule.subname
1033'
1034
1035test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1036 git config --add -f .gitmodules submodule.subname.ignore none &&
1037 git config --add -f .gitmodules submodule.subname.path sm &&
1038 git config --add submodule.subname.ignore untracked &&
1039 git config --add submodule.subname.path sm &&
1040 git status > output &&
1041 test_cmp expect output &&
1042 git config --remove-section submodule.subname &&
1043 git config -f .gitmodules --remove-section submodule.subname
1044'
1045
1046test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1047 git status --ignore-submodules=dirty > output &&
1048 test_cmp expect output
1049'
1050test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1051 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1052 git config --add -f .gitmodules submodule.subname.path sm &&
1053 git status > output &&
1054 test_cmp expect output &&
1055 git config -f .gitmodules --remove-section submodule.subname
1056'
1057
1058test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1059 git config --add -f .gitmodules submodule.subname.ignore none &&
1060 git config --add -f .gitmodules submodule.subname.path sm &&
1061 git config --add submodule.subname.ignore dirty &&
1062 git config --add submodule.subname.path sm &&
1063 git status > output &&
1064 test_cmp expect output &&
1065 git config --remove-section submodule.subname &&
1066 git config -f .gitmodules --remove-section submodule.subname
1067'
1068
1069cat > expect << EOF
1070# On branch master
1071# Changes not staged for commit:
1072# (use "git add <file>..." to update what will be committed)
1073# (use "git checkout -- <file>..." to discard changes in working directory)
1074#
1075# modified: dir1/modified
1076#
1077# Untracked files:
1078# (use "git add <file>..." to include in what will be committed)
1079#
1080# .gitmodules
1081# dir1/untracked
1082# dir2/modified
1083# dir2/untracked
1084# expect
1085# output
1086# untracked
1087no changes added to commit (use "git add" and/or "git commit -a")
1088EOF
1089
1090test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1091 git status --ignore-submodules=all > output &&
1092 test_cmp expect output
1093'
1094
1095test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1096 git config --add -f .gitmodules submodule.subname.ignore all &&
1097 git config --add -f .gitmodules submodule.subname.path sm &&
1098 git status > output &&
1099 test_cmp expect output &&
1100 git config -f .gitmodules --remove-section submodule.subname
1101'
1102
1103test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1104 git config --add -f .gitmodules submodule.subname.ignore none &&
1105 git config --add -f .gitmodules submodule.subname.path sm &&
1106 git config --add submodule.subname.ignore all &&
1107 git config --add submodule.subname.path sm &&
1108 git status > output &&
1109 test_cmp expect output &&
1110 git config --remove-section submodule.subname &&
1111 git config -f .gitmodules --remove-section submodule.subname
1112'
1113
1114test_done