dir: fix treatment of negated pathspecs
[git/raj.git] / t / t7512-status-help.sh
blob66d7a627972615f86e805dbc52a178e36fd12616
1 #!/bin/sh
3 # Copyright (c) 2012 Valentin Duperray, Lucien Kong, Franck Jonas,
4 # Thomas Nguy, Khoi Nguyen
5 # Grenoble INP Ensimag
8 test_description='git status advice'
10 . ./test-lib.sh
12 . "$TEST_DIRECTORY"/lib-rebase.sh
14 set_fake_editor
16 test_expect_success 'prepare for conflicts' '
17 git config --global advice.statusuoption false &&
18 test_commit init main.txt init &&
19 git branch conflicts &&
20 test_commit on_master main.txt on_master &&
21 git checkout conflicts &&
22 test_commit on_conflicts main.txt on_conflicts
26 test_expect_success 'status when conflicts unresolved' '
27 test_must_fail git merge master &&
28 cat >expected <<\EOF &&
29 On branch conflicts
30 You have unmerged paths.
31 (fix conflicts and run "git commit")
32 (use "git merge --abort" to abort the merge)
34 Unmerged paths:
35 (use "git add <file>..." to mark resolution)
36 both modified: main.txt
38 no changes added to commit (use "git add" and/or "git commit -a")
39 EOF
40 git status --untracked-files=no >actual &&
41 test_i18ncmp expected actual
45 test_expect_success 'status when conflicts resolved before commit' '
46 git reset --hard conflicts &&
47 test_must_fail git merge master &&
48 echo one >main.txt &&
49 git add main.txt &&
50 cat >expected <<\EOF &&
51 On branch conflicts
52 All conflicts fixed but you are still merging.
53 (use "git commit" to conclude merge)
55 Changes to be committed:
56 modified: main.txt
58 Untracked files not listed (use -u option to show untracked files)
59 EOF
60 git status --untracked-files=no >actual &&
61 test_i18ncmp expected actual
65 test_expect_success 'prepare for rebase conflicts' '
66 git reset --hard master &&
67 git checkout -b rebase_conflicts &&
68 test_commit one_rebase main.txt one &&
69 test_commit two_rebase main.txt two &&
70 test_commit three_rebase main.txt three
74 test_expect_success 'status when rebase in progress before resolving conflicts' '
75 test_when_finished "git rebase --abort" &&
76 ONTO=$(git rev-parse --short HEAD^^) &&
77 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
78 cat >expected <<EOF &&
79 rebase in progress; onto $ONTO
80 You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
81 (fix conflicts and then run "git rebase --continue")
82 (use "git rebase --skip" to skip this patch)
83 (use "git rebase --abort" to check out the original branch)
85 Unmerged paths:
86 (use "git restore --staged <file>..." to unstage)
87 (use "git add <file>..." to mark resolution)
88 both modified: main.txt
90 no changes added to commit (use "git add" and/or "git commit -a")
91 EOF
92 git status --untracked-files=no >actual &&
93 test_i18ncmp expected actual
97 test_expect_success 'status when rebase in progress before rebase --continue' '
98 git reset --hard rebase_conflicts &&
99 test_when_finished "git rebase --abort" &&
100 ONTO=$(git rev-parse --short HEAD^^) &&
101 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
102 echo three >main.txt &&
103 git add main.txt &&
104 cat >expected <<EOF &&
105 rebase in progress; onto $ONTO
106 You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
107 (all conflicts fixed: run "git rebase --continue")
109 Changes to be committed:
110 (use "git restore --staged <file>..." to unstage)
111 modified: main.txt
113 Untracked files not listed (use -u option to show untracked files)
115 git status --untracked-files=no >actual &&
116 test_i18ncmp expected actual
120 test_expect_success 'prepare for rebase_i_conflicts' '
121 git reset --hard master &&
122 git checkout -b rebase_i_conflicts &&
123 test_commit one_unmerge main.txt one_unmerge &&
124 git branch rebase_i_conflicts_second &&
125 test_commit one_master main.txt one_master &&
126 git checkout rebase_i_conflicts_second &&
127 test_commit one_second main.txt one_second
131 test_expect_success 'status during rebase -i when conflicts unresolved' '
132 test_when_finished "git rebase --abort" &&
133 ONTO=$(git rev-parse --short rebase_i_conflicts) &&
134 LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) &&
135 test_must_fail git rebase -i rebase_i_conflicts &&
136 cat >expected <<EOF &&
137 interactive rebase in progress; onto $ONTO
138 Last command done (1 command done):
139 pick $LAST_COMMIT one_second
140 No commands remaining.
141 You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
142 (fix conflicts and then run "git rebase --continue")
143 (use "git rebase --skip" to skip this patch)
144 (use "git rebase --abort" to check out the original branch)
146 Unmerged paths:
147 (use "git restore --staged <file>..." to unstage)
148 (use "git add <file>..." to mark resolution)
149 both modified: main.txt
151 no changes added to commit (use "git add" and/or "git commit -a")
153 git status --untracked-files=no >actual &&
154 test_i18ncmp expected actual
158 test_expect_success 'status during rebase -i after resolving conflicts' '
159 git reset --hard rebase_i_conflicts_second &&
160 test_when_finished "git rebase --abort" &&
161 ONTO=$(git rev-parse --short rebase_i_conflicts) &&
162 LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) &&
163 test_must_fail git rebase -i rebase_i_conflicts &&
164 git add main.txt &&
165 cat >expected <<EOF &&
166 interactive rebase in progress; onto $ONTO
167 Last command done (1 command done):
168 pick $LAST_COMMIT one_second
169 No commands remaining.
170 You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
171 (all conflicts fixed: run "git rebase --continue")
173 Changes to be committed:
174 (use "git restore --staged <file>..." to unstage)
175 modified: main.txt
177 Untracked files not listed (use -u option to show untracked files)
179 git status --untracked-files=no >actual &&
180 test_i18ncmp expected actual
184 test_expect_success 'status when rebasing -i in edit mode' '
185 git reset --hard master &&
186 git checkout -b rebase_i_edit &&
187 test_commit one_rebase_i main.txt one &&
188 test_commit two_rebase_i main.txt two &&
189 COMMIT2=$(git rev-parse --short rebase_i_edit) &&
190 test_commit three_rebase_i main.txt three &&
191 COMMIT3=$(git rev-parse --short rebase_i_edit) &&
192 FAKE_LINES="1 edit 2" &&
193 export FAKE_LINES &&
194 test_when_finished "git rebase --abort" &&
195 ONTO=$(git rev-parse --short HEAD~2) &&
196 git rebase -i HEAD~2 &&
197 cat >expected <<EOF &&
198 interactive rebase in progress; onto $ONTO
199 Last commands done (2 commands done):
200 pick $COMMIT2 two_rebase_i
201 edit $COMMIT3 three_rebase_i
202 No commands remaining.
203 You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
204 (use "git commit --amend" to amend the current commit)
205 (use "git rebase --continue" once you are satisfied with your changes)
207 nothing to commit (use -u to show untracked files)
209 git status --untracked-files=no >actual &&
210 test_i18ncmp expected actual
214 test_expect_success 'status when splitting a commit' '
215 git reset --hard master &&
216 git checkout -b split_commit &&
217 test_commit one_split main.txt one &&
218 test_commit two_split main.txt two &&
219 COMMIT2=$(git rev-parse --short split_commit) &&
220 test_commit three_split main.txt three &&
221 COMMIT3=$(git rev-parse --short split_commit) &&
222 test_commit four_split main.txt four &&
223 COMMIT4=$(git rev-parse --short split_commit) &&
224 FAKE_LINES="1 edit 2 3" &&
225 export FAKE_LINES &&
226 test_when_finished "git rebase --abort" &&
227 ONTO=$(git rev-parse --short HEAD~3) &&
228 git rebase -i HEAD~3 &&
229 git reset HEAD^ &&
230 cat >expected <<EOF &&
231 interactive rebase in progress; onto $ONTO
232 Last commands done (2 commands done):
233 pick $COMMIT2 two_split
234 edit $COMMIT3 three_split
235 Next command to do (1 remaining command):
236 pick $COMMIT4 four_split
237 (use "git rebase --edit-todo" to view and edit)
238 You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
239 (Once your working directory is clean, run "git rebase --continue")
241 Changes not staged for commit:
242 (use "git add <file>..." to update what will be committed)
243 (use "git restore <file>..." to discard changes in working directory)
244 modified: main.txt
246 no changes added to commit (use "git add" and/or "git commit -a")
248 git status --untracked-files=no >actual &&
249 test_i18ncmp expected actual
253 test_expect_success 'status after editing the last commit with --amend during a rebase -i' '
254 git reset --hard master &&
255 git checkout -b amend_last &&
256 test_commit one_amend main.txt one &&
257 test_commit two_amend main.txt two &&
258 test_commit three_amend main.txt three &&
259 COMMIT3=$(git rev-parse --short amend_last) &&
260 test_commit four_amend main.txt four &&
261 COMMIT4=$(git rev-parse --short amend_last) &&
262 FAKE_LINES="1 2 edit 3" &&
263 export FAKE_LINES &&
264 test_when_finished "git rebase --abort" &&
265 ONTO=$(git rev-parse --short HEAD~3) &&
266 git rebase -i HEAD~3 &&
267 git commit --amend -m "foo" &&
268 cat >expected <<EOF &&
269 interactive rebase in progress; onto $ONTO
270 Last commands done (3 commands done):
271 pick $COMMIT3 three_amend
272 edit $COMMIT4 four_amend
273 (see more in file .git/rebase-merge/done)
274 No commands remaining.
275 You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
276 (use "git commit --amend" to amend the current commit)
277 (use "git rebase --continue" once you are satisfied with your changes)
279 nothing to commit (use -u to show untracked files)
281 git status --untracked-files=no >actual &&
282 test_i18ncmp expected actual
286 test_expect_success 'prepare for several edits' '
287 git reset --hard master &&
288 git checkout -b several_edits &&
289 test_commit one_edits main.txt one &&
290 test_commit two_edits main.txt two &&
291 test_commit three_edits main.txt three &&
292 test_commit four_edits main.txt four
296 test_expect_success 'status: (continue first edit) second edit' '
297 FAKE_LINES="edit 1 edit 2 3" &&
298 export FAKE_LINES &&
299 test_when_finished "git rebase --abort" &&
300 COMMIT2=$(git rev-parse --short several_edits^^) &&
301 COMMIT3=$(git rev-parse --short several_edits^) &&
302 COMMIT4=$(git rev-parse --short several_edits) &&
303 ONTO=$(git rev-parse --short HEAD~3) &&
304 git rebase -i HEAD~3 &&
305 git rebase --continue &&
306 cat >expected <<EOF &&
307 interactive rebase in progress; onto $ONTO
308 Last commands done (2 commands done):
309 edit $COMMIT2 two_edits
310 edit $COMMIT3 three_edits
311 Next command to do (1 remaining command):
312 pick $COMMIT4 four_edits
313 (use "git rebase --edit-todo" to view and edit)
314 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
315 (use "git commit --amend" to amend the current commit)
316 (use "git rebase --continue" once you are satisfied with your changes)
318 nothing to commit (use -u to show untracked files)
320 git status --untracked-files=no >actual &&
321 test_i18ncmp expected actual
325 test_expect_success 'status: (continue first edit) second edit and split' '
326 git reset --hard several_edits &&
327 FAKE_LINES="edit 1 edit 2 3" &&
328 export FAKE_LINES &&
329 test_when_finished "git rebase --abort" &&
330 COMMIT2=$(git rev-parse --short several_edits^^) &&
331 COMMIT3=$(git rev-parse --short several_edits^) &&
332 COMMIT4=$(git rev-parse --short several_edits) &&
333 ONTO=$(git rev-parse --short HEAD~3) &&
334 git rebase -i HEAD~3 &&
335 git rebase --continue &&
336 git reset HEAD^ &&
337 cat >expected <<EOF &&
338 interactive rebase in progress; onto $ONTO
339 Last commands done (2 commands done):
340 edit $COMMIT2 two_edits
341 edit $COMMIT3 three_edits
342 Next command to do (1 remaining command):
343 pick $COMMIT4 four_edits
344 (use "git rebase --edit-todo" to view and edit)
345 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
346 (Once your working directory is clean, run "git rebase --continue")
348 Changes not staged for commit:
349 (use "git add <file>..." to update what will be committed)
350 (use "git restore <file>..." to discard changes in working directory)
351 modified: main.txt
353 no changes added to commit (use "git add" and/or "git commit -a")
355 git status --untracked-files=no >actual &&
356 test_i18ncmp expected actual
360 test_expect_success 'status: (continue first edit) second edit and amend' '
361 git reset --hard several_edits &&
362 FAKE_LINES="edit 1 edit 2 3" &&
363 export FAKE_LINES &&
364 test_when_finished "git rebase --abort" &&
365 COMMIT2=$(git rev-parse --short several_edits^^) &&
366 COMMIT3=$(git rev-parse --short several_edits^) &&
367 COMMIT4=$(git rev-parse --short several_edits) &&
368 ONTO=$(git rev-parse --short HEAD~3) &&
369 git rebase -i HEAD~3 &&
370 git rebase --continue &&
371 git commit --amend -m "foo" &&
372 cat >expected <<EOF &&
373 interactive rebase in progress; onto $ONTO
374 Last commands done (2 commands done):
375 edit $COMMIT2 two_edits
376 edit $COMMIT3 three_edits
377 Next command to do (1 remaining command):
378 pick $COMMIT4 four_edits
379 (use "git rebase --edit-todo" to view and edit)
380 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
381 (use "git commit --amend" to amend the current commit)
382 (use "git rebase --continue" once you are satisfied with your changes)
384 nothing to commit (use -u to show untracked files)
386 git status --untracked-files=no >actual &&
387 test_i18ncmp expected actual
391 test_expect_success 'status: (amend first edit) second edit' '
392 git reset --hard several_edits &&
393 FAKE_LINES="edit 1 edit 2 3" &&
394 export FAKE_LINES &&
395 test_when_finished "git rebase --abort" &&
396 COMMIT2=$(git rev-parse --short several_edits^^) &&
397 COMMIT3=$(git rev-parse --short several_edits^) &&
398 COMMIT4=$(git rev-parse --short several_edits) &&
399 ONTO=$(git rev-parse --short HEAD~3) &&
400 git rebase -i HEAD~3 &&
401 git commit --amend -m "a" &&
402 git rebase --continue &&
403 cat >expected <<EOF &&
404 interactive rebase in progress; onto $ONTO
405 Last commands done (2 commands done):
406 edit $COMMIT2 two_edits
407 edit $COMMIT3 three_edits
408 Next command to do (1 remaining command):
409 pick $COMMIT4 four_edits
410 (use "git rebase --edit-todo" to view and edit)
411 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
412 (use "git commit --amend" to amend the current commit)
413 (use "git rebase --continue" once you are satisfied with your changes)
415 nothing to commit (use -u to show untracked files)
417 git status --untracked-files=no >actual &&
418 test_i18ncmp expected actual
422 test_expect_success 'status: (amend first edit) second edit and split' '
423 git reset --hard several_edits &&
424 FAKE_LINES="edit 1 edit 2 3" &&
425 export FAKE_LINES &&
426 test_when_finished "git rebase --abort" &&
427 ONTO=$(git rev-parse --short HEAD~3) &&
428 COMMIT2=$(git rev-parse --short several_edits^^) &&
429 COMMIT3=$(git rev-parse --short several_edits^) &&
430 COMMIT4=$(git rev-parse --short several_edits) &&
431 git rebase -i HEAD~3 &&
432 git commit --amend -m "b" &&
433 git rebase --continue &&
434 git reset HEAD^ &&
435 cat >expected <<EOF &&
436 interactive rebase in progress; onto $ONTO
437 Last commands done (2 commands done):
438 edit $COMMIT2 two_edits
439 edit $COMMIT3 three_edits
440 Next command to do (1 remaining command):
441 pick $COMMIT4 four_edits
442 (use "git rebase --edit-todo" to view and edit)
443 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
444 (Once your working directory is clean, run "git rebase --continue")
446 Changes not staged for commit:
447 (use "git add <file>..." to update what will be committed)
448 (use "git restore <file>..." to discard changes in working directory)
449 modified: main.txt
451 no changes added to commit (use "git add" and/or "git commit -a")
453 git status --untracked-files=no >actual &&
454 test_i18ncmp expected actual
458 test_expect_success 'status: (amend first edit) second edit and amend' '
459 git reset --hard several_edits &&
460 FAKE_LINES="edit 1 edit 2 3" &&
461 export FAKE_LINES &&
462 test_when_finished "git rebase --abort" &&
463 COMMIT2=$(git rev-parse --short several_edits^^) &&
464 COMMIT3=$(git rev-parse --short several_edits^) &&
465 COMMIT4=$(git rev-parse --short several_edits) &&
466 ONTO=$(git rev-parse --short HEAD~3) &&
467 git rebase -i HEAD~3 &&
468 git commit --amend -m "c" &&
469 git rebase --continue &&
470 git commit --amend -m "d" &&
471 cat >expected <<EOF &&
472 interactive rebase in progress; onto $ONTO
473 Last commands done (2 commands done):
474 edit $COMMIT2 two_edits
475 edit $COMMIT3 three_edits
476 Next command to do (1 remaining command):
477 pick $COMMIT4 four_edits
478 (use "git rebase --edit-todo" to view and edit)
479 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
480 (use "git commit --amend" to amend the current commit)
481 (use "git rebase --continue" once you are satisfied with your changes)
483 nothing to commit (use -u to show untracked files)
485 git status --untracked-files=no >actual &&
486 test_i18ncmp expected actual
490 test_expect_success 'status: (split first edit) second edit' '
491 git reset --hard several_edits &&
492 FAKE_LINES="edit 1 edit 2 3" &&
493 export FAKE_LINES &&
494 test_when_finished "git rebase --abort" &&
495 COMMIT2=$(git rev-parse --short several_edits^^) &&
496 COMMIT3=$(git rev-parse --short several_edits^) &&
497 COMMIT4=$(git rev-parse --short several_edits) &&
498 ONTO=$(git rev-parse --short HEAD~3) &&
499 git rebase -i HEAD~3 &&
500 git reset HEAD^ &&
501 git add main.txt &&
502 git commit -m "e" &&
503 git rebase --continue &&
504 cat >expected <<EOF &&
505 interactive rebase in progress; onto $ONTO
506 Last commands done (2 commands done):
507 edit $COMMIT2 two_edits
508 edit $COMMIT3 three_edits
509 Next command to do (1 remaining command):
510 pick $COMMIT4 four_edits
511 (use "git rebase --edit-todo" to view and edit)
512 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
513 (use "git commit --amend" to amend the current commit)
514 (use "git rebase --continue" once you are satisfied with your changes)
516 nothing to commit (use -u to show untracked files)
518 git status --untracked-files=no >actual &&
519 test_i18ncmp expected actual
523 test_expect_success 'status: (split first edit) second edit and split' '
524 git reset --hard several_edits &&
525 FAKE_LINES="edit 1 edit 2 3" &&
526 export FAKE_LINES &&
527 test_when_finished "git rebase --abort" &&
528 COMMIT2=$(git rev-parse --short several_edits^^) &&
529 COMMIT3=$(git rev-parse --short several_edits^) &&
530 COMMIT4=$(git rev-parse --short several_edits) &&
531 ONTO=$(git rev-parse --short HEAD~3) &&
532 git rebase -i HEAD~3 &&
533 git reset HEAD^ &&
534 git add main.txt &&
535 git commit --amend -m "f" &&
536 git rebase --continue &&
537 git reset HEAD^ &&
538 cat >expected <<EOF &&
539 interactive rebase in progress; onto $ONTO
540 Last commands done (2 commands done):
541 edit $COMMIT2 two_edits
542 edit $COMMIT3 three_edits
543 Next command to do (1 remaining command):
544 pick $COMMIT4 four_edits
545 (use "git rebase --edit-todo" to view and edit)
546 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
547 (Once your working directory is clean, run "git rebase --continue")
549 Changes not staged for commit:
550 (use "git add <file>..." to update what will be committed)
551 (use "git restore <file>..." to discard changes in working directory)
552 modified: main.txt
554 no changes added to commit (use "git add" and/or "git commit -a")
556 git status --untracked-files=no >actual &&
557 test_i18ncmp expected actual
561 test_expect_success 'status: (split first edit) second edit and amend' '
562 git reset --hard several_edits &&
563 FAKE_LINES="edit 1 edit 2 3" &&
564 export FAKE_LINES &&
565 test_when_finished "git rebase --abort" &&
566 COMMIT2=$(git rev-parse --short several_edits^^) &&
567 COMMIT3=$(git rev-parse --short several_edits^) &&
568 COMMIT4=$(git rev-parse --short several_edits) &&
569 ONTO=$(git rev-parse --short HEAD~3) &&
570 git rebase -i HEAD~3 &&
571 git reset HEAD^ &&
572 git add main.txt &&
573 git commit --amend -m "g" &&
574 git rebase --continue &&
575 git commit --amend -m "h" &&
576 cat >expected <<EOF &&
577 interactive rebase in progress; onto $ONTO
578 Last commands done (2 commands done):
579 edit $COMMIT2 two_edits
580 edit $COMMIT3 three_edits
581 Next command to do (1 remaining command):
582 pick $COMMIT4 four_edits
583 (use "git rebase --edit-todo" to view and edit)
584 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
585 (use "git commit --amend" to amend the current commit)
586 (use "git rebase --continue" once you are satisfied with your changes)
588 nothing to commit (use -u to show untracked files)
590 git status --untracked-files=no >actual &&
591 test_i18ncmp expected actual
595 test_expect_success 'prepare am_session' '
596 git reset --hard master &&
597 git checkout -b am_session &&
598 test_commit one_am one.txt "one" &&
599 test_commit two_am two.txt "two" &&
600 test_commit three_am three.txt "three"
604 test_expect_success 'status in an am session: file already exists' '
605 git checkout -b am_already_exists &&
606 test_when_finished "rm Maildir/* && git am --abort" &&
607 git format-patch -1 -oMaildir &&
608 test_must_fail git am Maildir/*.patch &&
609 cat >expected <<\EOF &&
610 On branch am_already_exists
611 You are in the middle of an am session.
612 (fix conflicts and then run "git am --continue")
613 (use "git am --skip" to skip this patch)
614 (use "git am --abort" to restore the original branch)
616 nothing to commit (use -u to show untracked files)
618 git status --untracked-files=no >actual &&
619 test_i18ncmp expected actual
623 test_expect_success 'status in an am session: file does not exist' '
624 git reset --hard am_session &&
625 git checkout -b am_not_exists &&
626 git rm three.txt &&
627 git commit -m "delete three.txt" &&
628 test_when_finished "rm Maildir/* && git am --abort" &&
629 git format-patch -1 -oMaildir &&
630 test_must_fail git am Maildir/*.patch &&
631 cat >expected <<\EOF &&
632 On branch am_not_exists
633 You are in the middle of an am session.
634 (fix conflicts and then run "git am --continue")
635 (use "git am --skip" to skip this patch)
636 (use "git am --abort" to restore the original branch)
638 nothing to commit (use -u to show untracked files)
640 git status --untracked-files=no >actual &&
641 test_i18ncmp expected actual
645 test_expect_success 'status in an am session: empty patch' '
646 git reset --hard am_session &&
647 git checkout -b am_empty &&
648 test_when_finished "rm Maildir/* && git am --abort" &&
649 git format-patch -3 -oMaildir &&
650 git rm one.txt two.txt three.txt &&
651 git commit -m "delete all am_empty" &&
652 echo error >Maildir/0002-two_am.patch &&
653 test_must_fail git am Maildir/*.patch &&
654 cat >expected <<\EOF &&
655 On branch am_empty
656 You are in the middle of an am session.
657 The current patch is empty.
658 (use "git am --skip" to skip this patch)
659 (use "git am --abort" to restore the original branch)
661 nothing to commit (use -u to show untracked files)
663 git status --untracked-files=no >actual &&
664 test_i18ncmp expected actual
668 test_expect_success 'status when bisecting' '
669 git reset --hard master &&
670 git checkout -b bisect &&
671 test_commit one_bisect main.txt one &&
672 test_commit two_bisect main.txt two &&
673 test_commit three_bisect main.txt three &&
674 test_when_finished "git bisect reset" &&
675 git bisect start &&
676 git bisect bad &&
677 git bisect good one_bisect &&
678 TGT=$(git rev-parse --short two_bisect) &&
679 cat >expected <<EOF &&
680 HEAD detached at $TGT
681 You are currently bisecting, started from branch '\''bisect'\''.
682 (use "git bisect reset" to get back to the original branch)
684 nothing to commit (use -u to show untracked files)
686 git status --untracked-files=no >actual &&
687 test_i18ncmp expected actual
691 test_expect_success 'status when rebase conflicts with statushints disabled' '
692 git reset --hard master &&
693 git checkout -b statushints_disabled &&
694 test_when_finished "git config --local advice.statushints true" &&
695 git config --local advice.statushints false &&
696 test_commit one_statushints main.txt one &&
697 test_commit two_statushints main.txt two &&
698 test_commit three_statushints main.txt three &&
699 test_when_finished "git rebase --abort" &&
700 ONTO=$(git rev-parse --short HEAD^^) &&
701 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
702 cat >expected <<EOF &&
703 rebase in progress; onto $ONTO
704 You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
706 Unmerged paths:
707 both modified: main.txt
709 no changes added to commit
711 git status --untracked-files=no >actual &&
712 test_i18ncmp expected actual
716 test_expect_success 'prepare for cherry-pick conflicts' '
717 git reset --hard master &&
718 git checkout -b cherry_branch &&
719 test_commit one_cherry main.txt one &&
720 test_commit two_cherries main.txt two &&
721 git checkout -b cherry_branch_second &&
722 test_commit second_cherry main.txt second &&
723 git checkout cherry_branch &&
724 test_commit three_cherries main.txt three
728 test_expect_success 'status when cherry-picking before resolving conflicts' '
729 test_when_finished "git cherry-pick --abort" &&
730 test_must_fail git cherry-pick cherry_branch_second &&
731 TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
732 cat >expected <<EOF &&
733 On branch cherry_branch
734 You are currently cherry-picking commit $TO_CHERRY_PICK.
735 (fix conflicts and run "git cherry-pick --continue")
736 (use "git cherry-pick --skip" to skip this patch)
737 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
739 Unmerged paths:
740 (use "git add <file>..." to mark resolution)
741 both modified: main.txt
743 no changes added to commit (use "git add" and/or "git commit -a")
745 git status --untracked-files=no >actual &&
746 test_i18ncmp expected actual
750 test_expect_success 'status when cherry-picking after resolving conflicts' '
751 git reset --hard cherry_branch &&
752 test_when_finished "git cherry-pick --abort" &&
753 test_must_fail git cherry-pick cherry_branch_second &&
754 TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
755 echo end >main.txt &&
756 git add main.txt &&
757 cat >expected <<EOF &&
758 On branch cherry_branch
759 You are currently cherry-picking commit $TO_CHERRY_PICK.
760 (all conflicts fixed: run "git cherry-pick --continue")
761 (use "git cherry-pick --skip" to skip this patch)
762 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
764 Changes to be committed:
765 modified: main.txt
767 Untracked files not listed (use -u option to show untracked files)
769 git status --untracked-files=no >actual &&
770 test_i18ncmp expected actual
773 test_expect_success 'status when cherry-picking after committing conflict resolution' '
774 git reset --hard cherry_branch &&
775 test_when_finished "git cherry-pick --abort" &&
776 test_must_fail git cherry-pick cherry_branch_second one_cherry &&
777 echo end >main.txt &&
778 git commit -a &&
779 cat >expected <<EOF &&
780 On branch cherry_branch
781 Cherry-pick currently in progress.
782 (run "git cherry-pick --continue" to continue)
783 (use "git cherry-pick --skip" to skip this patch)
784 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
786 nothing to commit (use -u to show untracked files)
788 git status --untracked-files=no >actual &&
789 test_i18ncmp expected actual
792 test_expect_success 'status shows cherry-pick with invalid oid' '
793 mkdir .git/sequencer &&
794 test_write_lines "pick invalid-oid" >.git/sequencer/todo &&
795 git status --untracked-files=no >actual 2>err &&
796 git cherry-pick --quit &&
797 test_must_be_empty err &&
798 test_i18ncmp expected actual
801 test_expect_success 'status does not show error if .git/sequencer is a file' '
802 test_when_finished "rm .git/sequencer" &&
803 test_write_lines hello >.git/sequencer &&
804 git status --untracked-files=no 2>err &&
805 test_must_be_empty err
808 test_expect_success 'status showing detached at and from a tag' '
809 test_commit atag tagging &&
810 git checkout atag &&
811 cat >expected <<\EOF &&
812 HEAD detached at atag
813 nothing to commit (use -u to show untracked files)
815 git status --untracked-files=no >actual &&
816 test_i18ncmp expected actual &&
818 git reset --hard HEAD^ &&
819 cat >expected <<\EOF &&
820 HEAD detached from atag
821 nothing to commit (use -u to show untracked files)
823 git status --untracked-files=no >actual &&
824 test_i18ncmp expected actual
827 test_expect_success 'status while reverting commit (conflicts)' '
828 git checkout master &&
829 echo before >to-revert.txt &&
830 test_commit before to-revert.txt &&
831 echo old >to-revert.txt &&
832 test_commit old to-revert.txt &&
833 echo new >to-revert.txt &&
834 test_commit new to-revert.txt &&
835 TO_REVERT=$(git rev-parse --short HEAD^) &&
836 test_must_fail git revert $TO_REVERT &&
837 cat >expected <<EOF &&
838 On branch master
839 You are currently reverting commit $TO_REVERT.
840 (fix conflicts and run "git revert --continue")
841 (use "git revert --skip" to skip this patch)
842 (use "git revert --abort" to cancel the revert operation)
844 Unmerged paths:
845 (use "git restore --staged <file>..." to unstage)
846 (use "git add <file>..." to mark resolution)
847 both modified: to-revert.txt
849 no changes added to commit (use "git add" and/or "git commit -a")
851 git status --untracked-files=no >actual &&
852 test_i18ncmp expected actual
855 test_expect_success 'status while reverting commit (conflicts resolved)' '
856 echo reverted >to-revert.txt &&
857 git add to-revert.txt &&
858 cat >expected <<EOF &&
859 On branch master
860 You are currently reverting commit $TO_REVERT.
861 (all conflicts fixed: run "git revert --continue")
862 (use "git revert --skip" to skip this patch)
863 (use "git revert --abort" to cancel the revert operation)
865 Changes to be committed:
866 (use "git restore --staged <file>..." to unstage)
867 modified: to-revert.txt
869 Untracked files not listed (use -u option to show untracked files)
871 git status --untracked-files=no >actual &&
872 test_i18ncmp expected actual
875 test_expect_success 'status after reverting commit' '
876 git revert --continue &&
877 cat >expected <<\EOF &&
878 On branch master
879 nothing to commit (use -u to show untracked files)
881 git status --untracked-files=no >actual &&
882 test_i18ncmp expected actual
885 test_expect_success 'status while reverting after committing conflict resolution' '
886 test_when_finished "git revert --abort" &&
887 git reset --hard new &&
888 test_must_fail git revert old new &&
889 echo reverted >to-revert.txt &&
890 git commit -a &&
891 cat >expected <<EOF &&
892 On branch master
893 Revert currently in progress.
894 (run "git revert --continue" to continue)
895 (use "git revert --skip" to skip this patch)
896 (use "git revert --abort" to cancel the revert operation)
898 nothing to commit (use -u to show untracked files)
900 git status --untracked-files=no >actual &&
901 test_i18ncmp expected actual
904 test_expect_success 'prepare for different number of commits rebased' '
905 git reset --hard master &&
906 git checkout -b several_commits &&
907 test_commit one_commit main.txt one &&
908 test_commit two_commit main.txt two &&
909 test_commit three_commit main.txt three &&
910 test_commit four_commit main.txt four
913 test_expect_success 'status: one command done nothing remaining' '
914 FAKE_LINES="exec_exit_15" &&
915 export FAKE_LINES &&
916 test_when_finished "git rebase --abort" &&
917 ONTO=$(git rev-parse --short HEAD~3) &&
918 test_must_fail git rebase -i HEAD~3 &&
919 cat >expected <<EOF &&
920 interactive rebase in progress; onto $ONTO
921 Last command done (1 command done):
922 exec exit 15
923 No commands remaining.
924 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
925 (use "git commit --amend" to amend the current commit)
926 (use "git rebase --continue" once you are satisfied with your changes)
928 nothing to commit (use -u to show untracked files)
930 git status --untracked-files=no >actual &&
931 test_i18ncmp expected actual
934 test_expect_success 'status: two commands done with some white lines in done file' '
935 FAKE_LINES="1 > exec_exit_15 2 3" &&
936 export FAKE_LINES &&
937 test_when_finished "git rebase --abort" &&
938 ONTO=$(git rev-parse --short HEAD~3) &&
939 COMMIT4=$(git rev-parse --short HEAD) &&
940 COMMIT3=$(git rev-parse --short HEAD^) &&
941 COMMIT2=$(git rev-parse --short HEAD^^) &&
942 test_must_fail git rebase -i HEAD~3 &&
943 cat >expected <<EOF &&
944 interactive rebase in progress; onto $ONTO
945 Last commands done (2 commands done):
946 pick $COMMIT2 two_commit
947 exec exit 15
948 Next commands to do (2 remaining commands):
949 pick $COMMIT3 three_commit
950 pick $COMMIT4 four_commit
951 (use "git rebase --edit-todo" to view and edit)
952 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
953 (use "git commit --amend" to amend the current commit)
954 (use "git rebase --continue" once you are satisfied with your changes)
956 nothing to commit (use -u to show untracked files)
958 git status --untracked-files=no >actual &&
959 test_i18ncmp expected actual
962 test_expect_success 'status: two remaining commands with some white lines in todo file' '
963 FAKE_LINES="1 2 exec_exit_15 3 > 4" &&
964 export FAKE_LINES &&
965 test_when_finished "git rebase --abort" &&
966 ONTO=$(git rev-parse --short HEAD~4) &&
967 COMMIT4=$(git rev-parse --short HEAD) &&
968 COMMIT3=$(git rev-parse --short HEAD^) &&
969 COMMIT2=$(git rev-parse --short HEAD^^) &&
970 test_must_fail git rebase -i HEAD~4 &&
971 cat >expected <<EOF &&
972 interactive rebase in progress; onto $ONTO
973 Last commands done (3 commands done):
974 pick $COMMIT2 two_commit
975 exec exit 15
976 (see more in file .git/rebase-merge/done)
977 Next commands to do (2 remaining commands):
978 pick $COMMIT3 three_commit
979 pick $COMMIT4 four_commit
980 (use "git rebase --edit-todo" to view and edit)
981 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
982 (use "git commit --amend" to amend the current commit)
983 (use "git rebase --continue" once you are satisfied with your changes)
985 nothing to commit (use -u to show untracked files)
987 git status --untracked-files=no >actual &&
988 test_i18ncmp expected actual
991 test_expect_success 'status: handle not-yet-started rebase -i gracefully' '
992 ONTO=$(git rev-parse --short HEAD^) &&
993 COMMIT=$(git rev-parse --short HEAD) &&
994 EDITOR="git status --untracked-files=no >actual" git rebase -i HEAD^ &&
995 cat >expected <<EOF &&
996 On branch several_commits
997 No commands done.
998 Next command to do (1 remaining command):
999 pick $COMMIT four_commit
1000 (use "git rebase --edit-todo" to view and edit)
1001 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
1002 (use "git commit --amend" to amend the current commit)
1003 (use "git rebase --continue" once you are satisfied with your changes)
1005 nothing to commit (use -u to show untracked files)
1007 test_i18ncmp expected actual
1010 test_done