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