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