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