]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t7512-status-help.sh
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)
36 both modified: main.txt
38 no changes added to commit (use "git add" and/or "git commit -a")
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 &&
50 cat >expected <<\EOF &&
52 All conflicts fixed but you are still merging.
53 (use "git commit" to conclude merge)
55 Changes to be committed:
58 Untracked files not listed (use -u option to show untracked files)
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)
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")
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 &&
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)
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)
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 &&
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)
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" &&
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" &&
226 test_when_finished "git rebase --abort" &&
227 ONTO=$(git rev-parse --short HEAD~3) &&
228 git rebase -i HEAD~3 &&
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)
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" &&
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" &&
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" &&
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 &&
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)
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" &&
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" &&
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" &&
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 &&
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)
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" &&
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" &&
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 &&
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" &&
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 &&
535 git commit --amend -m "f" &&
536 git rebase --continue &&
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)
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" &&
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 &&
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 &&
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 &&
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" &&
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'\''.
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 --abort" to cancel the cherry-pick operation)
739 (use "git add <file>..." to mark resolution)
740 both modified: main.txt
742 no changes added to commit (use "git add" and/or "git commit -a")
744 git status --untracked-files=no >actual &&
745 test_i18ncmp expected actual
749 test_expect_success
'status when cherry-picking after resolving conflicts' '
750 git reset --hard cherry_branch &&
751 test_when_finished "git cherry-pick --abort" &&
752 test_must_fail git cherry-pick cherry_branch_second &&
753 TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
754 echo end >main.txt &&
756 cat >expected <<EOF &&
757 On branch cherry_branch
758 You are currently cherry-picking commit $TO_CHERRY_PICK.
759 (all conflicts fixed: run "git cherry-pick --continue")
760 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
762 Changes to be committed:
765 Untracked files not listed (use -u option to show untracked files)
767 git status --untracked-files=no >actual &&
768 test_i18ncmp expected actual
771 test_expect_success
'status when cherry-picking after committing conflict resolution' '
772 git reset --hard cherry_branch &&
773 test_when_finished "git cherry-pick --abort" &&
774 test_must_fail git cherry-pick cherry_branch_second one_cherry &&
775 echo end >main.txt &&
777 cat >expected <<EOF &&
778 On branch cherry_branch
779 Cherry-pick currently in progress.
780 (run "git cherry-pick --continue" to continue)
781 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
783 nothing to commit (use -u to show untracked files)
785 git status --untracked-files=no >actual &&
786 test_i18ncmp expected actual
789 test_expect_success
'status shows cherry-pick with invalid oid' '
790 mkdir .git/sequencer &&
791 test_write_lines "pick invalid-oid" >.git/sequencer/todo &&
792 git status --untracked-files=no >actual 2>err &&
793 git cherry-pick --quit &&
794 test_must_be_empty err &&
795 test_i18ncmp expected actual
798 test_expect_success
'status does not show error if .git/sequencer is a file' '
799 test_when_finished "rm .git/sequencer" &&
800 test_write_lines hello >.git/sequencer &&
801 git status --untracked-files=no 2>err &&
802 test_must_be_empty err
805 test_expect_success
'status showing detached at and from a tag' '
806 test_commit atag tagging &&
808 cat >expected <<\EOF &&
809 HEAD detached at atag
810 nothing to commit (use -u to show untracked files)
812 git status --untracked-files=no >actual &&
813 test_i18ncmp expected actual &&
815 git reset --hard HEAD^ &&
816 cat >expected <<\EOF &&
817 HEAD detached from atag
818 nothing to commit (use -u to show untracked files)
820 git status --untracked-files=no >actual &&
821 test_i18ncmp expected actual
824 test_expect_success
'status while reverting commit (conflicts)' '
825 git checkout master &&
826 echo before >to-revert.txt &&
827 test_commit before to-revert.txt &&
828 echo old >to-revert.txt &&
829 test_commit old to-revert.txt &&
830 echo new >to-revert.txt &&
831 test_commit new to-revert.txt &&
832 TO_REVERT=$(git rev-parse --short HEAD^) &&
833 test_must_fail git revert $TO_REVERT &&
834 cat >expected <<EOF &&
836 You are currently reverting commit $TO_REVERT.
837 (fix conflicts and run "git revert --continue")
838 (use "git revert --abort" to cancel the revert operation)
841 (use "git restore --staged <file>..." to unstage)
842 (use "git add <file>..." to mark resolution)
843 both modified: to-revert.txt
845 no changes added to commit (use "git add" and/or "git commit -a")
847 git status --untracked-files=no >actual &&
848 test_i18ncmp expected actual
851 test_expect_success
'status while reverting commit (conflicts resolved)' '
852 echo reverted >to-revert.txt &&
853 git add to-revert.txt &&
854 cat >expected <<EOF &&
856 You are currently reverting commit $TO_REVERT.
857 (all conflicts fixed: run "git revert --continue")
858 (use "git revert --abort" to cancel the revert operation)
860 Changes to be committed:
861 (use "git restore --staged <file>..." to unstage)
862 modified: to-revert.txt
864 Untracked files not listed (use -u option to show untracked files)
866 git status --untracked-files=no >actual &&
867 test_i18ncmp expected actual
870 test_expect_success
'status after reverting commit' '
871 git revert --continue &&
872 cat >expected <<\EOF &&
874 nothing to commit (use -u to show untracked files)
876 git status --untracked-files=no >actual &&
877 test_i18ncmp expected actual
880 test_expect_success
'status while reverting after committing conflict resolution' '
881 test_when_finished "git revert --abort" &&
882 git reset --hard new &&
883 test_must_fail git revert old new &&
884 echo reverted >to-revert.txt &&
886 cat >expected <<EOF &&
888 Revert currently in progress.
889 (run "git revert --continue" to continue)
890 (use "git revert --abort" to cancel the revert operation)
892 nothing to commit (use -u to show untracked files)
894 git status --untracked-files=no >actual &&
895 test_i18ncmp expected actual
898 test_expect_success
'prepare for different number of commits rebased' '
899 git reset --hard master &&
900 git checkout -b several_commits &&
901 test_commit one_commit main.txt one &&
902 test_commit two_commit main.txt two &&
903 test_commit three_commit main.txt three &&
904 test_commit four_commit main.txt four
907 test_expect_success
'status: one command done nothing remaining' '
908 FAKE_LINES="exec_exit_15" &&
910 test_when_finished "git rebase --abort" &&
911 ONTO=$(git rev-parse --short HEAD~3) &&
912 test_must_fail git rebase -i HEAD~3 &&
913 cat >expected <<EOF &&
914 interactive rebase in progress; onto $ONTO
915 Last command done (1 command done):
917 No commands remaining.
918 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
919 (use "git commit --amend" to amend the current commit)
920 (use "git rebase --continue" once you are satisfied with your changes)
922 nothing to commit (use -u to show untracked files)
924 git status --untracked-files=no >actual &&
925 test_i18ncmp expected actual
928 test_expect_success
'status: two commands done with some white lines in done file' '
929 FAKE_LINES="1 > exec_exit_15 2 3" &&
931 test_when_finished "git rebase --abort" &&
932 ONTO=$(git rev-parse --short HEAD~3) &&
933 COMMIT4=$(git rev-parse --short HEAD) &&
934 COMMIT3=$(git rev-parse --short HEAD^) &&
935 COMMIT2=$(git rev-parse --short HEAD^^) &&
936 test_must_fail git rebase -i HEAD~3 &&
937 cat >expected <<EOF &&
938 interactive rebase in progress; onto $ONTO
939 Last commands done (2 commands done):
940 pick $COMMIT2 two_commit
942 Next commands to do (2 remaining commands):
943 pick $COMMIT3 three_commit
944 pick $COMMIT4 four_commit
945 (use "git rebase --edit-todo" to view and edit)
946 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
947 (use "git commit --amend" to amend the current commit)
948 (use "git rebase --continue" once you are satisfied with your changes)
950 nothing to commit (use -u to show untracked files)
952 git status --untracked-files=no >actual &&
953 test_i18ncmp expected actual
956 test_expect_success
'status: two remaining commands with some white lines in todo file' '
957 FAKE_LINES="1 2 exec_exit_15 3 > 4" &&
959 test_when_finished "git rebase --abort" &&
960 ONTO=$(git rev-parse --short HEAD~4) &&
961 COMMIT4=$(git rev-parse --short HEAD) &&
962 COMMIT3=$(git rev-parse --short HEAD^) &&
963 COMMIT2=$(git rev-parse --short HEAD^^) &&
964 test_must_fail git rebase -i HEAD~4 &&
965 cat >expected <<EOF &&
966 interactive rebase in progress; onto $ONTO
967 Last commands done (3 commands done):
968 pick $COMMIT2 two_commit
970 (see more in file .git/rebase-merge/done)
971 Next commands to do (2 remaining commands):
972 pick $COMMIT3 three_commit
973 pick $COMMIT4 four_commit
974 (use "git rebase --edit-todo" to view and edit)
975 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
976 (use "git commit --amend" to amend the current commit)
977 (use "git rebase --continue" once you are satisfied with your changes)
979 nothing to commit (use -u to show untracked files)
981 git status --untracked-files=no >actual &&
982 test_i18ncmp expected actual
985 test_expect_success
'status: handle not-yet-started rebase -i gracefully' '
986 ONTO=$(git rev-parse --short HEAD^) &&
987 COMMIT=$(git rev-parse --short HEAD) &&
988 EDITOR="git status --untracked-files=no >actual" git rebase -i HEAD^ &&
989 cat >expected <<EOF &&
990 On branch several_commits
992 Next command to do (1 remaining command):
993 pick $COMMIT four_commit
994 (use "git rebase --edit-todo" to view and edit)
995 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
996 (use "git commit --amend" to amend the current commit)
997 (use "git rebase --continue" once you are satisfied with your changes)
999 nothing to commit (use -u to show untracked files)
1001 test_i18ncmp expected actual