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