3 # Copyright (c) 2012 Valentin Duperray, Lucien Kong, Franck Jonas,
4 # Thomas Nguy, Khoi Nguyen
8 test_description='git status advice'
12 . "$TEST_DIRECTORY"/lib-rebase.sh
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 &&
30 You have unmerged paths.
31 (fix conflicts and run "git commit")
32 (use "git merge --abort" to abort the merge)
35 (use "git add <file>..." to mark resolution)
37 both modified: main.txt
39 no changes added to commit (use "git add" and/or "git commit -a")
41 git status --untracked-files=no >actual &&
42 test_i18ncmp expected actual
46 test_expect_success 'status when conflicts resolved before commit' '
47 git reset --hard conflicts &&
48 test_must_fail git merge master &&
51 cat >expected <<\EOF &&
53 All conflicts fixed but you are still merging.
54 (use "git commit" to conclude merge)
56 Changes to be committed:
60 Untracked files not listed (use -u option to show untracked files)
62 git status --untracked-files=no >actual &&
63 test_i18ncmp expected actual
67 test_expect_success 'prepare for rebase conflicts' '
68 git reset --hard master &&
69 git checkout -b rebase_conflicts &&
70 test_commit one_rebase main.txt one &&
71 test_commit two_rebase main.txt two &&
72 test_commit three_rebase main.txt three
76 test_expect_success 'status when rebase in progress before resolving conflicts' '
77 ONTO=$(git rev-parse --short HEAD^^) &&
78 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
79 cat >expected <<EOF &&
80 rebase in progress; onto $ONTO
81 You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
82 (fix conflicts and then run "git rebase --continue")
83 (use "git rebase --skip" to skip this patch)
84 (use "git rebase --abort" to check out the original branch)
87 (use "git reset HEAD <file>..." to unstage)
88 (use "git add <file>..." to mark resolution)
90 both modified: main.txt
92 no changes added to commit (use "git add" and/or "git commit -a")
94 git status --untracked-files=no >actual &&
95 test_i18ncmp expected actual
98 test_expect_success 'short status when rebase in progress' '
99 test_when_finished "git rebase --abort" &&
100 cat >expected <<EOF &&
101 ## HEAD (no branch); REBASE-m
104 git status --untracked-files=no --short --branch --in-progress >actual &&
105 test_i18ncmp expected actual
108 test_expect_success 'status when rebase in progress before rebase --continue' '
109 git reset --hard rebase_conflicts &&
110 test_when_finished "git rebase --abort" &&
111 ONTO=$(git rev-parse --short HEAD^^) &&
112 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
113 echo three >main.txt &&
115 cat >expected <<EOF &&
116 rebase in progress; onto $ONTO
117 You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
118 (all conflicts fixed: run "git rebase --continue")
120 Changes to be committed:
121 (use "git reset HEAD <file>..." to unstage)
125 Untracked files not listed (use -u option to show untracked files)
127 git status --untracked-files=no >actual &&
128 test_i18ncmp expected actual
132 test_expect_success 'prepare for rebase_i_conflicts' '
133 git reset --hard master &&
134 git checkout -b rebase_i_conflicts &&
135 test_commit one_unmerge main.txt one_unmerge &&
136 git branch rebase_i_conflicts_second &&
137 test_commit one_master main.txt one_master &&
138 git checkout rebase_i_conflicts_second &&
139 test_commit one_second main.txt one_second
143 test_expect_success 'status during rebase -i when conflicts unresolved' '
144 ONTO=$(git rev-parse --short rebase_i_conflicts) &&
145 LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) &&
146 test_must_fail git rebase -i rebase_i_conflicts &&
147 cat >expected <<EOF &&
148 interactive rebase in progress; onto $ONTO
149 Last command done (1 command done):
150 pick $LAST_COMMIT one_second
151 No commands remaining.
152 You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
153 (fix conflicts and then run "git rebase --continue")
154 (use "git rebase --skip" to skip this patch)
155 (use "git rebase --abort" to check out the original branch)
158 (use "git reset HEAD <file>..." to unstage)
159 (use "git add <file>..." to mark resolution)
161 both modified: main.txt
163 no changes added to commit (use "git add" and/or "git commit -a")
165 git status --untracked-files=no >actual &&
166 test_i18ncmp expected actual
169 test_expect_success 'short status during rebase -i when conflicts unresolved' '
170 test_when_finished "git rebase --abort" &&
171 cat >expected <<EOF &&
172 ## HEAD (no branch); REBASE-i
175 git status --untracked-files=no --short --branch --in-progress >actual &&
176 test_i18ncmp expected actual
180 test_expect_success 'status during rebase -i after resolving conflicts' '
181 git reset --hard rebase_i_conflicts_second &&
182 test_when_finished "git rebase --abort" &&
183 ONTO=$(git rev-parse --short rebase_i_conflicts) &&
184 LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) &&
185 test_must_fail git rebase -i rebase_i_conflicts &&
187 cat >expected <<EOF &&
188 interactive rebase in progress; onto $ONTO
189 Last command done (1 command done):
190 pick $LAST_COMMIT one_second
191 No commands remaining.
192 You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
193 (all conflicts fixed: run "git rebase --continue")
195 Changes to be committed:
196 (use "git reset HEAD <file>..." to unstage)
200 Untracked files not listed (use -u option to show untracked files)
202 git status --untracked-files=no >actual &&
203 test_i18ncmp expected actual
207 test_expect_success 'status when rebasing -i in edit mode' '
208 git reset --hard master &&
209 git checkout -b rebase_i_edit &&
210 test_commit one_rebase_i main.txt one &&
211 test_commit two_rebase_i main.txt two &&
212 COMMIT2=$(git rev-parse --short rebase_i_edit) &&
213 test_commit three_rebase_i main.txt three &&
214 COMMIT3=$(git rev-parse --short rebase_i_edit) &&
215 FAKE_LINES="1 edit 2" &&
217 test_when_finished "git rebase --abort" &&
218 ONTO=$(git rev-parse --short HEAD~2) &&
219 git rebase -i HEAD~2 &&
220 cat >expected <<EOF &&
221 interactive rebase in progress; onto $ONTO
222 Last commands done (2 commands done):
223 pick $COMMIT2 two_rebase_i
224 edit $COMMIT3 three_rebase_i
225 No commands remaining.
226 You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
227 (use "git commit --amend" to amend the current commit)
228 (use "git rebase --continue" once you are satisfied with your changes)
230 nothing to commit (use -u to show untracked files)
232 git status --untracked-files=no >actual &&
233 test_i18ncmp expected actual
237 test_expect_success 'status when splitting a commit' '
238 git reset --hard master &&
239 git checkout -b split_commit &&
240 test_commit one_split main.txt one &&
241 test_commit two_split main.txt two &&
242 COMMIT2=$(git rev-parse --short split_commit) &&
243 test_commit three_split main.txt three &&
244 COMMIT3=$(git rev-parse --short split_commit) &&
245 test_commit four_split main.txt four &&
246 COMMIT4=$(git rev-parse --short split_commit) &&
247 FAKE_LINES="1 edit 2 3" &&
249 test_when_finished "git rebase --abort" &&
250 ONTO=$(git rev-parse --short HEAD~3) &&
251 git rebase -i HEAD~3 &&
253 cat >expected <<EOF &&
254 interactive rebase in progress; onto $ONTO
255 Last commands done (2 commands done):
256 pick $COMMIT2 two_split
257 edit $COMMIT3 three_split
258 Next command to do (1 remaining command):
259 pick $COMMIT4 four_split
260 (use "git rebase --edit-todo" to view and edit)
261 You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
262 (Once your working directory is clean, run "git rebase --continue")
264 Changes not staged for commit:
265 (use "git add <file>..." to update what will be committed)
266 (use "git checkout -- <file>..." to discard changes in working directory)
270 no changes added to commit (use "git add" and/or "git commit -a")
272 git status --untracked-files=no >actual &&
273 test_i18ncmp expected actual
277 test_expect_success 'status after editing the last commit with --amend during a rebase -i' '
278 git reset --hard master &&
279 git checkout -b amend_last &&
280 test_commit one_amend main.txt one &&
281 test_commit two_amend main.txt two &&
282 test_commit three_amend main.txt three &&
283 COMMIT3=$(git rev-parse --short amend_last) &&
284 test_commit four_amend main.txt four &&
285 COMMIT4=$(git rev-parse --short amend_last) &&
286 FAKE_LINES="1 2 edit 3" &&
288 test_when_finished "git rebase --abort" &&
289 ONTO=$(git rev-parse --short HEAD~3) &&
290 git rebase -i HEAD~3 &&
291 git commit --amend -m "foo" &&
292 cat >expected <<EOF &&
293 interactive rebase in progress; onto $ONTO
294 Last commands done (3 commands done):
295 pick $COMMIT3 three_amend
296 edit $COMMIT4 four_amend
297 (see more in file .git/rebase-merge/done)
298 No commands remaining.
299 You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
300 (use "git commit --amend" to amend the current commit)
301 (use "git rebase --continue" once you are satisfied with your changes)
303 nothing to commit (use -u to show untracked files)
305 git status --untracked-files=no >actual &&
306 test_i18ncmp expected actual
310 test_expect_success 'prepare for several edits' '
311 git reset --hard master &&
312 git checkout -b several_edits &&
313 test_commit one_edits main.txt one &&
314 test_commit two_edits main.txt two &&
315 test_commit three_edits main.txt three &&
316 test_commit four_edits main.txt four
320 test_expect_success 'status: (continue first edit) second edit' '
321 FAKE_LINES="edit 1 edit 2 3" &&
323 test_when_finished "git rebase --abort" &&
324 COMMIT2=$(git rev-parse --short several_edits^^) &&
325 COMMIT3=$(git rev-parse --short several_edits^) &&
326 COMMIT4=$(git rev-parse --short several_edits) &&
327 ONTO=$(git rev-parse --short HEAD~3) &&
328 git rebase -i HEAD~3 &&
329 git rebase --continue &&
330 cat >expected <<EOF &&
331 interactive rebase in progress; onto $ONTO
332 Last commands done (2 commands done):
333 edit $COMMIT2 two_edits
334 edit $COMMIT3 three_edits
335 Next command to do (1 remaining command):
336 pick $COMMIT4 four_edits
337 (use "git rebase --edit-todo" to view and edit)
338 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
339 (use "git commit --amend" to amend the current commit)
340 (use "git rebase --continue" once you are satisfied with your changes)
342 nothing to commit (use -u to show untracked files)
344 git status --untracked-files=no >actual &&
345 test_i18ncmp expected actual
349 test_expect_success 'status: (continue first edit) second edit and split' '
350 git reset --hard several_edits &&
351 FAKE_LINES="edit 1 edit 2 3" &&
353 test_when_finished "git rebase --abort" &&
354 COMMIT2=$(git rev-parse --short several_edits^^) &&
355 COMMIT3=$(git rev-parse --short several_edits^) &&
356 COMMIT4=$(git rev-parse --short several_edits) &&
357 ONTO=$(git rev-parse --short HEAD~3) &&
358 git rebase -i HEAD~3 &&
359 git rebase --continue &&
361 cat >expected <<EOF &&
362 interactive rebase in progress; onto $ONTO
363 Last commands done (2 commands done):
364 edit $COMMIT2 two_edits
365 edit $COMMIT3 three_edits
366 Next command to do (1 remaining command):
367 pick $COMMIT4 four_edits
368 (use "git rebase --edit-todo" to view and edit)
369 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
370 (Once your working directory is clean, run "git rebase --continue")
372 Changes not staged for commit:
373 (use "git add <file>..." to update what will be committed)
374 (use "git checkout -- <file>..." to discard changes in working directory)
378 no changes added to commit (use "git add" and/or "git commit -a")
380 git status --untracked-files=no >actual &&
381 test_i18ncmp expected actual
385 test_expect_success 'status: (continue first edit) second edit and amend' '
386 git reset --hard several_edits &&
387 FAKE_LINES="edit 1 edit 2 3" &&
389 test_when_finished "git rebase --abort" &&
390 COMMIT2=$(git rev-parse --short several_edits^^) &&
391 COMMIT3=$(git rev-parse --short several_edits^) &&
392 COMMIT4=$(git rev-parse --short several_edits) &&
393 ONTO=$(git rev-parse --short HEAD~3) &&
394 git rebase -i HEAD~3 &&
395 git rebase --continue &&
396 git commit --amend -m "foo" &&
397 cat >expected <<EOF &&
398 interactive rebase in progress; onto $ONTO
399 Last commands done (2 commands done):
400 edit $COMMIT2 two_edits
401 edit $COMMIT3 three_edits
402 Next command to do (1 remaining command):
403 pick $COMMIT4 four_edits
404 (use "git rebase --edit-todo" to view and edit)
405 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
406 (use "git commit --amend" to amend the current commit)
407 (use "git rebase --continue" once you are satisfied with your changes)
409 nothing to commit (use -u to show untracked files)
411 git status --untracked-files=no >actual &&
412 test_i18ncmp expected actual
416 test_expect_success 'status: (amend first edit) second edit' '
417 git reset --hard several_edits &&
418 FAKE_LINES="edit 1 edit 2 3" &&
420 test_when_finished "git rebase --abort" &&
421 COMMIT2=$(git rev-parse --short several_edits^^) &&
422 COMMIT3=$(git rev-parse --short several_edits^) &&
423 COMMIT4=$(git rev-parse --short several_edits) &&
424 ONTO=$(git rev-parse --short HEAD~3) &&
425 git rebase -i HEAD~3 &&
426 git commit --amend -m "a" &&
427 git rebase --continue &&
428 cat >expected <<EOF &&
429 interactive rebase in progress; onto $ONTO
430 Last commands done (2 commands done):
431 edit $COMMIT2 two_edits
432 edit $COMMIT3 three_edits
433 Next command to do (1 remaining command):
434 pick $COMMIT4 four_edits
435 (use "git rebase --edit-todo" to view and edit)
436 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
437 (use "git commit --amend" to amend the current commit)
438 (use "git rebase --continue" once you are satisfied with your changes)
440 nothing to commit (use -u to show untracked files)
442 git status --untracked-files=no >actual &&
443 test_i18ncmp expected actual
447 test_expect_success 'status: (amend first edit) second edit and split' '
448 git reset --hard several_edits &&
449 FAKE_LINES="edit 1 edit 2 3" &&
451 test_when_finished "git rebase --abort" &&
452 ONTO=$(git rev-parse --short HEAD~3) &&
453 COMMIT2=$(git rev-parse --short several_edits^^) &&
454 COMMIT3=$(git rev-parse --short several_edits^) &&
455 COMMIT4=$(git rev-parse --short several_edits) &&
456 git rebase -i HEAD~3 &&
457 git commit --amend -m "b" &&
458 git rebase --continue &&
460 cat >expected <<EOF &&
461 interactive rebase in progress; onto $ONTO
462 Last commands done (2 commands done):
463 edit $COMMIT2 two_edits
464 edit $COMMIT3 three_edits
465 Next command to do (1 remaining command):
466 pick $COMMIT4 four_edits
467 (use "git rebase --edit-todo" to view and edit)
468 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
469 (Once your working directory is clean, run "git rebase --continue")
471 Changes not staged for commit:
472 (use "git add <file>..." to update what will be committed)
473 (use "git checkout -- <file>..." to discard changes in working directory)
477 no changes added to commit (use "git add" and/or "git commit -a")
479 git status --untracked-files=no >actual &&
480 test_i18ncmp expected actual
484 test_expect_success 'status: (amend first edit) second edit and amend' '
485 git reset --hard several_edits &&
486 FAKE_LINES="edit 1 edit 2 3" &&
488 test_when_finished "git rebase --abort" &&
489 COMMIT2=$(git rev-parse --short several_edits^^) &&
490 COMMIT3=$(git rev-parse --short several_edits^) &&
491 COMMIT4=$(git rev-parse --short several_edits) &&
492 ONTO=$(git rev-parse --short HEAD~3) &&
493 git rebase -i HEAD~3 &&
494 git commit --amend -m "c" &&
495 git rebase --continue &&
496 git commit --amend -m "d" &&
497 cat >expected <<EOF &&
498 interactive rebase in progress; onto $ONTO
499 Last commands done (2 commands done):
500 edit $COMMIT2 two_edits
501 edit $COMMIT3 three_edits
502 Next command to do (1 remaining command):
503 pick $COMMIT4 four_edits
504 (use "git rebase --edit-todo" to view and edit)
505 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
506 (use "git commit --amend" to amend the current commit)
507 (use "git rebase --continue" once you are satisfied with your changes)
509 nothing to commit (use -u to show untracked files)
511 git status --untracked-files=no >actual &&
512 test_i18ncmp expected actual
516 test_expect_success 'status: (split first edit) second edit' '
517 git reset --hard several_edits &&
518 FAKE_LINES="edit 1 edit 2 3" &&
520 test_when_finished "git rebase --abort" &&
521 COMMIT2=$(git rev-parse --short several_edits^^) &&
522 COMMIT3=$(git rev-parse --short several_edits^) &&
523 COMMIT4=$(git rev-parse --short several_edits) &&
524 ONTO=$(git rev-parse --short HEAD~3) &&
525 git rebase -i HEAD~3 &&
529 git rebase --continue &&
530 cat >expected <<EOF &&
531 interactive rebase in progress; onto $ONTO
532 Last commands done (2 commands done):
533 edit $COMMIT2 two_edits
534 edit $COMMIT3 three_edits
535 Next command to do (1 remaining command):
536 pick $COMMIT4 four_edits
537 (use "git rebase --edit-todo" to view and edit)
538 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
539 (use "git commit --amend" to amend the current commit)
540 (use "git rebase --continue" once you are satisfied with your changes)
542 nothing to commit (use -u to show untracked files)
544 git status --untracked-files=no >actual &&
545 test_i18ncmp expected actual
549 test_expect_success 'status: (split first edit) second edit and split' '
550 git reset --hard several_edits &&
551 FAKE_LINES="edit 1 edit 2 3" &&
553 test_when_finished "git rebase --abort" &&
554 COMMIT2=$(git rev-parse --short several_edits^^) &&
555 COMMIT3=$(git rev-parse --short several_edits^) &&
556 COMMIT4=$(git rev-parse --short several_edits) &&
557 ONTO=$(git rev-parse --short HEAD~3) &&
558 git rebase -i HEAD~3 &&
561 git commit --amend -m "f" &&
562 git rebase --continue &&
564 cat >expected <<EOF &&
565 interactive rebase in progress; onto $ONTO
566 Last commands done (2 commands done):
567 edit $COMMIT2 two_edits
568 edit $COMMIT3 three_edits
569 Next command to do (1 remaining command):
570 pick $COMMIT4 four_edits
571 (use "git rebase --edit-todo" to view and edit)
572 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
573 (Once your working directory is clean, run "git rebase --continue")
575 Changes not staged for commit:
576 (use "git add <file>..." to update what will be committed)
577 (use "git checkout -- <file>..." to discard changes in working directory)
581 no changes added to commit (use "git add" and/or "git commit -a")
583 git status --untracked-files=no >actual &&
584 test_i18ncmp expected actual
588 test_expect_success 'status: (split first edit) second edit and amend' '
589 git reset --hard several_edits &&
590 FAKE_LINES="edit 1 edit 2 3" &&
592 test_when_finished "git rebase --abort" &&
593 COMMIT2=$(git rev-parse --short several_edits^^) &&
594 COMMIT3=$(git rev-parse --short several_edits^) &&
595 COMMIT4=$(git rev-parse --short several_edits) &&
596 ONTO=$(git rev-parse --short HEAD~3) &&
597 git rebase -i HEAD~3 &&
600 git commit --amend -m "g" &&
601 git rebase --continue &&
602 git commit --amend -m "h" &&
603 cat >expected <<EOF &&
604 interactive rebase in progress; onto $ONTO
605 Last commands done (2 commands done):
606 edit $COMMIT2 two_edits
607 edit $COMMIT3 three_edits
608 Next command to do (1 remaining command):
609 pick $COMMIT4 four_edits
610 (use "git rebase --edit-todo" to view and edit)
611 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
612 (use "git commit --amend" to amend the current commit)
613 (use "git rebase --continue" once you are satisfied with your changes)
615 nothing to commit (use -u to show untracked files)
617 git status --untracked-files=no >actual &&
618 test_i18ncmp expected actual
622 test_expect_success 'prepare am_session' '
623 git reset --hard master &&
624 git checkout -b am_session &&
625 test_commit one_am one.txt "one" &&
626 test_commit two_am two.txt "two" &&
627 test_commit three_am three.txt "three"
631 test_expect_success 'status in an am session: file already exists' '
632 git checkout -b am_already_exists &&
633 git format-patch -1 -oMaildir &&
634 test_must_fail git am Maildir/*.patch &&
635 cat >expected <<\EOF &&
636 On branch am_already_exists
637 You are in the middle of an am session.
638 (fix conflicts and then run "git am --continue")
639 (use "git am --skip" to skip this patch)
640 (use "git am --abort" to restore the original branch)
642 nothing to commit (use -u to show untracked files)
644 git status --untracked-files=no >actual &&
645 test_i18ncmp expected actual
648 test_expect_success 'short status in an am session: file already exists' '
649 test_when_finished "rm Maildir/* && git am --abort" &&
650 cat >expected <<\EOF &&
651 ## am_already_exists; AM
653 git status --untracked-files=no --short --branch --in-progress >actual &&
654 test_i18ncmp expected actual
657 test_expect_success 'status in an am session: file does not exist' '
658 git reset --hard am_session &&
659 git checkout -b am_not_exists &&
661 git commit -m "delete three.txt" &&
662 test_when_finished "rm Maildir/* && git am --abort" &&
663 git format-patch -1 -oMaildir &&
664 test_must_fail git am Maildir/*.patch &&
665 cat >expected <<\EOF &&
666 On branch am_not_exists
667 You are in the middle of an am session.
668 (fix conflicts and then run "git am --continue")
669 (use "git am --skip" to skip this patch)
670 (use "git am --abort" to restore the original branch)
672 nothing to commit (use -u to show untracked files)
674 git status --untracked-files=no >actual &&
675 test_i18ncmp expected actual
679 test_expect_success 'status in an am session: empty patch' '
680 git reset --hard am_session &&
681 git checkout -b am_empty &&
682 test_when_finished "rm Maildir/* && git am --abort" &&
683 git format-patch -3 -oMaildir &&
684 git rm one.txt two.txt three.txt &&
685 git commit -m "delete all am_empty" &&
686 echo error >Maildir/0002-two_am.patch &&
687 test_must_fail git am Maildir/*.patch &&
688 cat >expected <<\EOF &&
690 You are in the middle of an am session.
691 The current patch is empty.
692 (use "git am --skip" to skip this patch)
693 (use "git am --abort" to restore the original branch)
695 nothing to commit (use -u to show untracked files)
697 git status --untracked-files=no >actual &&
698 test_i18ncmp expected actual
702 test_expect_success 'status when bisecting' '
703 git reset --hard master &&
704 git checkout -b bisect &&
705 test_commit one_bisect main.txt one &&
706 test_commit two_bisect main.txt two &&
707 test_commit three_bisect main.txt three &&
710 git bisect good one_bisect &&
711 TGT=$(git rev-parse --short two_bisect) &&
712 cat >expected <<EOF &&
713 HEAD detached at $TGT
714 You are currently bisecting, started from branch '\''bisect'\''.
715 (use "git bisect reset" to get back to the original branch)
717 nothing to commit (use -u to show untracked files)
719 git status --untracked-files=no >actual &&
720 test_i18ncmp expected actual
723 test_expect_success 'short status when bisecting' '
724 test_when_finished "git bisect reset" &&
725 cat >expected <<EOF &&
726 ## HEAD (no branch); BISECTING
728 git status --untracked-files=no --short --branch --in-progress >actual &&
729 test_i18ncmp expected actual
732 test_expect_success 'status when rebase conflicts with statushints disabled' '
733 git reset --hard master &&
734 git checkout -b statushints_disabled &&
735 test_when_finished "git config --local advice.statushints true" &&
736 git config --local advice.statushints false &&
737 test_commit one_statushints main.txt one &&
738 test_commit two_statushints main.txt two &&
739 test_commit three_statushints main.txt three &&
740 test_when_finished "git rebase --abort" &&
741 ONTO=$(git rev-parse --short HEAD^^) &&
742 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
743 cat >expected <<EOF &&
744 rebase in progress; onto $ONTO
745 You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
748 both modified: main.txt
750 no changes added to commit
752 git status --untracked-files=no >actual &&
753 test_i18ncmp expected actual
757 test_expect_success 'prepare for cherry-pick conflicts' '
758 git reset --hard master &&
759 git checkout -b cherry_branch &&
760 test_commit one_cherry main.txt one &&
761 test_commit two_cherries main.txt two &&
762 git checkout -b cherry_branch_second &&
763 test_commit second_cherry main.txt second &&
764 git checkout cherry_branch &&
765 test_commit three_cherries main.txt three
769 test_expect_success 'status when cherry-picking before resolving conflicts' '
770 test_must_fail git cherry-pick cherry_branch_second &&
771 TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
772 cat >expected <<EOF &&
773 On branch cherry_branch
774 You are currently cherry-picking commit $TO_CHERRY_PICK.
775 (fix conflicts and run "git cherry-pick --continue")
776 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
779 (use "git add <file>..." to mark resolution)
781 both modified: main.txt
783 no changes added to commit (use "git add" and/or "git commit -a")
785 git status --untracked-files=no >actual &&
786 test_i18ncmp expected actual
789 test_expect_success 'short status when cherry-picking before resolving conflicts' '
790 test_when_finished "git cherry-pick --abort" &&
791 cat >expected <<EOF &&
792 ## cherry_branch; CHERRY-PICKING
795 git status --untracked-files=no --short --branch --in-progress >actual &&
796 test_i18ncmp expected actual
799 test_expect_success 'status when cherry-picking after resolving conflicts' '
800 git reset --hard cherry_branch &&
801 test_when_finished "git cherry-pick --abort" &&
802 test_must_fail git cherry-pick cherry_branch_second &&
803 TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
804 echo end >main.txt &&
806 cat >expected <<EOF &&
807 On branch cherry_branch
808 You are currently cherry-picking commit $TO_CHERRY_PICK.
809 (all conflicts fixed: run "git cherry-pick --continue")
810 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
812 Changes to be committed:
816 Untracked files not listed (use -u option to show untracked files)
818 git status --untracked-files=no >actual &&
819 test_i18ncmp expected actual
822 test_expect_success 'status showing detached at and from a tag' '
823 test_commit atag tagging &&
825 cat >expected <<\EOF &&
826 HEAD detached at atag
827 nothing to commit (use -u to show untracked files)
829 git status --untracked-files=no >actual &&
830 test_i18ncmp expected actual &&
832 git reset --hard HEAD^ &&
833 cat >expected <<\EOF &&
834 HEAD detached from atag
835 nothing to commit (use -u to show untracked files)
837 git status --untracked-files=no >actual &&
838 test_i18ncmp expected actual
841 test_expect_success 'status while reverting commit (conflicts)' '
842 git checkout master &&
843 echo before >to-revert.txt &&
844 test_commit before to-revert.txt &&
845 echo old >to-revert.txt &&
846 test_commit old to-revert.txt &&
847 echo new >to-revert.txt &&
848 test_commit new to-revert.txt &&
849 TO_REVERT=$(git rev-parse --short HEAD^) &&
850 test_must_fail git revert $TO_REVERT &&
851 cat >expected <<EOF &&
853 You are currently reverting commit $TO_REVERT.
854 (fix conflicts and run "git revert --continue")
855 (use "git revert --abort" to cancel the revert operation)
858 (use "git reset HEAD <file>..." to unstage)
859 (use "git add <file>..." to mark resolution)
861 both modified: to-revert.txt
863 no changes added to commit (use "git add" and/or "git commit -a")
865 git status --untracked-files=no >actual &&
866 test_i18ncmp expected actual
869 test_expect_success 'short status while reverting commit (conflicts)' '
870 cat >expected <<EOF &&
874 git status --untracked-files=no --short --branch --in-progress >actual &&
875 test_i18ncmp expected actual
878 test_expect_success 'status while reverting commit (conflicts resolved)' '
879 echo reverted >to-revert.txt &&
880 git add to-revert.txt &&
881 cat >expected <<EOF &&
883 You are currently reverting commit $TO_REVERT.
884 (all conflicts fixed: run "git revert --continue")
885 (use "git revert --abort" to cancel the revert operation)
887 Changes to be committed:
888 (use "git reset HEAD <file>..." to unstage)
890 modified: to-revert.txt
892 Untracked files not listed (use -u option to show untracked files)
894 git status --untracked-files=no >actual &&
895 test_i18ncmp expected actual
898 test_expect_success 'status after reverting commit' '
899 git revert --continue &&
900 cat >expected <<\EOF &&
902 nothing to commit (use -u to show untracked files)
904 git status --untracked-files=no >actual &&
905 test_i18ncmp expected actual
908 test_expect_success 'prepare for different number of commits rebased' '
909 git reset --hard master &&
910 git checkout -b several_commits &&
911 test_commit one_commit main.txt one &&
912 test_commit two_commit main.txt two &&
913 test_commit three_commit main.txt three &&
914 test_commit four_commit main.txt four
917 test_expect_success 'status: one command done nothing remaining' '
918 FAKE_LINES="exec_exit_15" &&
920 test_when_finished "git rebase --abort" &&
921 ONTO=$(git rev-parse --short HEAD~3) &&
922 test_must_fail git rebase -i HEAD~3 &&
923 cat >expected <<EOF &&
924 interactive rebase in progress; onto $ONTO
925 Last command done (1 command done):
927 No commands remaining.
928 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
929 (use "git commit --amend" to amend the current commit)
930 (use "git rebase --continue" once you are satisfied with your changes)
932 nothing to commit (use -u to show untracked files)
934 git status --untracked-files=no >actual &&
935 test_i18ncmp expected actual
938 test_expect_success 'status: two commands done with some white lines in done file' '
939 FAKE_LINES="1 > exec_exit_15 2 3" &&
941 test_when_finished "git rebase --abort" &&
942 ONTO=$(git rev-parse --short HEAD~3) &&
943 COMMIT4=$(git rev-parse --short HEAD) &&
944 COMMIT3=$(git rev-parse --short HEAD^) &&
945 COMMIT2=$(git rev-parse --short HEAD^^) &&
946 test_must_fail git rebase -i HEAD~3 &&
947 cat >expected <<EOF &&
948 interactive rebase in progress; onto $ONTO
949 Last commands done (2 commands done):
950 pick $COMMIT2 two_commit
952 Next commands to do (2 remaining commands):
953 pick $COMMIT3 three_commit
954 pick $COMMIT4 four_commit
955 (use "git rebase --edit-todo" to view and edit)
956 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
957 (use "git commit --amend" to amend the current commit)
958 (use "git rebase --continue" once you are satisfied with your changes)
960 nothing to commit (use -u to show untracked files)
962 git status --untracked-files=no >actual &&
963 test_i18ncmp expected actual
966 test_expect_success 'status: two remaining commands with some white lines in todo file' '
967 FAKE_LINES="1 2 exec_exit_15 3 > 4" &&
969 test_when_finished "git rebase --abort" &&
970 ONTO=$(git rev-parse --short HEAD~4) &&
971 COMMIT4=$(git rev-parse --short HEAD) &&
972 COMMIT3=$(git rev-parse --short HEAD^) &&
973 COMMIT2=$(git rev-parse --short HEAD^^) &&
974 test_must_fail git rebase -i HEAD~4 &&
975 cat >expected <<EOF &&
976 interactive rebase in progress; onto $ONTO
977 Last commands done (3 commands done):
978 pick $COMMIT2 two_commit
980 (see more in file .git/rebase-merge/done)
981 Next commands to do (2 remaining commands):
982 pick $COMMIT3 three_commit
983 pick $COMMIT4 four_commit
984 (use "git rebase --edit-todo" to view and edit)
985 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
986 (use "git commit --amend" to amend the current commit)
987 (use "git rebase --continue" once you are satisfied with your changes)
989 nothing to commit (use -u to show untracked files)
991 git status --untracked-files=no >actual &&
992 test_i18ncmp expected actual
995 test_expect_success 'status: handle not-yet-started rebase -i gracefully' '
996 ONTO=$(git rev-parse --short HEAD^) &&
997 COMMIT=$(git rev-parse --short HEAD) &&
998 EDITOR="git status --untracked-files=no >actual" git rebase -i HEAD^ &&
999 cat >expected <<EOF &&
1000 On branch several_commits
1002 Next command to do (1 remaining command):
1003 pick $COMMIT four_commit
1004 (use "git rebase --edit-todo" to view and edit)
1005 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
1006 (use "git commit --amend" to amend the current commit)
1007 (use "git rebase --continue" once you are satisfied with your changes)
1009 nothing to commit (use -u to show untracked files)
1011 test_i18ncmp expected actual