worktree: handle broken symrefs in find_shared_symref()
[git.git] / t / t7512-status-help.sh
blob458608cc1e7ca51e1a7e40017794b5f2c55d3db3
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)
37 both modified: main.txt
39 no changes added to commit (use "git add" and/or "git commit -a")
40 EOF
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 &&
49 echo one >main.txt &&
50 git add main.txt &&
51 cat >expected <<\EOF &&
52 On branch conflicts
53 All conflicts fixed but you are still merging.
54 (use "git commit" to conclude merge)
56 Changes to be committed:
58 modified: main.txt
60 Untracked files not listed (use -u option to show untracked files)
61 EOF
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 test_when_finished "git rebase --abort" &&
78 ONTO=$(git rev-parse --short HEAD^^) &&
79 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
80 cat >expected <<EOF &&
81 rebase in progress; onto $ONTO
82 You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
83 (fix conflicts and then run "git rebase --continue")
84 (use "git rebase --skip" to skip this patch)
85 (use "git rebase --abort" to check out the original branch)
87 Unmerged paths:
88 (use "git reset HEAD <file>..." to unstage)
89 (use "git add <file>..." to mark resolution)
91 both modified: main.txt
93 no changes added to commit (use "git add" and/or "git commit -a")
94 EOF
95 git status --untracked-files=no >actual &&
96 test_i18ncmp expected actual
100 test_expect_success 'status when rebase in progress before rebase --continue' '
101 git reset --hard rebase_conflicts &&
102 test_when_finished "git rebase --abort" &&
103 ONTO=$(git rev-parse --short HEAD^^) &&
104 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
105 echo three >main.txt &&
106 git add main.txt &&
107 cat >expected <<EOF &&
108 rebase in progress; onto $ONTO
109 You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
110 (all conflicts fixed: run "git rebase --continue")
112 Changes to be committed:
113 (use "git reset HEAD <file>..." to unstage)
115 modified: main.txt
117 Untracked files not listed (use -u option to show untracked files)
119 git status --untracked-files=no >actual &&
120 test_i18ncmp expected actual
124 test_expect_success 'prepare for rebase_i_conflicts' '
125 git reset --hard master &&
126 git checkout -b rebase_i_conflicts &&
127 test_commit one_unmerge main.txt one_unmerge &&
128 git branch rebase_i_conflicts_second &&
129 test_commit one_master main.txt one_master &&
130 git checkout rebase_i_conflicts_second &&
131 test_commit one_second main.txt one_second
135 test_expect_success 'status during rebase -i when conflicts unresolved' '
136 test_when_finished "git rebase --abort" &&
137 ONTO=$(git rev-parse --short rebase_i_conflicts) &&
138 LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) &&
139 test_must_fail git rebase -i rebase_i_conflicts &&
140 cat >expected <<EOF &&
141 interactive rebase in progress; onto $ONTO
142 Last command done (1 command done):
143 pick $LAST_COMMIT one_second
144 No commands remaining.
145 You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
146 (fix conflicts and then run "git rebase --continue")
147 (use "git rebase --skip" to skip this patch)
148 (use "git rebase --abort" to check out the original branch)
150 Unmerged paths:
151 (use "git reset HEAD <file>..." to unstage)
152 (use "git add <file>..." to mark resolution)
154 both modified: main.txt
156 no changes added to commit (use "git add" and/or "git commit -a")
158 git status --untracked-files=no >actual &&
159 test_i18ncmp expected actual
163 test_expect_success 'status during rebase -i after resolving conflicts' '
164 git reset --hard rebase_i_conflicts_second &&
165 test_when_finished "git rebase --abort" &&
166 ONTO=$(git rev-parse --short rebase_i_conflicts) &&
167 LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) &&
168 test_must_fail git rebase -i rebase_i_conflicts &&
169 git add main.txt &&
170 cat >expected <<EOF &&
171 interactive rebase in progress; onto $ONTO
172 Last command done (1 command done):
173 pick $LAST_COMMIT one_second
174 No commands remaining.
175 You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
176 (all conflicts fixed: run "git rebase --continue")
178 Changes to be committed:
179 (use "git reset HEAD <file>..." to unstage)
181 modified: main.txt
183 Untracked files not listed (use -u option to show untracked files)
185 git status --untracked-files=no >actual &&
186 test_i18ncmp expected actual
190 test_expect_success 'status when rebasing -i in edit mode' '
191 git reset --hard master &&
192 git checkout -b rebase_i_edit &&
193 test_commit one_rebase_i main.txt one &&
194 test_commit two_rebase_i main.txt two &&
195 COMMIT2=$(git rev-parse --short rebase_i_edit) &&
196 test_commit three_rebase_i main.txt three &&
197 COMMIT3=$(git rev-parse --short rebase_i_edit) &&
198 FAKE_LINES="1 edit 2" &&
199 export FAKE_LINES &&
200 test_when_finished "git rebase --abort" &&
201 ONTO=$(git rev-parse --short HEAD~2) &&
202 git rebase -i HEAD~2 &&
203 cat >expected <<EOF &&
204 interactive rebase in progress; onto $ONTO
205 Last commands done (2 commands done):
206 pick $COMMIT2 two_rebase_i
207 edit $COMMIT3 three_rebase_i
208 No commands remaining.
209 You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
210 (use "git commit --amend" to amend the current commit)
211 (use "git rebase --continue" once you are satisfied with your changes)
213 nothing to commit (use -u to show untracked files)
215 git status --untracked-files=no >actual &&
216 test_i18ncmp expected actual
220 test_expect_success 'status when splitting a commit' '
221 git reset --hard master &&
222 git checkout -b split_commit &&
223 test_commit one_split main.txt one &&
224 test_commit two_split main.txt two &&
225 COMMIT2=$(git rev-parse --short split_commit) &&
226 test_commit three_split main.txt three &&
227 COMMIT3=$(git rev-parse --short split_commit) &&
228 test_commit four_split main.txt four &&
229 COMMIT4=$(git rev-parse --short split_commit) &&
230 FAKE_LINES="1 edit 2 3" &&
231 export FAKE_LINES &&
232 test_when_finished "git rebase --abort" &&
233 ONTO=$(git rev-parse --short HEAD~3) &&
234 git rebase -i HEAD~3 &&
235 git reset HEAD^ &&
236 cat >expected <<EOF &&
237 interactive rebase in progress; onto $ONTO
238 Last commands done (2 commands done):
239 pick $COMMIT2 two_split
240 edit $COMMIT3 three_split
241 Next command to do (1 remaining command):
242 pick $COMMIT4 four_split
243 (use "git rebase --edit-todo" to view and edit)
244 You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
245 (Once your working directory is clean, run "git rebase --continue")
247 Changes not staged for commit:
248 (use "git add <file>..." to update what will be committed)
249 (use "git checkout -- <file>..." to discard changes in working directory)
251 modified: main.txt
253 no changes added to commit (use "git add" and/or "git commit -a")
255 git status --untracked-files=no >actual &&
256 test_i18ncmp expected actual
260 test_expect_success 'status after editing the last commit with --amend during a rebase -i' '
261 git reset --hard master &&
262 git checkout -b amend_last &&
263 test_commit one_amend main.txt one &&
264 test_commit two_amend main.txt two &&
265 test_commit three_amend main.txt three &&
266 COMMIT3=$(git rev-parse --short amend_last) &&
267 test_commit four_amend main.txt four &&
268 COMMIT4=$(git rev-parse --short amend_last) &&
269 FAKE_LINES="1 2 edit 3" &&
270 export FAKE_LINES &&
271 test_when_finished "git rebase --abort" &&
272 ONTO=$(git rev-parse --short HEAD~3) &&
273 git rebase -i HEAD~3 &&
274 git commit --amend -m "foo" &&
275 cat >expected <<EOF &&
276 interactive rebase in progress; onto $ONTO
277 Last commands done (3 commands done):
278 pick $COMMIT3 three_amend
279 edit $COMMIT4 four_amend
280 (see more in file .git/rebase-merge/done)
281 No commands remaining.
282 You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
283 (use "git commit --amend" to amend the current commit)
284 (use "git rebase --continue" once you are satisfied with your changes)
286 nothing to commit (use -u to show untracked files)
288 git status --untracked-files=no >actual &&
289 test_i18ncmp expected actual
293 test_expect_success 'prepare for several edits' '
294 git reset --hard master &&
295 git checkout -b several_edits &&
296 test_commit one_edits main.txt one &&
297 test_commit two_edits main.txt two &&
298 test_commit three_edits main.txt three &&
299 test_commit four_edits main.txt four
303 test_expect_success 'status: (continue first edit) second edit' '
304 FAKE_LINES="edit 1 edit 2 3" &&
305 export FAKE_LINES &&
306 test_when_finished "git rebase --abort" &&
307 COMMIT2=$(git rev-parse --short several_edits^^) &&
308 COMMIT3=$(git rev-parse --short several_edits^) &&
309 COMMIT4=$(git rev-parse --short several_edits) &&
310 ONTO=$(git rev-parse --short HEAD~3) &&
311 git rebase -i HEAD~3 &&
312 git rebase --continue &&
313 cat >expected <<EOF &&
314 interactive rebase in progress; onto $ONTO
315 Last commands done (2 commands done):
316 edit $COMMIT2 two_edits
317 edit $COMMIT3 three_edits
318 Next command to do (1 remaining command):
319 pick $COMMIT4 four_edits
320 (use "git rebase --edit-todo" to view and edit)
321 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
322 (use "git commit --amend" to amend the current commit)
323 (use "git rebase --continue" once you are satisfied with your changes)
325 nothing to commit (use -u to show untracked files)
327 git status --untracked-files=no >actual &&
328 test_i18ncmp expected actual
332 test_expect_success 'status: (continue first edit) second edit and split' '
333 git reset --hard several_edits &&
334 FAKE_LINES="edit 1 edit 2 3" &&
335 export FAKE_LINES &&
336 test_when_finished "git rebase --abort" &&
337 COMMIT2=$(git rev-parse --short several_edits^^) &&
338 COMMIT3=$(git rev-parse --short several_edits^) &&
339 COMMIT4=$(git rev-parse --short several_edits) &&
340 ONTO=$(git rev-parse --short HEAD~3) &&
341 git rebase -i HEAD~3 &&
342 git rebase --continue &&
343 git reset HEAD^ &&
344 cat >expected <<EOF &&
345 interactive rebase in progress; onto $ONTO
346 Last commands done (2 commands done):
347 edit $COMMIT2 two_edits
348 edit $COMMIT3 three_edits
349 Next command to do (1 remaining command):
350 pick $COMMIT4 four_edits
351 (use "git rebase --edit-todo" to view and edit)
352 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
353 (Once your working directory is clean, run "git rebase --continue")
355 Changes not staged for commit:
356 (use "git add <file>..." to update what will be committed)
357 (use "git checkout -- <file>..." to discard changes in working directory)
359 modified: main.txt
361 no changes added to commit (use "git add" and/or "git commit -a")
363 git status --untracked-files=no >actual &&
364 test_i18ncmp expected actual
368 test_expect_success 'status: (continue first edit) second edit and amend' '
369 git reset --hard several_edits &&
370 FAKE_LINES="edit 1 edit 2 3" &&
371 export FAKE_LINES &&
372 test_when_finished "git rebase --abort" &&
373 COMMIT2=$(git rev-parse --short several_edits^^) &&
374 COMMIT3=$(git rev-parse --short several_edits^) &&
375 COMMIT4=$(git rev-parse --short several_edits) &&
376 ONTO=$(git rev-parse --short HEAD~3) &&
377 git rebase -i HEAD~3 &&
378 git rebase --continue &&
379 git commit --amend -m "foo" &&
380 cat >expected <<EOF &&
381 interactive rebase in progress; onto $ONTO
382 Last commands done (2 commands done):
383 edit $COMMIT2 two_edits
384 edit $COMMIT3 three_edits
385 Next command to do (1 remaining command):
386 pick $COMMIT4 four_edits
387 (use "git rebase --edit-todo" to view and edit)
388 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
389 (use "git commit --amend" to amend the current commit)
390 (use "git rebase --continue" once you are satisfied with your changes)
392 nothing to commit (use -u to show untracked files)
394 git status --untracked-files=no >actual &&
395 test_i18ncmp expected actual
399 test_expect_success 'status: (amend first edit) second edit' '
400 git reset --hard several_edits &&
401 FAKE_LINES="edit 1 edit 2 3" &&
402 export FAKE_LINES &&
403 test_when_finished "git rebase --abort" &&
404 COMMIT2=$(git rev-parse --short several_edits^^) &&
405 COMMIT3=$(git rev-parse --short several_edits^) &&
406 COMMIT4=$(git rev-parse --short several_edits) &&
407 ONTO=$(git rev-parse --short HEAD~3) &&
408 git rebase -i HEAD~3 &&
409 git commit --amend -m "a" &&
410 git rebase --continue &&
411 cat >expected <<EOF &&
412 interactive rebase in progress; onto $ONTO
413 Last commands done (2 commands done):
414 edit $COMMIT2 two_edits
415 edit $COMMIT3 three_edits
416 Next command to do (1 remaining command):
417 pick $COMMIT4 four_edits
418 (use "git rebase --edit-todo" to view and edit)
419 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
420 (use "git commit --amend" to amend the current commit)
421 (use "git rebase --continue" once you are satisfied with your changes)
423 nothing to commit (use -u to show untracked files)
425 git status --untracked-files=no >actual &&
426 test_i18ncmp expected actual
430 test_expect_success 'status: (amend first edit) second edit and split' '
431 git reset --hard several_edits &&
432 FAKE_LINES="edit 1 edit 2 3" &&
433 export FAKE_LINES &&
434 test_when_finished "git rebase --abort" &&
435 ONTO=$(git rev-parse --short HEAD~3) &&
436 COMMIT2=$(git rev-parse --short several_edits^^) &&
437 COMMIT3=$(git rev-parse --short several_edits^) &&
438 COMMIT4=$(git rev-parse --short several_edits) &&
439 git rebase -i HEAD~3 &&
440 git commit --amend -m "b" &&
441 git rebase --continue &&
442 git reset HEAD^ &&
443 cat >expected <<EOF &&
444 interactive rebase in progress; onto $ONTO
445 Last commands done (2 commands done):
446 edit $COMMIT2 two_edits
447 edit $COMMIT3 three_edits
448 Next command to do (1 remaining command):
449 pick $COMMIT4 four_edits
450 (use "git rebase --edit-todo" to view and edit)
451 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
452 (Once your working directory is clean, run "git rebase --continue")
454 Changes not staged for commit:
455 (use "git add <file>..." to update what will be committed)
456 (use "git checkout -- <file>..." to discard changes in working directory)
458 modified: main.txt
460 no changes added to commit (use "git add" and/or "git commit -a")
462 git status --untracked-files=no >actual &&
463 test_i18ncmp expected actual
467 test_expect_success 'status: (amend first edit) second edit and amend' '
468 git reset --hard several_edits &&
469 FAKE_LINES="edit 1 edit 2 3" &&
470 export FAKE_LINES &&
471 test_when_finished "git rebase --abort" &&
472 COMMIT2=$(git rev-parse --short several_edits^^) &&
473 COMMIT3=$(git rev-parse --short several_edits^) &&
474 COMMIT4=$(git rev-parse --short several_edits) &&
475 ONTO=$(git rev-parse --short HEAD~3) &&
476 git rebase -i HEAD~3 &&
477 git commit --amend -m "c" &&
478 git rebase --continue &&
479 git commit --amend -m "d" &&
480 cat >expected <<EOF &&
481 interactive rebase in progress; onto $ONTO
482 Last commands done (2 commands done):
483 edit $COMMIT2 two_edits
484 edit $COMMIT3 three_edits
485 Next command to do (1 remaining command):
486 pick $COMMIT4 four_edits
487 (use "git rebase --edit-todo" to view and edit)
488 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
489 (use "git commit --amend" to amend the current commit)
490 (use "git rebase --continue" once you are satisfied with your changes)
492 nothing to commit (use -u to show untracked files)
494 git status --untracked-files=no >actual &&
495 test_i18ncmp expected actual
499 test_expect_success 'status: (split first edit) second edit' '
500 git reset --hard several_edits &&
501 FAKE_LINES="edit 1 edit 2 3" &&
502 export FAKE_LINES &&
503 test_when_finished "git rebase --abort" &&
504 COMMIT2=$(git rev-parse --short several_edits^^) &&
505 COMMIT3=$(git rev-parse --short several_edits^) &&
506 COMMIT4=$(git rev-parse --short several_edits) &&
507 ONTO=$(git rev-parse --short HEAD~3) &&
508 git rebase -i HEAD~3 &&
509 git reset HEAD^ &&
510 git add main.txt &&
511 git commit -m "e" &&
512 git rebase --continue &&
513 cat >expected <<EOF &&
514 interactive rebase in progress; onto $ONTO
515 Last commands done (2 commands done):
516 edit $COMMIT2 two_edits
517 edit $COMMIT3 three_edits
518 Next command to do (1 remaining command):
519 pick $COMMIT4 four_edits
520 (use "git rebase --edit-todo" to view and edit)
521 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
522 (use "git commit --amend" to amend the current commit)
523 (use "git rebase --continue" once you are satisfied with your changes)
525 nothing to commit (use -u to show untracked files)
527 git status --untracked-files=no >actual &&
528 test_i18ncmp expected actual
532 test_expect_success 'status: (split first edit) second edit and split' '
533 git reset --hard several_edits &&
534 FAKE_LINES="edit 1 edit 2 3" &&
535 export FAKE_LINES &&
536 test_when_finished "git rebase --abort" &&
537 COMMIT2=$(git rev-parse --short several_edits^^) &&
538 COMMIT3=$(git rev-parse --short several_edits^) &&
539 COMMIT4=$(git rev-parse --short several_edits) &&
540 ONTO=$(git rev-parse --short HEAD~3) &&
541 git rebase -i HEAD~3 &&
542 git reset HEAD^ &&
543 git add main.txt &&
544 git commit --amend -m "f" &&
545 git rebase --continue &&
546 git reset HEAD^ &&
547 cat >expected <<EOF &&
548 interactive rebase in progress; onto $ONTO
549 Last commands done (2 commands done):
550 edit $COMMIT2 two_edits
551 edit $COMMIT3 three_edits
552 Next command to do (1 remaining command):
553 pick $COMMIT4 four_edits
554 (use "git rebase --edit-todo" to view and edit)
555 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
556 (Once your working directory is clean, run "git rebase --continue")
558 Changes not staged for commit:
559 (use "git add <file>..." to update what will be committed)
560 (use "git checkout -- <file>..." to discard changes in working directory)
562 modified: main.txt
564 no changes added to commit (use "git add" and/or "git commit -a")
566 git status --untracked-files=no >actual &&
567 test_i18ncmp expected actual
571 test_expect_success 'status: (split first edit) second edit and amend' '
572 git reset --hard several_edits &&
573 FAKE_LINES="edit 1 edit 2 3" &&
574 export FAKE_LINES &&
575 test_when_finished "git rebase --abort" &&
576 COMMIT2=$(git rev-parse --short several_edits^^) &&
577 COMMIT3=$(git rev-parse --short several_edits^) &&
578 COMMIT4=$(git rev-parse --short several_edits) &&
579 ONTO=$(git rev-parse --short HEAD~3) &&
580 git rebase -i HEAD~3 &&
581 git reset HEAD^ &&
582 git add main.txt &&
583 git commit --amend -m "g" &&
584 git rebase --continue &&
585 git commit --amend -m "h" &&
586 cat >expected <<EOF &&
587 interactive rebase in progress; onto $ONTO
588 Last commands done (2 commands done):
589 edit $COMMIT2 two_edits
590 edit $COMMIT3 three_edits
591 Next command to do (1 remaining command):
592 pick $COMMIT4 four_edits
593 (use "git rebase --edit-todo" to view and edit)
594 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
595 (use "git commit --amend" to amend the current commit)
596 (use "git rebase --continue" once you are satisfied with your changes)
598 nothing to commit (use -u to show untracked files)
600 git status --untracked-files=no >actual &&
601 test_i18ncmp expected actual
605 test_expect_success 'prepare am_session' '
606 git reset --hard master &&
607 git checkout -b am_session &&
608 test_commit one_am one.txt "one" &&
609 test_commit two_am two.txt "two" &&
610 test_commit three_am three.txt "three"
614 test_expect_success 'status in an am session: file already exists' '
615 git checkout -b am_already_exists &&
616 test_when_finished "rm Maildir/* && git am --abort" &&
617 git format-patch -1 -oMaildir &&
618 test_must_fail git am Maildir/*.patch &&
619 cat >expected <<\EOF &&
620 On branch am_already_exists
621 You are in the middle of an am session.
622 (fix conflicts and then run "git am --continue")
623 (use "git am --skip" to skip this patch)
624 (use "git am --abort" to restore the original branch)
626 nothing to commit (use -u to show untracked files)
628 git status --untracked-files=no >actual &&
629 test_i18ncmp expected actual
633 test_expect_success 'status in an am session: file does not exist' '
634 git reset --hard am_session &&
635 git checkout -b am_not_exists &&
636 git rm three.txt &&
637 git commit -m "delete three.txt" &&
638 test_when_finished "rm Maildir/* && git am --abort" &&
639 git format-patch -1 -oMaildir &&
640 test_must_fail git am Maildir/*.patch &&
641 cat >expected <<\EOF &&
642 On branch am_not_exists
643 You are in the middle of an am session.
644 (fix conflicts and then run "git am --continue")
645 (use "git am --skip" to skip this patch)
646 (use "git am --abort" to restore the original branch)
648 nothing to commit (use -u to show untracked files)
650 git status --untracked-files=no >actual &&
651 test_i18ncmp expected actual
655 test_expect_success 'status in an am session: empty patch' '
656 git reset --hard am_session &&
657 git checkout -b am_empty &&
658 test_when_finished "rm Maildir/* && git am --abort" &&
659 git format-patch -3 -oMaildir &&
660 git rm one.txt two.txt three.txt &&
661 git commit -m "delete all am_empty" &&
662 echo error >Maildir/0002-two_am.patch &&
663 test_must_fail git am Maildir/*.patch &&
664 cat >expected <<\EOF &&
665 On branch am_empty
666 You are in the middle of an am session.
667 The current patch is empty.
668 (use "git am --skip" to skip this patch)
669 (use "git am --abort" to restore the original branch)
671 nothing to commit (use -u to show untracked files)
673 git status --untracked-files=no >actual &&
674 test_i18ncmp expected actual
678 test_expect_success 'status when bisecting' '
679 git reset --hard master &&
680 git checkout -b bisect &&
681 test_commit one_bisect main.txt one &&
682 test_commit two_bisect main.txt two &&
683 test_commit three_bisect main.txt three &&
684 test_when_finished "git bisect reset" &&
685 git bisect start &&
686 git bisect bad &&
687 git bisect good one_bisect &&
688 TGT=$(git rev-parse --short two_bisect) &&
689 cat >expected <<EOF &&
690 HEAD detached at $TGT
691 You are currently bisecting, started from branch '\''bisect'\''.
692 (use "git bisect reset" to get back to the original branch)
694 nothing to commit (use -u to show untracked files)
696 git status --untracked-files=no >actual &&
697 test_i18ncmp expected actual
701 test_expect_success 'status when rebase conflicts with statushints disabled' '
702 git reset --hard master &&
703 git checkout -b statushints_disabled &&
704 test_when_finished "git config --local advice.statushints true" &&
705 git config --local advice.statushints false &&
706 test_commit one_statushints main.txt one &&
707 test_commit two_statushints main.txt two &&
708 test_commit three_statushints main.txt three &&
709 test_when_finished "git rebase --abort" &&
710 ONTO=$(git rev-parse --short HEAD^^) &&
711 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
712 cat >expected <<EOF &&
713 rebase in progress; onto $ONTO
714 You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
716 Unmerged paths:
717 both modified: main.txt
719 no changes added to commit
721 git status --untracked-files=no >actual &&
722 test_i18ncmp expected actual
726 test_expect_success 'prepare for cherry-pick conflicts' '
727 git reset --hard master &&
728 git checkout -b cherry_branch &&
729 test_commit one_cherry main.txt one &&
730 test_commit two_cherries main.txt two &&
731 git checkout -b cherry_branch_second &&
732 test_commit second_cherry main.txt second &&
733 git checkout cherry_branch &&
734 test_commit three_cherries main.txt three
738 test_expect_success 'status when cherry-picking before resolving conflicts' '
739 test_when_finished "git cherry-pick --abort" &&
740 test_must_fail git cherry-pick cherry_branch_second &&
741 TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
742 cat >expected <<EOF &&
743 On branch cherry_branch
744 You are currently cherry-picking commit $TO_CHERRY_PICK.
745 (fix conflicts and run "git cherry-pick --continue")
746 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
748 Unmerged paths:
749 (use "git add <file>..." to mark resolution)
751 both modified: main.txt
753 no changes added to commit (use "git add" and/or "git commit -a")
755 git status --untracked-files=no >actual &&
756 test_i18ncmp expected actual
760 test_expect_success 'status when cherry-picking after resolving conflicts' '
761 git reset --hard cherry_branch &&
762 test_when_finished "git cherry-pick --abort" &&
763 test_must_fail git cherry-pick cherry_branch_second &&
764 TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
765 echo end >main.txt &&
766 git add main.txt &&
767 cat >expected <<EOF &&
768 On branch cherry_branch
769 You are currently cherry-picking commit $TO_CHERRY_PICK.
770 (all conflicts fixed: run "git cherry-pick --continue")
771 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
773 Changes to be committed:
775 modified: main.txt
777 Untracked files not listed (use -u option to show untracked files)
779 git status --untracked-files=no >actual &&
780 test_i18ncmp expected actual
783 test_expect_success 'status showing detached at and from a tag' '
784 test_commit atag tagging &&
785 git checkout atag &&
786 cat >expected <<\EOF &&
787 HEAD detached at atag
788 nothing to commit (use -u to show untracked files)
790 git status --untracked-files=no >actual &&
791 test_i18ncmp expected actual &&
793 git reset --hard HEAD^ &&
794 cat >expected <<\EOF &&
795 HEAD detached from atag
796 nothing to commit (use -u to show untracked files)
798 git status --untracked-files=no >actual &&
799 test_i18ncmp expected actual
802 test_expect_success 'status while reverting commit (conflicts)' '
803 git checkout master &&
804 echo before >to-revert.txt &&
805 test_commit before to-revert.txt &&
806 echo old >to-revert.txt &&
807 test_commit old to-revert.txt &&
808 echo new >to-revert.txt &&
809 test_commit new to-revert.txt &&
810 TO_REVERT=$(git rev-parse --short HEAD^) &&
811 test_must_fail git revert $TO_REVERT &&
812 cat >expected <<EOF &&
813 On branch master
814 You are currently reverting commit $TO_REVERT.
815 (fix conflicts and run "git revert --continue")
816 (use "git revert --abort" to cancel the revert operation)
818 Unmerged paths:
819 (use "git reset HEAD <file>..." to unstage)
820 (use "git add <file>..." to mark resolution)
822 both modified: to-revert.txt
824 no changes added to commit (use "git add" and/or "git commit -a")
826 git status --untracked-files=no >actual &&
827 test_i18ncmp expected actual
830 test_expect_success 'status while reverting commit (conflicts resolved)' '
831 echo reverted >to-revert.txt &&
832 git add to-revert.txt &&
833 cat >expected <<EOF &&
834 On branch master
835 You are currently reverting commit $TO_REVERT.
836 (all conflicts fixed: run "git revert --continue")
837 (use "git revert --abort" to cancel the revert operation)
839 Changes to be committed:
840 (use "git reset HEAD <file>..." to unstage)
842 modified: to-revert.txt
844 Untracked files not listed (use -u option to show untracked files)
846 git status --untracked-files=no >actual &&
847 test_i18ncmp expected actual
850 test_expect_success 'status after reverting commit' '
851 git revert --continue &&
852 cat >expected <<\EOF &&
853 On branch master
854 nothing to commit (use -u to show untracked files)
856 git status --untracked-files=no >actual &&
857 test_i18ncmp expected actual
860 test_expect_success 'prepare for different number of commits rebased' '
861 git reset --hard master &&
862 git checkout -b several_commits &&
863 test_commit one_commit main.txt one &&
864 test_commit two_commit main.txt two &&
865 test_commit three_commit main.txt three &&
866 test_commit four_commit main.txt four
869 test_expect_success 'status: one command done nothing remaining' '
870 FAKE_LINES="exec_exit_15" &&
871 export FAKE_LINES &&
872 test_when_finished "git rebase --abort" &&
873 ONTO=$(git rev-parse --short HEAD~3) &&
874 test_must_fail git rebase -i HEAD~3 &&
875 cat >expected <<EOF &&
876 interactive rebase in progress; onto $ONTO
877 Last command done (1 command done):
878 exec exit 15
879 No commands remaining.
880 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
881 (use "git commit --amend" to amend the current commit)
882 (use "git rebase --continue" once you are satisfied with your changes)
884 nothing to commit (use -u to show untracked files)
886 git status --untracked-files=no >actual &&
887 test_i18ncmp expected actual
890 test_expect_success 'status: two commands done with some white lines in done file' '
891 FAKE_LINES="1 > exec_exit_15 2 3" &&
892 export FAKE_LINES &&
893 test_when_finished "git rebase --abort" &&
894 ONTO=$(git rev-parse --short HEAD~3) &&
895 COMMIT4=$(git rev-parse --short HEAD) &&
896 COMMIT3=$(git rev-parse --short HEAD^) &&
897 COMMIT2=$(git rev-parse --short HEAD^^) &&
898 test_must_fail git rebase -i HEAD~3 &&
899 cat >expected <<EOF &&
900 interactive rebase in progress; onto $ONTO
901 Last commands done (2 commands done):
902 pick $COMMIT2 two_commit
903 exec exit 15
904 Next commands to do (2 remaining commands):
905 pick $COMMIT3 three_commit
906 pick $COMMIT4 four_commit
907 (use "git rebase --edit-todo" to view and edit)
908 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
909 (use "git commit --amend" to amend the current commit)
910 (use "git rebase --continue" once you are satisfied with your changes)
912 nothing to commit (use -u to show untracked files)
914 git status --untracked-files=no >actual &&
915 test_i18ncmp expected actual
918 test_expect_success 'status: two remaining commands with some white lines in todo file' '
919 FAKE_LINES="1 2 exec_exit_15 3 > 4" &&
920 export FAKE_LINES &&
921 test_when_finished "git rebase --abort" &&
922 ONTO=$(git rev-parse --short HEAD~4) &&
923 COMMIT4=$(git rev-parse --short HEAD) &&
924 COMMIT3=$(git rev-parse --short HEAD^) &&
925 COMMIT2=$(git rev-parse --short HEAD^^) &&
926 test_must_fail git rebase -i HEAD~4 &&
927 cat >expected <<EOF &&
928 interactive rebase in progress; onto $ONTO
929 Last commands done (3 commands done):
930 pick $COMMIT2 two_commit
931 exec exit 15
932 (see more in file .git/rebase-merge/done)
933 Next commands to do (2 remaining commands):
934 pick $COMMIT3 three_commit
935 pick $COMMIT4 four_commit
936 (use "git rebase --edit-todo" to view and edit)
937 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
938 (use "git commit --amend" to amend the current commit)
939 (use "git rebase --continue" once you are satisfied with your changes)
941 nothing to commit (use -u to show untracked files)
943 git status --untracked-files=no >actual &&
944 test_i18ncmp expected actual
947 test_expect_success 'status: handle not-yet-started rebase -i gracefully' '
948 ONTO=$(git rev-parse --short HEAD^) &&
949 COMMIT=$(git rev-parse --short HEAD) &&
950 EDITOR="git status --untracked-files=no >actual" git rebase -i HEAD^ &&
951 cat >expected <<EOF &&
952 On branch several_commits
953 No commands done.
954 Next command to do (1 remaining command):
955 pick $COMMIT four_commit
956 (use "git rebase --edit-todo" to view and edit)
957 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
958 (use "git commit --amend" to amend the current commit)
959 (use "git rebase --continue" once you are satisfied with your changes)
961 nothing to commit (use -u to show untracked files)
963 test_i18ncmp expected actual
966 test_done