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