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