Merge branch 'jc/exclusion-doc'
[alt-git.git] / t / t7512-status-help.sh
blob49d19a3b36d0649dfd01de29acdbf0fab2532e17
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")
33 Unmerged paths:
34 (use "git add <file>..." to mark resolution)
36 both modified: main.txt
38 no changes added to commit (use "git add" and/or "git commit -a")
39 EOF
40 git status --untracked-files=no >actual &&
41 test_i18ncmp expected actual
45 test_expect_success 'status when conflicts resolved before commit' '
46 git reset --hard conflicts &&
47 test_must_fail git merge master &&
48 echo one >main.txt &&
49 git add main.txt &&
50 cat >expected <<\EOF &&
51 On branch conflicts
52 All conflicts fixed but you are still merging.
53 (use "git commit" to conclude merge)
55 Changes to be committed:
57 modified: main.txt
59 Untracked files not listed (use -u option to show untracked files)
60 EOF
61 git status --untracked-files=no >actual &&
62 test_i18ncmp expected actual
66 test_expect_success 'prepare for rebase conflicts' '
67 git reset --hard master &&
68 git checkout -b rebase_conflicts &&
69 test_commit one_rebase main.txt one &&
70 test_commit two_rebase main.txt two &&
71 test_commit three_rebase main.txt three
75 test_expect_success 'status when rebase in progress before resolving conflicts' '
76 test_when_finished "git rebase --abort" &&
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)
86 Unmerged paths:
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")
93 EOF
94 git status --untracked-files=no >actual &&
95 test_i18ncmp expected actual
99 test_expect_success 'status when rebase in progress before rebase --continue' '
100 git reset --hard rebase_conflicts &&
101 test_when_finished "git rebase --abort" &&
102 ONTO=$(git rev-parse --short HEAD^^) &&
103 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
104 echo three >main.txt &&
105 git add main.txt &&
106 cat >expected <<EOF &&
107 rebase in progress; onto $ONTO
108 You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
109 (all conflicts fixed: run "git rebase --continue")
111 Changes to be committed:
112 (use "git reset HEAD <file>..." to unstage)
114 modified: main.txt
116 Untracked files not listed (use -u option to show untracked files)
118 git status --untracked-files=no >actual &&
119 test_i18ncmp expected actual
123 test_expect_success 'prepare for rebase_i_conflicts' '
124 git reset --hard master &&
125 git checkout -b rebase_i_conflicts &&
126 test_commit one_unmerge main.txt one_unmerge &&
127 git branch rebase_i_conflicts_second &&
128 test_commit one_master main.txt one_master &&
129 git checkout rebase_i_conflicts_second &&
130 test_commit one_second main.txt one_second
134 test_expect_success 'status during rebase -i when conflicts unresolved' '
135 test_when_finished "git rebase --abort" &&
136 ONTO=$(git rev-parse --short rebase_i_conflicts) &&
137 LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) &&
138 test_must_fail git rebase -i rebase_i_conflicts &&
139 cat >expected <<EOF &&
140 interactive rebase in progress; onto $ONTO
141 Last command done (1 command done):
142 pick $LAST_COMMIT one_second
143 No commands remaining.
144 You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
145 (fix conflicts and then run "git rebase --continue")
146 (use "git rebase --skip" to skip this patch)
147 (use "git rebase --abort" to check out the original branch)
149 Unmerged paths:
150 (use "git reset HEAD <file>..." to unstage)
151 (use "git add <file>..." to mark resolution)
153 both modified: main.txt
155 no changes added to commit (use "git add" and/or "git commit -a")
157 git status --untracked-files=no >actual &&
158 test_i18ncmp expected actual
162 test_expect_success 'status during rebase -i after resolving conflicts' '
163 git reset --hard rebase_i_conflicts_second &&
164 test_when_finished "git rebase --abort" &&
165 ONTO=$(git rev-parse --short rebase_i_conflicts) &&
166 LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) &&
167 test_must_fail git rebase -i rebase_i_conflicts &&
168 git add main.txt &&
169 cat >expected <<EOF &&
170 interactive rebase in progress; onto $ONTO
171 Last command done (1 command done):
172 pick $LAST_COMMIT one_second
173 No commands remaining.
174 You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
175 (all conflicts fixed: run "git rebase --continue")
177 Changes to be committed:
178 (use "git reset HEAD <file>..." to unstage)
180 modified: main.txt
182 Untracked files not listed (use -u option to show untracked files)
184 git status --untracked-files=no >actual &&
185 test_i18ncmp expected actual
189 test_expect_success 'status when rebasing -i in edit mode' '
190 git reset --hard master &&
191 git checkout -b rebase_i_edit &&
192 test_commit one_rebase_i main.txt one &&
193 test_commit two_rebase_i main.txt two &&
194 COMMIT2=$(git rev-parse --short rebase_i_edit) &&
195 test_commit three_rebase_i main.txt three &&
196 COMMIT3=$(git rev-parse --short rebase_i_edit) &&
197 FAKE_LINES="1 edit 2" &&
198 export FAKE_LINES &&
199 test_when_finished "git rebase --abort" &&
200 ONTO=$(git rev-parse --short HEAD~2) &&
201 git rebase -i HEAD~2 &&
202 cat >expected <<EOF &&
203 interactive rebase in progress; onto $ONTO
204 Last commands done (2 commands done):
205 pick $COMMIT2 two_rebase_i
206 edit $COMMIT3 three_rebase_i
207 No commands remaining.
208 You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
209 (use "git commit --amend" to amend the current commit)
210 (use "git rebase --continue" once you are satisfied with your changes)
212 nothing to commit (use -u to show untracked files)
214 git status --untracked-files=no >actual &&
215 test_i18ncmp expected actual
219 test_expect_success 'status when splitting a commit' '
220 git reset --hard master &&
221 git checkout -b split_commit &&
222 test_commit one_split main.txt one &&
223 test_commit two_split main.txt two &&
224 COMMIT2=$(git rev-parse --short split_commit) &&
225 test_commit three_split main.txt three &&
226 COMMIT3=$(git rev-parse --short split_commit) &&
227 test_commit four_split main.txt four &&
228 COMMIT4=$(git rev-parse --short split_commit) &&
229 FAKE_LINES="1 edit 2 3" &&
230 export FAKE_LINES &&
231 test_when_finished "git rebase --abort" &&
232 ONTO=$(git rev-parse --short HEAD~3) &&
233 git rebase -i HEAD~3 &&
234 git reset HEAD^ &&
235 cat >expected <<EOF &&
236 interactive rebase in progress; onto $ONTO
237 Last commands done (2 commands done):
238 pick $COMMIT2 two_split
239 edit $COMMIT3 three_split
240 Next command to do (1 remaining command):
241 pick $COMMIT4 four_split
242 (use "git rebase --edit-todo" to view and edit)
243 You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
244 (Once your working directory is clean, run "git rebase --continue")
246 Changes not staged for commit:
247 (use "git add <file>..." to update what will be committed)
248 (use "git checkout -- <file>..." to discard changes in working directory)
250 modified: main.txt
252 no changes added to commit (use "git add" and/or "git commit -a")
254 git status --untracked-files=no >actual &&
255 test_i18ncmp expected actual
259 test_expect_success 'status after editing the last commit with --amend during a rebase -i' '
260 git reset --hard master &&
261 git checkout -b amend_last &&
262 test_commit one_amend main.txt one &&
263 test_commit two_amend main.txt two &&
264 test_commit three_amend main.txt three &&
265 COMMIT3=$(git rev-parse --short amend_last) &&
266 test_commit four_amend main.txt four &&
267 COMMIT4=$(git rev-parse --short amend_last) &&
268 FAKE_LINES="1 2 edit 3" &&
269 export FAKE_LINES &&
270 test_when_finished "git rebase --abort" &&
271 ONTO=$(git rev-parse --short HEAD~3) &&
272 git rebase -i HEAD~3 &&
273 git commit --amend -m "foo" &&
274 cat >expected <<EOF &&
275 interactive rebase in progress; onto $ONTO
276 Last commands done (3 commands done):
277 pick $COMMIT3 three_amend
278 edit $COMMIT4 four_amend
279 (see more in file .git/rebase-merge/done)
280 No commands remaining.
281 You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
282 (use "git commit --amend" to amend the current commit)
283 (use "git rebase --continue" once you are satisfied with your changes)
285 nothing to commit (use -u to show untracked files)
287 git status --untracked-files=no >actual &&
288 test_i18ncmp expected actual
292 test_expect_success 'prepare for several edits' '
293 git reset --hard master &&
294 git checkout -b several_edits &&
295 test_commit one_edits main.txt one &&
296 test_commit two_edits main.txt two &&
297 test_commit three_edits main.txt three &&
298 test_commit four_edits main.txt four
302 test_expect_success 'status: (continue first edit) second edit' '
303 FAKE_LINES="edit 1 edit 2 3" &&
304 export FAKE_LINES &&
305 test_when_finished "git rebase --abort" &&
306 COMMIT2=$(git rev-parse --short several_edits^^) &&
307 COMMIT3=$(git rev-parse --short several_edits^) &&
308 COMMIT4=$(git rev-parse --short several_edits) &&
309 ONTO=$(git rev-parse --short HEAD~3) &&
310 git rebase -i HEAD~3 &&
311 git rebase --continue &&
312 cat >expected <<EOF &&
313 interactive rebase in progress; onto $ONTO
314 Last commands done (2 commands done):
315 edit $COMMIT2 two_edits
316 edit $COMMIT3 three_edits
317 Next command to do (1 remaining command):
318 pick $COMMIT4 four_edits
319 (use "git rebase --edit-todo" to view and edit)
320 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
321 (use "git commit --amend" to amend the current commit)
322 (use "git rebase --continue" once you are satisfied with your changes)
324 nothing to commit (use -u to show untracked files)
326 git status --untracked-files=no >actual &&
327 test_i18ncmp expected actual
331 test_expect_success 'status: (continue first edit) second edit and split' '
332 git reset --hard several_edits &&
333 FAKE_LINES="edit 1 edit 2 3" &&
334 export FAKE_LINES &&
335 test_when_finished "git rebase --abort" &&
336 COMMIT2=$(git rev-parse --short several_edits^^) &&
337 COMMIT3=$(git rev-parse --short several_edits^) &&
338 COMMIT4=$(git rev-parse --short several_edits) &&
339 ONTO=$(git rev-parse --short HEAD~3) &&
340 git rebase -i HEAD~3 &&
341 git rebase --continue &&
342 git reset HEAD^ &&
343 cat >expected <<EOF &&
344 interactive rebase in progress; onto $ONTO
345 Last commands done (2 commands done):
346 edit $COMMIT2 two_edits
347 edit $COMMIT3 three_edits
348 Next command to do (1 remaining command):
349 pick $COMMIT4 four_edits
350 (use "git rebase --edit-todo" to view and edit)
351 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
352 (Once your working directory is clean, run "git rebase --continue")
354 Changes not staged for commit:
355 (use "git add <file>..." to update what will be committed)
356 (use "git checkout -- <file>..." to discard changes in working directory)
358 modified: main.txt
360 no changes added to commit (use "git add" and/or "git commit -a")
362 git status --untracked-files=no >actual &&
363 test_i18ncmp expected actual
367 test_expect_success 'status: (continue first edit) second edit and amend' '
368 git reset --hard several_edits &&
369 FAKE_LINES="edit 1 edit 2 3" &&
370 export FAKE_LINES &&
371 test_when_finished "git rebase --abort" &&
372 COMMIT2=$(git rev-parse --short several_edits^^) &&
373 COMMIT3=$(git rev-parse --short several_edits^) &&
374 COMMIT4=$(git rev-parse --short several_edits) &&
375 ONTO=$(git rev-parse --short HEAD~3) &&
376 git rebase -i HEAD~3 &&
377 git rebase --continue &&
378 git commit --amend -m "foo" &&
379 cat >expected <<EOF &&
380 interactive rebase in progress; onto $ONTO
381 Last commands done (2 commands done):
382 edit $COMMIT2 two_edits
383 edit $COMMIT3 three_edits
384 Next command to do (1 remaining command):
385 pick $COMMIT4 four_edits
386 (use "git rebase --edit-todo" to view and edit)
387 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
388 (use "git commit --amend" to amend the current commit)
389 (use "git rebase --continue" once you are satisfied with your changes)
391 nothing to commit (use -u to show untracked files)
393 git status --untracked-files=no >actual &&
394 test_i18ncmp expected actual
398 test_expect_success 'status: (amend first edit) second edit' '
399 git reset --hard several_edits &&
400 FAKE_LINES="edit 1 edit 2 3" &&
401 export FAKE_LINES &&
402 test_when_finished "git rebase --abort" &&
403 COMMIT2=$(git rev-parse --short several_edits^^) &&
404 COMMIT3=$(git rev-parse --short several_edits^) &&
405 COMMIT4=$(git rev-parse --short several_edits) &&
406 ONTO=$(git rev-parse --short HEAD~3) &&
407 git rebase -i HEAD~3 &&
408 git commit --amend -m "a" &&
409 git rebase --continue &&
410 cat >expected <<EOF &&
411 interactive rebase in progress; onto $ONTO
412 Last commands done (2 commands done):
413 edit $COMMIT2 two_edits
414 edit $COMMIT3 three_edits
415 Next command to do (1 remaining command):
416 pick $COMMIT4 four_edits
417 (use "git rebase --edit-todo" to view and edit)
418 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
419 (use "git commit --amend" to amend the current commit)
420 (use "git rebase --continue" once you are satisfied with your changes)
422 nothing to commit (use -u to show untracked files)
424 git status --untracked-files=no >actual &&
425 test_i18ncmp expected actual
429 test_expect_success 'status: (amend first edit) second edit and split' '
430 git reset --hard several_edits &&
431 FAKE_LINES="edit 1 edit 2 3" &&
432 export FAKE_LINES &&
433 test_when_finished "git rebase --abort" &&
434 ONTO=$(git rev-parse --short HEAD~3) &&
435 COMMIT2=$(git rev-parse --short several_edits^^) &&
436 COMMIT3=$(git rev-parse --short several_edits^) &&
437 COMMIT4=$(git rev-parse --short several_edits) &&
438 git rebase -i HEAD~3 &&
439 git commit --amend -m "b" &&
440 git rebase --continue &&
441 git reset HEAD^ &&
442 cat >expected <<EOF &&
443 interactive rebase in progress; onto $ONTO
444 Last commands done (2 commands done):
445 edit $COMMIT2 two_edits
446 edit $COMMIT3 three_edits
447 Next command to do (1 remaining command):
448 pick $COMMIT4 four_edits
449 (use "git rebase --edit-todo" to view and edit)
450 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
451 (Once your working directory is clean, run "git rebase --continue")
453 Changes not staged for commit:
454 (use "git add <file>..." to update what will be committed)
455 (use "git checkout -- <file>..." to discard changes in working directory)
457 modified: main.txt
459 no changes added to commit (use "git add" and/or "git commit -a")
461 git status --untracked-files=no >actual &&
462 test_i18ncmp expected actual
466 test_expect_success 'status: (amend first edit) second edit and amend' '
467 git reset --hard several_edits &&
468 FAKE_LINES="edit 1 edit 2 3" &&
469 export FAKE_LINES &&
470 test_when_finished "git rebase --abort" &&
471 COMMIT2=$(git rev-parse --short several_edits^^) &&
472 COMMIT3=$(git rev-parse --short several_edits^) &&
473 COMMIT4=$(git rev-parse --short several_edits) &&
474 ONTO=$(git rev-parse --short HEAD~3) &&
475 git rebase -i HEAD~3 &&
476 git commit --amend -m "c" &&
477 git rebase --continue &&
478 git commit --amend -m "d" &&
479 cat >expected <<EOF &&
480 interactive rebase in progress; onto $ONTO
481 Last commands done (2 commands done):
482 edit $COMMIT2 two_edits
483 edit $COMMIT3 three_edits
484 Next command to do (1 remaining command):
485 pick $COMMIT4 four_edits
486 (use "git rebase --edit-todo" to view and edit)
487 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
488 (use "git commit --amend" to amend the current commit)
489 (use "git rebase --continue" once you are satisfied with your changes)
491 nothing to commit (use -u to show untracked files)
493 git status --untracked-files=no >actual &&
494 test_i18ncmp expected actual
498 test_expect_success 'status: (split first edit) second edit' '
499 git reset --hard several_edits &&
500 FAKE_LINES="edit 1 edit 2 3" &&
501 export FAKE_LINES &&
502 test_when_finished "git rebase --abort" &&
503 COMMIT2=$(git rev-parse --short several_edits^^) &&
504 COMMIT3=$(git rev-parse --short several_edits^) &&
505 COMMIT4=$(git rev-parse --short several_edits) &&
506 ONTO=$(git rev-parse --short HEAD~3) &&
507 git rebase -i HEAD~3 &&
508 git reset HEAD^ &&
509 git add main.txt &&
510 git commit -m "e" &&
511 git rebase --continue &&
512 cat >expected <<EOF &&
513 interactive rebase in progress; onto $ONTO
514 Last commands done (2 commands done):
515 edit $COMMIT2 two_edits
516 edit $COMMIT3 three_edits
517 Next command to do (1 remaining command):
518 pick $COMMIT4 four_edits
519 (use "git rebase --edit-todo" to view and edit)
520 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
521 (use "git commit --amend" to amend the current commit)
522 (use "git rebase --continue" once you are satisfied with your changes)
524 nothing to commit (use -u to show untracked files)
526 git status --untracked-files=no >actual &&
527 test_i18ncmp expected actual
531 test_expect_success 'status: (split first edit) second edit and split' '
532 git reset --hard several_edits &&
533 FAKE_LINES="edit 1 edit 2 3" &&
534 export FAKE_LINES &&
535 test_when_finished "git rebase --abort" &&
536 COMMIT2=$(git rev-parse --short several_edits^^) &&
537 COMMIT3=$(git rev-parse --short several_edits^) &&
538 COMMIT4=$(git rev-parse --short several_edits) &&
539 ONTO=$(git rev-parse --short HEAD~3) &&
540 git rebase -i HEAD~3 &&
541 git reset HEAD^ &&
542 git add main.txt &&
543 git commit --amend -m "f" &&
544 git rebase --continue &&
545 git reset HEAD^ &&
546 cat >expected <<EOF &&
547 interactive rebase in progress; onto $ONTO
548 Last commands done (2 commands done):
549 edit $COMMIT2 two_edits
550 edit $COMMIT3 three_edits
551 Next command to do (1 remaining command):
552 pick $COMMIT4 four_edits
553 (use "git rebase --edit-todo" to view and edit)
554 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
555 (Once your working directory is clean, run "git rebase --continue")
557 Changes not staged for commit:
558 (use "git add <file>..." to update what will be committed)
559 (use "git checkout -- <file>..." to discard changes in working directory)
561 modified: main.txt
563 no changes added to commit (use "git add" and/or "git commit -a")
565 git status --untracked-files=no >actual &&
566 test_i18ncmp expected actual
570 test_expect_success 'status: (split first edit) second edit and amend' '
571 git reset --hard several_edits &&
572 FAKE_LINES="edit 1 edit 2 3" &&
573 export FAKE_LINES &&
574 test_when_finished "git rebase --abort" &&
575 COMMIT2=$(git rev-parse --short several_edits^^) &&
576 COMMIT3=$(git rev-parse --short several_edits^) &&
577 COMMIT4=$(git rev-parse --short several_edits) &&
578 ONTO=$(git rev-parse --short HEAD~3) &&
579 git rebase -i HEAD~3 &&
580 git reset HEAD^ &&
581 git add main.txt &&
582 git commit --amend -m "g" &&
583 git rebase --continue &&
584 git commit --amend -m "h" &&
585 cat >expected <<EOF &&
586 interactive rebase in progress; onto $ONTO
587 Last commands done (2 commands done):
588 edit $COMMIT2 two_edits
589 edit $COMMIT3 three_edits
590 Next command to do (1 remaining command):
591 pick $COMMIT4 four_edits
592 (use "git rebase --edit-todo" to view and edit)
593 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
594 (use "git commit --amend" to amend the current commit)
595 (use "git rebase --continue" once you are satisfied with your changes)
597 nothing to commit (use -u to show untracked files)
599 git status --untracked-files=no >actual &&
600 test_i18ncmp expected actual
604 test_expect_success 'prepare am_session' '
605 git reset --hard master &&
606 git checkout -b am_session &&
607 test_commit one_am one.txt "one" &&
608 test_commit two_am two.txt "two" &&
609 test_commit three_am three.txt "three"
613 test_expect_success 'status in an am session: file already exists' '
614 git checkout -b am_already_exists &&
615 test_when_finished "rm Maildir/* && git am --abort" &&
616 git format-patch -1 -oMaildir &&
617 test_must_fail git am Maildir/*.patch &&
618 cat >expected <<\EOF &&
619 On branch am_already_exists
620 You are in the middle of an am session.
621 (fix conflicts and then run "git am --continue")
622 (use "git am --skip" to skip this patch)
623 (use "git am --abort" to restore the original branch)
625 nothing to commit (use -u to show untracked files)
627 git status --untracked-files=no >actual &&
628 test_i18ncmp expected actual
632 test_expect_success 'status in an am session: file does not exist' '
633 git reset --hard am_session &&
634 git checkout -b am_not_exists &&
635 git rm three.txt &&
636 git commit -m "delete three.txt" &&
637 test_when_finished "rm Maildir/* && git am --abort" &&
638 git format-patch -1 -oMaildir &&
639 test_must_fail git am Maildir/*.patch &&
640 cat >expected <<\EOF &&
641 On branch am_not_exists
642 You are in the middle of an am session.
643 (fix conflicts and then run "git am --continue")
644 (use "git am --skip" to skip this patch)
645 (use "git am --abort" to restore the original branch)
647 nothing to commit (use -u to show untracked files)
649 git status --untracked-files=no >actual &&
650 test_i18ncmp expected actual
654 test_expect_success 'status in an am session: empty patch' '
655 git reset --hard am_session &&
656 git checkout -b am_empty &&
657 test_when_finished "rm Maildir/* && git am --abort" &&
658 git format-patch -3 -oMaildir &&
659 git rm one.txt two.txt three.txt &&
660 git commit -m "delete all am_empty" &&
661 echo error >Maildir/0002-two_am.patch &&
662 test_must_fail git am Maildir/*.patch &&
663 cat >expected <<\EOF &&
664 On branch am_empty
665 You are in the middle of an am session.
666 The current patch is empty.
667 (use "git am --skip" to skip this patch)
668 (use "git am --abort" to restore the original branch)
670 nothing to commit (use -u to show untracked files)
672 git status --untracked-files=no >actual &&
673 test_i18ncmp expected actual
677 test_expect_success 'status when bisecting' '
678 git reset --hard master &&
679 git checkout -b bisect &&
680 test_commit one_bisect main.txt one &&
681 test_commit two_bisect main.txt two &&
682 test_commit three_bisect main.txt three &&
683 test_when_finished "git bisect reset" &&
684 git bisect start &&
685 git bisect bad &&
686 git bisect good one_bisect &&
687 TGT=$(git rev-parse --short two_bisect) &&
688 cat >expected <<EOF &&
689 HEAD detached at $TGT
690 You are currently bisecting, started from branch '\''bisect'\''.
691 (use "git bisect reset" to get back to the original branch)
693 nothing to commit (use -u to show untracked files)
695 git status --untracked-files=no >actual &&
696 test_i18ncmp expected actual
700 test_expect_success 'status when rebase conflicts with statushints disabled' '
701 git reset --hard master &&
702 git checkout -b statushints_disabled &&
703 test_when_finished "git config --local advice.statushints true" &&
704 git config --local advice.statushints false &&
705 test_commit one_statushints main.txt one &&
706 test_commit two_statushints main.txt two &&
707 test_commit three_statushints main.txt three &&
708 test_when_finished "git rebase --abort" &&
709 ONTO=$(git rev-parse --short HEAD^^) &&
710 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
711 cat >expected <<EOF &&
712 rebase in progress; onto $ONTO
713 You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
715 Unmerged paths:
716 both modified: main.txt
718 no changes added to commit
720 git status --untracked-files=no >actual &&
721 test_i18ncmp expected actual
725 test_expect_success 'prepare for cherry-pick conflicts' '
726 git reset --hard master &&
727 git checkout -b cherry_branch &&
728 test_commit one_cherry main.txt one &&
729 test_commit two_cherries main.txt two &&
730 git checkout -b cherry_branch_second &&
731 test_commit second_cherry main.txt second &&
732 git checkout cherry_branch &&
733 test_commit three_cherries main.txt three
737 test_expect_success 'status when cherry-picking before resolving conflicts' '
738 test_when_finished "git cherry-pick --abort" &&
739 test_must_fail git cherry-pick cherry_branch_second &&
740 TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
741 cat >expected <<EOF &&
742 On branch cherry_branch
743 You are currently cherry-picking commit $TO_CHERRY_PICK.
744 (fix conflicts and run "git cherry-pick --continue")
745 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
747 Unmerged paths:
748 (use "git add <file>..." to mark resolution)
750 both modified: main.txt
752 no changes added to commit (use "git add" and/or "git commit -a")
754 git status --untracked-files=no >actual &&
755 test_i18ncmp expected actual
759 test_expect_success 'status when cherry-picking after resolving conflicts' '
760 git reset --hard cherry_branch &&
761 test_when_finished "git cherry-pick --abort" &&
762 test_must_fail git cherry-pick cherry_branch_second &&
763 TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
764 echo end >main.txt &&
765 git add main.txt &&
766 cat >expected <<EOF &&
767 On branch cherry_branch
768 You are currently cherry-picking commit $TO_CHERRY_PICK.
769 (all conflicts fixed: run "git cherry-pick --continue")
770 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
772 Changes to be committed:
774 modified: main.txt
776 Untracked files not listed (use -u option to show untracked files)
778 git status --untracked-files=no >actual &&
779 test_i18ncmp expected actual
782 test_expect_success 'status showing detached at and from a tag' '
783 test_commit atag tagging &&
784 git checkout atag &&
785 cat >expected <<\EOF &&
786 HEAD detached at atag
787 nothing to commit (use -u to show untracked files)
789 git status --untracked-files=no >actual &&
790 test_i18ncmp expected actual &&
792 git reset --hard HEAD^ &&
793 cat >expected <<\EOF &&
794 HEAD detached from atag
795 nothing to commit (use -u to show untracked files)
797 git status --untracked-files=no >actual &&
798 test_i18ncmp expected actual
801 test_expect_success 'status while reverting commit (conflicts)' '
802 git checkout master &&
803 echo before >to-revert.txt &&
804 test_commit before to-revert.txt &&
805 echo old >to-revert.txt &&
806 test_commit old to-revert.txt &&
807 echo new >to-revert.txt &&
808 test_commit new to-revert.txt &&
809 TO_REVERT=$(git rev-parse --short HEAD^) &&
810 test_must_fail git revert $TO_REVERT &&
811 cat >expected <<EOF &&
812 On branch master
813 You are currently reverting commit $TO_REVERT.
814 (fix conflicts and run "git revert --continue")
815 (use "git revert --abort" to cancel the revert operation)
817 Unmerged paths:
818 (use "git reset HEAD <file>..." to unstage)
819 (use "git add <file>..." to mark resolution)
821 both modified: to-revert.txt
823 no changes added to commit (use "git add" and/or "git commit -a")
825 git status --untracked-files=no >actual &&
826 test_i18ncmp expected actual
829 test_expect_success 'status while reverting commit (conflicts resolved)' '
830 echo reverted >to-revert.txt &&
831 git add to-revert.txt &&
832 cat >expected <<EOF &&
833 On branch master
834 You are currently reverting commit $TO_REVERT.
835 (all conflicts fixed: run "git revert --continue")
836 (use "git revert --abort" to cancel the revert operation)
838 Changes to be committed:
839 (use "git reset HEAD <file>..." to unstage)
841 modified: to-revert.txt
843 Untracked files not listed (use -u option to show untracked files)
845 git status --untracked-files=no >actual &&
846 test_i18ncmp expected actual
849 test_expect_success 'status after reverting commit' '
850 git revert --continue &&
851 cat >expected <<\EOF &&
852 On branch master
853 nothing to commit (use -u to show untracked files)
855 git status --untracked-files=no >actual &&
856 test_i18ncmp expected actual
859 test_expect_success 'prepare for different number of commits rebased' '
860 git reset --hard master &&
861 git checkout -b several_commits &&
862 test_commit one_commit main.txt one &&
863 test_commit two_commit main.txt two &&
864 test_commit three_commit main.txt three &&
865 test_commit four_commit main.txt four
868 test_expect_success 'status: one command done nothing remaining' '
869 FAKE_LINES="exec_exit_15" &&
870 export FAKE_LINES &&
871 test_when_finished "git rebase --abort" &&
872 ONTO=$(git rev-parse --short HEAD~3) &&
873 test_must_fail git rebase -i HEAD~3 &&
874 cat >expected <<EOF &&
875 interactive rebase in progress; onto $ONTO
876 Last command done (1 command done):
877 exec exit 15
878 No commands remaining.
879 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
880 (use "git commit --amend" to amend the current commit)
881 (use "git rebase --continue" once you are satisfied with your changes)
883 nothing to commit (use -u to show untracked files)
885 git status --untracked-files=no >actual &&
886 test_i18ncmp expected actual
889 test_expect_success 'status: two commands done with some white lines in done file' '
890 FAKE_LINES="1 > exec_exit_15 2 3" &&
891 export FAKE_LINES &&
892 test_when_finished "git rebase --abort" &&
893 ONTO=$(git rev-parse --short HEAD~3) &&
894 COMMIT4=$(git rev-parse --short HEAD) &&
895 COMMIT3=$(git rev-parse --short HEAD^) &&
896 COMMIT2=$(git rev-parse --short HEAD^^) &&
897 test_must_fail git rebase -i HEAD~3 &&
898 cat >expected <<EOF &&
899 interactive rebase in progress; onto $ONTO
900 Last commands done (2 commands done):
901 pick $COMMIT2 two_commit
902 exec exit 15
903 Next commands to do (2 remaining commands):
904 pick $COMMIT3 three_commit
905 pick $COMMIT4 four_commit
906 (use "git rebase --edit-todo" to view and edit)
907 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
908 (use "git commit --amend" to amend the current commit)
909 (use "git rebase --continue" once you are satisfied with your changes)
911 nothing to commit (use -u to show untracked files)
913 git status --untracked-files=no >actual &&
914 test_i18ncmp expected actual
917 test_expect_success 'status: two remaining commands with some white lines in todo file' '
918 FAKE_LINES="1 2 exec_exit_15 3 > 4" &&
919 export FAKE_LINES &&
920 test_when_finished "git rebase --abort" &&
921 ONTO=$(git rev-parse --short HEAD~4) &&
922 COMMIT4=$(git rev-parse --short HEAD) &&
923 COMMIT3=$(git rev-parse --short HEAD^) &&
924 COMMIT2=$(git rev-parse --short HEAD^^) &&
925 test_must_fail git rebase -i HEAD~4 &&
926 cat >expected <<EOF &&
927 interactive rebase in progress; onto $ONTO
928 Last commands done (3 commands done):
929 pick $COMMIT2 two_commit
930 exec exit 15
931 (see more in file .git/rebase-merge/done)
932 Next commands to do (2 remaining commands):
933 pick $COMMIT3 three_commit
934 pick $COMMIT4 four_commit
935 (use "git rebase --edit-todo" to view and edit)
936 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
937 (use "git commit --amend" to amend the current commit)
938 (use "git rebase --continue" once you are satisfied with your changes)
940 nothing to commit (use -u to show untracked files)
942 git status --untracked-files=no >actual &&
943 test_i18ncmp expected actual
946 test_done