]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7508-status.sh
Merge branch 'cb/maint-orphan-merge-noclobber'
[thirdparty/git.git] / t / t7508-status.sh
CommitLineData
367c9886
JS
1#!/bin/sh
2#
3# Copyright (c) 2007 Johannes E. Schindelin
4#
5
47a528ad 6test_description='git status'
367c9886
JS
7
8. ./test-lib.sh
9
10test_expect_success 'setup' '
68cfc6f5
MG
11 : >tracked &&
12 : >modified &&
367c9886 13 mkdir dir1 &&
68cfc6f5
MG
14 : >dir1/tracked &&
15 : >dir1/modified &&
367c9886 16 mkdir dir2 &&
68cfc6f5
MG
17 : >dir1/tracked &&
18 : >dir1/modified &&
367c9886 19 git add . &&
ff58b9aa
JK
20
21 git status >output &&
22
367c9886
JS
23 test_tick &&
24 git commit -m initial &&
68cfc6f5
MG
25 : >untracked &&
26 : >dir1/untracked &&
27 : >dir2/untracked &&
28 echo 1 >dir1/modified &&
29 echo 2 >dir2/modified &&
30 echo 3 >dir2/added &&
367c9886
JS
31 git add dir2/added
32'
33
ff58b9aa
JK
34test_expect_success 'status (1)' '
35
aadbe44f 36 grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
ff58b9aa
JK
37
38'
39
68cfc6f5 40cat >expect <<\EOF
367c9886
JS
41# On branch master
42# Changes to be committed:
43# (use "git reset HEAD <file>..." to unstage)
44#
45# new file: dir2/added
46#
8009d83c 47# Changes not staged for commit:
367c9886 48# (use "git add <file>..." to update what will be committed)
4d6e4c4d 49# (use "git checkout -- <file>..." to discard changes in working directory)
367c9886
JS
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
ff58b9aa 64test_expect_success 'status (2)' '
367c9886 65
68cfc6f5 66 git status >output &&
3af82863 67 test_cmp expect output
367c9886
JS
68
69'
70
18f3b5a9
MG
71cat >expect <<\EOF
72# On branch master
73# Changes to be committed:
74# new file: dir2/added
75#
8009d83c 76# Changes not staged for commit:
18f3b5a9
MG
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
68cfc6f5 99cat >expect <<\EOF
14ed05dd
MG
100 M dir1/modified
101A dir2/added
102?? dir1/untracked
103?? dir2/modified
104?? dir2/untracked
105?? expect
106?? output
107?? untracked
108EOF
109
46077fa5 110test_expect_success 'status -s' '
14ed05dd 111
68cfc6f5 112 git status -s >output &&
14ed05dd
MG
113 test_cmp expect output
114
115'
116
46077fa5
MG
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
6c2ce048
MSO
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#
8009d83c 143# Changes not staged for commit:
6c2ce048 144# (use "git add <file>..." to update what will be committed)
4d6e4c4d 145# (use "git checkout -- <file>..." to discard changes in working directory)
6c2ce048
MSO
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 &&
68cfc6f5
MG
153 : >dir3/untracked1 &&
154 : >dir3/untracked2 &&
6c2ce048
MSO
155 git status -uno >output &&
156 test_cmp expect output
157'
158
d6293d1f
MSO
159test_expect_success 'status (status.showUntrackedFiles no)' '
160 git config status.showuntrackedfiles no
161 git status >output &&
162 test_cmp expect output
163'
164
18f3b5a9
MG
165cat >expect <<EOF
166# On branch master
167# Changes to be committed:
168# new file: dir2/added
169#
8009d83c 170# Changes not staged for commit:
18f3b5a9
MG
171# modified: dir1/modified
172#
980bde38 173# Untracked files not listed
18f3b5a9
MG
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
14ed05dd
MG
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
4bfee30a
MSO
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#
8009d83c 205# Changes not staged for commit:
4bfee30a 206# (use "git add <file>..." to update what will be committed)
4d6e4c4d 207# (use "git checkout -- <file>..." to discard changes in working directory)
4bfee30a
MSO
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' '
4bfee30a
MSO
223 git status -unormal >output &&
224 test_cmp expect output
225'
226
d6293d1f
MSO
227test_expect_success 'status (status.showUntrackedFiles normal)' '
228 git config status.showuntrackedfiles normal
229 git status >output &&
230 test_cmp expect output
231'
232
14ed05dd
MG
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
4bfee30a
MSO
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#
8009d83c 263# Changes not staged for commit:
4bfee30a 264# (use "git add <file>..." to update what will be committed)
4d6e4c4d 265# (use "git checkout -- <file>..." to discard changes in working directory)
4bfee30a
MSO
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 &&
d6293d1f
MSO
283 test_cmp expect output
284'
285test_expect_success 'status (status.showUntrackedFiles all)' '
286 git config status.showuntrackedfiles all
287 git status >output &&
4bfee30a 288 rm -rf dir3 &&
d6293d1f 289 git config --unset status.showuntrackedfiles &&
4bfee30a
MSO
290 test_cmp expect output
291'
292
14ed05dd
MG
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
68cfc6f5 316cat >expect <<\EOF
367c9886
JS
317# On branch master
318# Changes to be committed:
319# (use "git reset HEAD <file>..." to unstage)
320#
321# new file: ../dir2/added
322#
8009d83c 323# Changes not staged for commit:
367c9886 324# (use "git add <file>..." to update what will be committed)
4d6e4c4d 325# (use "git checkout -- <file>..." to discard changes in working directory)
367c9886 326#
69e74918 327# modified: modified
367c9886
JS
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
68cfc6f5 342 (cd dir1 && git status) >output &&
3af82863 343 test_cmp expect output
367c9886
JS
344
345'
346
68cfc6f5 347cat >expect <<\EOF
14ed05dd
MG
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
68cfc6f5 359 (cd dir1 && git status -s) >output &&
14ed05dd
MG
360 test_cmp expect output
361
362'
363
68cfc6f5 364cat >expect <<\EOF
c521bb71
MG
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
68cfc6f5 377 (cd dir1 && git status --porcelain) >output &&
c521bb71
MG
378 test_cmp expect output
379
380'
381
68cfc6f5
MG
382test_expect_success 'setup unique colors' '
383
384 git config status.color.untracked blue
385
386'
387
388cat >expect <<\EOF
389# On branch master
390# Changes to be committed:
391# (use "git reset HEAD <file>..." to unstage)
392#
393# <GREEN>new file: dir2/added<RESET>
394#
8009d83c 395# Changes not staged for commit:
68cfc6f5
MG
396# (use "git add <file>..." to update what will be committed)
397# (use "git checkout -- <file>..." to discard changes in working directory)
398#
399# <RED>modified: dir1/modified<RESET>
400#
401# Untracked files:
402# (use "git add <file>..." to include in what will be committed)
403#
404# <BLUE>dir1/untracked<RESET>
405# <BLUE>dir2/modified<RESET>
406# <BLUE>dir2/untracked<RESET>
407# <BLUE>expect<RESET>
408# <BLUE>output<RESET>
409# <BLUE>untracked<RESET>
410EOF
411
412test_expect_success 'status with color.ui' '
413
414 git config color.ui always &&
415 git status | test_decode_color >output &&
416 test_cmp expect output
417
418'
419
420test_expect_success 'status with color.status' '
421
422 git config --unset color.ui &&
423 git config color.status always &&
424 git status | test_decode_color >output &&
425 test_cmp expect output
426
427'
428
429cat >expect <<\EOF
430 <RED>M<RESET> dir1/modified
431<GREEN>A<RESET> dir2/added
432<BLUE>??<RESET> dir1/untracked
433<BLUE>??<RESET> dir2/modified
434<BLUE>??<RESET> dir2/untracked
435<BLUE>??<RESET> expect
436<BLUE>??<RESET> output
437<BLUE>??<RESET> untracked
438EOF
439
440test_expect_success 'status -s with color.ui' '
441
442 git config --unset color.status &&
443 git config color.ui always &&
444 git status -s | test_decode_color >output &&
445 test_cmp expect output
446
447'
448
449test_expect_success 'status -s with color.status' '
450
451 git config --unset color.ui &&
452 git config color.status always &&
453 git status -s | test_decode_color >output &&
454 test_cmp expect output
455
456'
457
46077fa5
MG
458cat >expect <<\EOF
459## <GREEN>master<RESET>
460 <RED>M<RESET> dir1/modified
461<GREEN>A<RESET> dir2/added
462<BLUE>??<RESET> dir1/untracked
463<BLUE>??<RESET> dir2/modified
464<BLUE>??<RESET> dir2/untracked
465<BLUE>??<RESET> expect
466<BLUE>??<RESET> output
467<BLUE>??<RESET> untracked
468EOF
469
470test_expect_success 'status -s -b with color.status' '
471
472 git status -s -b | test_decode_color >output &&
473 test_cmp expect output
474
475'
476
68cfc6f5
MG
477cat >expect <<\EOF
478 M dir1/modified
479A dir2/added
480?? dir1/untracked
481?? dir2/modified
482?? dir2/untracked
483?? expect
484?? output
485?? untracked
486EOF
487
488test_expect_success 'status --porcelain ignores color.ui' '
489
490 git config --unset color.status &&
491 git config color.ui always &&
492 git status --porcelain | test_decode_color >output &&
493 test_cmp expect output
494
495'
496
497test_expect_success 'status --porcelain ignores color.status' '
498
499 git config --unset color.ui &&
500 git config color.status always &&
501 git status --porcelain | test_decode_color >output &&
502 test_cmp expect output
503
504'
505
506# recover unconditionally from color tests
507git config --unset color.status
508git config --unset color.ui
509
46077fa5
MG
510test_expect_success 'status --porcelain ignores -b' '
511
512 git status --porcelain -b >output &&
513 test_cmp expect output
514
515'
516
68cfc6f5 517cat >expect <<\EOF
46f721c8
JK
518# On branch master
519# Changes to be committed:
520# (use "git reset HEAD <file>..." to unstage)
521#
522# new file: dir2/added
523#
8009d83c 524# Changes not staged for commit:
46f721c8 525# (use "git add <file>..." to update what will be committed)
4d6e4c4d 526# (use "git checkout -- <file>..." to discard changes in working directory)
46f721c8
JK
527#
528# modified: dir1/modified
529#
530# Untracked files:
531# (use "git add <file>..." to include in what will be committed)
532#
533# dir1/untracked
534# dir2/modified
535# dir2/untracked
536# expect
537# output
538# untracked
539EOF
540
68cfc6f5 541
46f721c8
JK
542test_expect_success 'status without relative paths' '
543
544 git config status.relativePaths false
68cfc6f5 545 (cd dir1 && git status) >output &&
3af82863 546 test_cmp expect output
46f721c8
JK
547
548'
549
68cfc6f5 550cat >expect <<\EOF
14ed05dd
MG
551 M dir1/modified
552A dir2/added
553?? dir1/untracked
554?? dir2/modified
555?? dir2/untracked
556?? expect
557?? output
558?? untracked
559EOF
560
561test_expect_success 'status -s without relative paths' '
562
68cfc6f5 563 (cd dir1 && git status -s) >output &&
14ed05dd
MG
564 test_cmp expect output
565
566'
567
959ba670
JK
568cat <<EOF >expect
569# On branch master
570# Changes to be committed:
571# (use "git reset HEAD <file>..." to unstage)
572#
573# modified: dir1/modified
574#
575# Untracked files:
576# (use "git add <file>..." to include in what will be committed)
577#
578# dir1/untracked
579# dir2/
580# expect
581# output
582# untracked
583EOF
9e4b7ab6
JH
584test_expect_success 'dry-run of partial commit excluding new file in index' '
585 git commit --dry-run dir1/modified >output &&
82ebb0b6 586 test_cmp expect output
959ba670
JK
587'
588
4c926b37
MH
589cat >expect <<EOF
590:100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified
591EOF
4bb6644d 592test_expect_success 'status refreshes the index' '
4c926b37
MH
593 touch dir2/added &&
594 git status &&
595 git diff-files >output &&
596 test_cmp expect output
597'
598
e5e4a7f2
PY
599test_expect_success 'setup status submodule summary' '
600 test_create_repo sm && (
601 cd sm &&
602 >foo &&
603 git add foo &&
604 git commit -m "Add foo"
605 ) &&
606 git add sm
607'
608
609cat >expect <<EOF
610# On branch master
611# Changes to be committed:
612# (use "git reset HEAD <file>..." to unstage)
613#
614# new file: dir2/added
615# new file: sm
616#
8009d83c 617# Changes not staged for commit:
e5e4a7f2 618# (use "git add <file>..." to update what will be committed)
4d6e4c4d 619# (use "git checkout -- <file>..." to discard changes in working directory)
e5e4a7f2
PY
620#
621# modified: dir1/modified
622#
623# Untracked files:
624# (use "git add <file>..." to include in what will be committed)
625#
626# dir1/untracked
627# dir2/modified
628# dir2/untracked
629# expect
630# output
631# untracked
632EOF
633test_expect_success 'status submodule summary is disabled by default' '
634 git status >output &&
635 test_cmp expect output
636'
637
98fa4738
JK
638# we expect the same as the previous test
639test_expect_success 'status --untracked-files=all does not show submodule' '
640 git status --untracked-files=all >output &&
e5e4a7f2
PY
641 test_cmp expect output
642'
643
14ed05dd
MG
644cat >expect <<EOF
645 M dir1/modified
646A dir2/added
647A sm
648?? dir1/untracked
649?? dir2/modified
650?? dir2/untracked
651?? expect
652?? output
653?? untracked
654EOF
655test_expect_success 'status -s submodule summary is disabled by default' '
656 git status -s >output &&
657 test_cmp expect output
658'
659
660# we expect the same as the previous test
661test_expect_success 'status -s --untracked-files=all does not show submodule' '
662 git status -s --untracked-files=all >output &&
663 test_cmp expect output
664'
665
e5e4a7f2
PY
666head=$(cd sm && git rev-parse --short=7 --verify HEAD)
667
668cat >expect <<EOF
669# On branch master
670# Changes to be committed:
671# (use "git reset HEAD <file>..." to unstage)
672#
673# new file: dir2/added
674# new file: sm
675#
8009d83c 676# Changes not staged for commit:
e5e4a7f2 677# (use "git add <file>..." to update what will be committed)
4d6e4c4d 678# (use "git checkout -- <file>..." to discard changes in working directory)
e5e4a7f2
PY
679#
680# modified: dir1/modified
681#
f17a5d34 682# Submodule changes to be committed:
e5e4a7f2
PY
683#
684# * sm 0000000...$head (1):
685# > Add foo
686#
687# Untracked files:
688# (use "git add <file>..." to include in what will be committed)
689#
690# dir1/untracked
691# dir2/modified
692# dir2/untracked
693# expect
694# output
695# untracked
696EOF
697test_expect_success 'status submodule summary' '
698 git config status.submodulesummary 10 &&
699 git status >output &&
700 test_cmp expect output
701'
702
14ed05dd
MG
703cat >expect <<EOF
704 M dir1/modified
705A dir2/added
706A sm
707?? dir1/untracked
708?? dir2/modified
709?? dir2/untracked
710?? expect
711?? output
712?? untracked
713EOF
714test_expect_success 'status -s submodule summary' '
715 git status -s >output &&
716 test_cmp expect output
717'
e5e4a7f2
PY
718
719cat >expect <<EOF
720# On branch master
8009d83c 721# Changes not staged for commit:
e5e4a7f2 722# (use "git add <file>..." to update what will be committed)
4d6e4c4d 723# (use "git checkout -- <file>..." to discard changes in working directory)
e5e4a7f2
PY
724#
725# modified: dir1/modified
726#
727# Untracked files:
728# (use "git add <file>..." to include in what will be committed)
729#
730# dir1/untracked
731# dir2/modified
732# dir2/untracked
733# expect
734# output
735# untracked
736no changes added to commit (use "git add" and/or "git commit -a")
737EOF
738test_expect_success 'status submodule summary (clean submodule)' '
739 git commit -m "commit submodule" &&
740 git config status.submodulesummary 10 &&
9e4b7ab6
JH
741 test_must_fail git commit --dry-run >output &&
742 test_cmp expect output &&
743 git status >output &&
e5e4a7f2
PY
744 test_cmp expect output
745'
746
14ed05dd
MG
747cat >expect <<EOF
748 M dir1/modified
749?? dir1/untracked
750?? dir2/modified
751?? dir2/untracked
752?? expect
753?? output
754?? untracked
755EOF
756test_expect_success 'status -s submodule summary (clean submodule)' '
757 git status -s >output &&
758 test_cmp expect output
759'
760
e5e4a7f2
PY
761cat >expect <<EOF
762# On branch master
763# Changes to be committed:
764# (use "git reset HEAD^1 <file>..." to unstage)
765#
766# new file: dir2/added
767# new file: sm
768#
8009d83c 769# Changes not staged for commit:
e5e4a7f2 770# (use "git add <file>..." to update what will be committed)
4d6e4c4d 771# (use "git checkout -- <file>..." to discard changes in working directory)
e5e4a7f2
PY
772#
773# modified: dir1/modified
774#
f17a5d34 775# Submodule changes to be committed:
e5e4a7f2
PY
776#
777# * sm 0000000...$head (1):
778# > Add foo
779#
780# Untracked files:
781# (use "git add <file>..." to include in what will be committed)
782#
783# dir1/untracked
784# dir2/modified
785# dir2/untracked
786# expect
787# output
788# untracked
789EOF
9e4b7ab6 790test_expect_success 'commit --dry-run submodule summary (--amend)' '
e5e4a7f2 791 git config status.submodulesummary 10 &&
9e4b7ab6 792 git commit --dry-run --amend >output &&
e5e4a7f2
PY
793 test_cmp expect output
794'
795
c91cfd19 796test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
b2f6fd95
MH
797 (
798 chmod a-w .git &&
799 # make dir1/tracked stat-dirty
800 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
801 git status -s >output &&
802 ! grep dir1/tracked output &&
803 # make sure "status" succeeded without writing index out
804 git diff-files | grep dir1/tracked
805 )
806 status=$?
807 chmod 775 .git
808 (exit $status)
809'
810
c2e0940b 811(cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
aee9c7d6
JL
812new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
813touch .gitmodules
814
46a958b3
JL
815cat > expect << EOF
816# On branch master
aee9c7d6
JL
817# Changes to be committed:
818# (use "git reset HEAD <file>..." to unstage)
819#
820# modified: sm
821#
8009d83c 822# Changes not staged for commit:
46a958b3
JL
823# (use "git add <file>..." to update what will be committed)
824# (use "git checkout -- <file>..." to discard changes in working directory)
825#
826# modified: dir1/modified
827#
aee9c7d6
JL
828# Submodule changes to be committed:
829#
830# * sm $head...$new_head (1):
831# > Add bar
832#
46a958b3
JL
833# Untracked files:
834# (use "git add <file>..." to include in what will be committed)
835#
aee9c7d6 836# .gitmodules
46a958b3
JL
837# dir1/untracked
838# dir2/modified
839# dir2/untracked
840# expect
841# output
842# untracked
46a958b3
JL
843EOF
844
845test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
846 echo modified > sm/untracked &&
847 git status --ignore-submodules=untracked > output &&
848 test_cmp expect output
849'
850
302ad7a9 851test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
90e14525
JL
852 git config diff.ignoreSubmodules dirty &&
853 git status >output &&
854 test_cmp expect output &&
302ad7a9
JL
855 git config --add -f .gitmodules submodule.subname.ignore untracked &&
856 git config --add -f .gitmodules submodule.subname.path sm &&
857 git status > output &&
858 test_cmp expect output &&
90e14525
JL
859 git config -f .gitmodules --remove-section submodule.subname &&
860 git config --unset diff.ignoreSubmodules
302ad7a9
JL
861'
862
aee9c7d6 863test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
302ad7a9
JL
864 git config --add -f .gitmodules submodule.subname.ignore none &&
865 git config --add -f .gitmodules submodule.subname.path sm &&
aee9c7d6
JL
866 git config --add submodule.subname.ignore untracked &&
867 git config --add submodule.subname.path sm &&
868 git status > output &&
869 test_cmp expect output &&
302ad7a9
JL
870 git config --remove-section submodule.subname &&
871 git config --remove-section -f .gitmodules submodule.subname
aee9c7d6
JL
872'
873
46a958b3
JL
874test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
875 git status --ignore-submodules=dirty > output &&
876 test_cmp expect output
877'
878
302ad7a9 879test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
90e14525
JL
880 git config diff.ignoreSubmodules dirty &&
881 git status >output &&
882 ! test -s actual &&
302ad7a9
JL
883 git config --add -f .gitmodules submodule.subname.ignore dirty &&
884 git config --add -f .gitmodules submodule.subname.path sm &&
885 git status > output &&
886 test_cmp expect output &&
90e14525
JL
887 git config -f .gitmodules --remove-section submodule.subname &&
888 git config --unset diff.ignoreSubmodules
302ad7a9
JL
889'
890
aee9c7d6 891test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
302ad7a9
JL
892 git config --add -f .gitmodules submodule.subname.ignore none &&
893 git config --add -f .gitmodules submodule.subname.path sm &&
aee9c7d6
JL
894 git config --add submodule.subname.ignore dirty &&
895 git config --add submodule.subname.path sm &&
896 git status > output &&
897 test_cmp expect output &&
302ad7a9
JL
898 git config --remove-section submodule.subname &&
899 git config -f .gitmodules --remove-section submodule.subname
aee9c7d6
JL
900'
901
46a958b3
JL
902test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
903 echo modified > sm/foo &&
904 git status --ignore-submodules=dirty > output &&
905 test_cmp expect output
906'
907
302ad7a9
JL
908test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
909 git config --add -f .gitmodules submodule.subname.ignore dirty &&
910 git config --add -f .gitmodules submodule.subname.path sm &&
911 git status > output &&
912 test_cmp expect output &&
913 git config -f .gitmodules --remove-section submodule.subname
914'
915
aee9c7d6 916test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
302ad7a9
JL
917 git config --add -f .gitmodules submodule.subname.ignore none &&
918 git config --add -f .gitmodules submodule.subname.path sm &&
aee9c7d6
JL
919 git config --add submodule.subname.ignore dirty &&
920 git config --add submodule.subname.path sm &&
921 git status > output &&
922 test_cmp expect output &&
302ad7a9
JL
923 git config --remove-section submodule.subname &&
924 git config -f .gitmodules --remove-section submodule.subname
aee9c7d6
JL
925'
926
46a958b3
JL
927cat > expect << EOF
928# On branch master
aee9c7d6
JL
929# Changes to be committed:
930# (use "git reset HEAD <file>..." to unstage)
931#
932# modified: sm
933#
8009d83c 934# Changes not staged for commit:
46a958b3
JL
935# (use "git add <file>..." to update what will be committed)
936# (use "git checkout -- <file>..." to discard changes in working directory)
937# (commit or discard the untracked or modified content in submodules)
938#
939# modified: dir1/modified
940# modified: sm (modified content)
941#
aee9c7d6
JL
942# Submodule changes to be committed:
943#
944# * sm $head...$new_head (1):
945# > Add bar
946#
46a958b3
JL
947# Untracked files:
948# (use "git add <file>..." to include in what will be committed)
949#
aee9c7d6 950# .gitmodules
46a958b3
JL
951# dir1/untracked
952# dir2/modified
953# dir2/untracked
954# expect
955# output
956# untracked
46a958b3
JL
957EOF
958
959test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
960 git status --ignore-submodules=untracked > output &&
961 test_cmp expect output
962'
963
302ad7a9
JL
964test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
965 git config --add -f .gitmodules submodule.subname.ignore untracked &&
966 git config --add -f .gitmodules submodule.subname.path sm &&
967 git status > output &&
968 test_cmp expect output &&
969 git config -f .gitmodules --remove-section submodule.subname
970'
971
aee9c7d6 972test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
302ad7a9
JL
973 git config --add -f .gitmodules submodule.subname.ignore none &&
974 git config --add -f .gitmodules submodule.subname.path sm &&
aee9c7d6
JL
975 git config --add submodule.subname.ignore untracked &&
976 git config --add submodule.subname.path sm &&
977 git status > output &&
978 test_cmp expect output &&
302ad7a9
JL
979 git config --remove-section submodule.subname &&
980 git config -f .gitmodules --remove-section submodule.subname
aee9c7d6
JL
981'
982
46a958b3
JL
983head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
984
985cat > expect << EOF
986# On branch master
aee9c7d6
JL
987# Changes to be committed:
988# (use "git reset HEAD <file>..." to unstage)
989#
990# modified: sm
991#
8009d83c 992# Changes not staged for commit:
46a958b3
JL
993# (use "git add <file>..." to update what will be committed)
994# (use "git checkout -- <file>..." to discard changes in working directory)
995#
996# modified: dir1/modified
997# modified: sm (new commits)
998#
aee9c7d6
JL
999# Submodule changes to be committed:
1000#
1001# * sm $head...$new_head (1):
1002# > Add bar
1003#
46a958b3
JL
1004# Submodules changed but not updated:
1005#
aee9c7d6 1006# * sm $new_head...$head2 (1):
46a958b3
JL
1007# > 2nd commit
1008#
1009# Untracked files:
1010# (use "git add <file>..." to include in what will be committed)
1011#
aee9c7d6 1012# .gitmodules
46a958b3
JL
1013# dir1/untracked
1014# dir2/modified
1015# dir2/untracked
1016# expect
1017# output
1018# untracked
46a958b3
JL
1019EOF
1020
1021test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1022 git status --ignore-submodules=untracked > output &&
1023 test_cmp expect output
1024'
1025
302ad7a9
JL
1026test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1027 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1028 git config --add -f .gitmodules submodule.subname.path sm &&
1029 git status > output &&
1030 test_cmp expect output &&
1031 git config -f .gitmodules --remove-section submodule.subname
1032'
1033
aee9c7d6 1034test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
302ad7a9
JL
1035 git config --add -f .gitmodules submodule.subname.ignore none &&
1036 git config --add -f .gitmodules submodule.subname.path sm &&
aee9c7d6
JL
1037 git config --add submodule.subname.ignore untracked &&
1038 git config --add submodule.subname.path sm &&
1039 git status > output &&
1040 test_cmp expect output &&
302ad7a9
JL
1041 git config --remove-section submodule.subname &&
1042 git config -f .gitmodules --remove-section submodule.subname
aee9c7d6
JL
1043'
1044
46a958b3
JL
1045test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1046 git status --ignore-submodules=dirty > output &&
1047 test_cmp expect output
1048'
302ad7a9
JL
1049test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1050 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1051 git config --add -f .gitmodules submodule.subname.path sm &&
1052 git status > output &&
1053 test_cmp expect output &&
1054 git config -f .gitmodules --remove-section submodule.subname
1055'
46a958b3 1056
aee9c7d6 1057test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
302ad7a9
JL
1058 git config --add -f .gitmodules submodule.subname.ignore none &&
1059 git config --add -f .gitmodules submodule.subname.path sm &&
aee9c7d6
JL
1060 git config --add submodule.subname.ignore dirty &&
1061 git config --add submodule.subname.path sm &&
1062 git status > output &&
1063 test_cmp expect output &&
302ad7a9
JL
1064 git config --remove-section submodule.subname &&
1065 git config -f .gitmodules --remove-section submodule.subname
aee9c7d6
JL
1066'
1067
46a958b3
JL
1068cat > expect << EOF
1069# On branch master
8009d83c 1070# Changes not staged for commit:
46a958b3
JL
1071# (use "git add <file>..." to update what will be committed)
1072# (use "git checkout -- <file>..." to discard changes in working directory)
1073#
1074# modified: dir1/modified
1075#
1076# Untracked files:
1077# (use "git add <file>..." to include in what will be committed)
1078#
aee9c7d6 1079# .gitmodules
46a958b3
JL
1080# dir1/untracked
1081# dir2/modified
1082# dir2/untracked
1083# expect
1084# output
1085# untracked
1086no changes added to commit (use "git add" and/or "git commit -a")
1087EOF
1088
1089test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1090 git status --ignore-submodules=all > output &&
1091 test_cmp expect output
1092'
1093
302ad7a9
JL
1094test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1095 git config --add -f .gitmodules submodule.subname.ignore all &&
1096 git config --add -f .gitmodules submodule.subname.path sm &&
1097 git status > output &&
1098 test_cmp expect output &&
1099 git config -f .gitmodules --remove-section submodule.subname
1100'
1101
aee9c7d6 1102test_expect_failure '.git/config ignore=all suppresses submodule summary' '
302ad7a9
JL
1103 git config --add -f .gitmodules submodule.subname.ignore none &&
1104 git config --add -f .gitmodules submodule.subname.path sm &&
aee9c7d6
JL
1105 git config --add submodule.subname.ignore all &&
1106 git config --add submodule.subname.path sm &&
1107 git status > output &&
1108 test_cmp expect output &&
302ad7a9
JL
1109 git config --remove-section submodule.subname &&
1110 git config -f .gitmodules --remove-section submodule.subname
aee9c7d6
JL
1111'
1112
367c9886 1113test_done