git-p4: fix typos
[git/gitster.git] / t / t7512-status-help.sh
blobcdd5f2c697938839f0d15987a12edb656ee0a462
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 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
11 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
13 TEST_PASSES_SANITIZE_LEAK=true
14 . ./test-lib.sh
16 . "$TEST_DIRECTORY"/lib-rebase.sh
18 set_fake_editor
20 test_expect_success 'prepare for conflicts' '
21 git config --global advice.statusuoption false &&
22 test_commit init main.txt init &&
23 git branch conflicts &&
24 test_commit on_main main.txt on_main &&
25 git checkout conflicts &&
26 test_commit on_conflicts main.txt on_conflicts
30 test_expect_success 'status when conflicts unresolved' '
31 test_must_fail git merge main &&
32 cat >expected <<\EOF &&
33 On branch conflicts
34 You have unmerged paths.
35 (fix conflicts and run "git commit")
36 (use "git merge --abort" to abort the merge)
38 Unmerged paths:
39 (use "git add <file>..." to mark resolution)
40 both modified: main.txt
42 no changes added to commit (use "git add" and/or "git commit -a")
43 EOF
44 git status --untracked-files=no >actual &&
45 test_cmp expected actual
49 test_expect_success 'status when conflicts resolved before commit' '
50 git reset --hard conflicts &&
51 test_must_fail git merge main &&
52 echo one >main.txt &&
53 git add main.txt &&
54 cat >expected <<\EOF &&
55 On branch conflicts
56 All conflicts fixed but you are still merging.
57 (use "git commit" to conclude merge)
59 Changes to be committed:
60 modified: main.txt
62 Untracked files not listed (use -u option to show untracked files)
63 EOF
64 git status --untracked-files=no >actual &&
65 test_cmp expected actual
69 test_expect_success 'prepare for rebase conflicts' '
70 git reset --hard main &&
71 git checkout -b rebase_conflicts &&
72 test_commit one_rebase main.txt one &&
73 test_commit two_rebase main.txt two &&
74 test_commit three_rebase main.txt three
78 test_expect_success 'status when rebase --apply in progress before resolving conflicts' '
79 test_when_finished "git rebase --abort" &&
80 ONTO=$(git rev-parse --short HEAD^^) &&
81 test_must_fail git rebase --apply HEAD^ --onto HEAD^^ &&
82 cat >expected <<EOF &&
83 rebase in progress; onto $ONTO
84 You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
85 (fix conflicts and then run "git rebase --continue")
86 (use "git rebase --skip" to skip this patch)
87 (use "git rebase --abort" to check out the original branch)
89 Unmerged paths:
90 (use "git restore --staged <file>..." to unstage)
91 (use "git add <file>..." to mark resolution)
92 both modified: main.txt
94 no changes added to commit (use "git add" and/or "git commit -a")
95 EOF
96 git status --untracked-files=no >actual &&
97 test_cmp expected actual
101 test_expect_success 'status when rebase --apply in progress before rebase --continue' '
102 git reset --hard rebase_conflicts &&
103 test_when_finished "git rebase --abort" &&
104 ONTO=$(git rev-parse --short HEAD^^) &&
105 test_must_fail git rebase --apply HEAD^ --onto HEAD^^ &&
106 echo three >main.txt &&
107 git add main.txt &&
108 cat >expected <<EOF &&
109 rebase in progress; onto $ONTO
110 You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
111 (all conflicts fixed: run "git rebase --continue")
113 Changes to be committed:
114 (use "git restore --staged <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_cmp expected actual
124 test_expect_success 'prepare for rebase_i_conflicts' '
125 git reset --hard main &&
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_main main.txt one_main &&
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 restore --staged <file>..." to unstage)
152 (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_cmp 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 restore --staged <file>..." to unstage)
179 modified: main.txt
181 Untracked files not listed (use -u option to show untracked files)
183 git status --untracked-files=no >actual &&
184 test_cmp expected actual
188 test_expect_success 'status when rebasing -i in edit mode' '
189 git reset --hard main &&
190 git checkout -b rebase_i_edit &&
191 test_commit one_rebase_i main.txt one &&
192 test_commit two_rebase_i main.txt two &&
193 COMMIT2=$(git rev-parse --short rebase_i_edit) &&
194 test_commit three_rebase_i main.txt three &&
195 COMMIT3=$(git rev-parse --short rebase_i_edit) &&
196 FAKE_LINES="1 edit 2" &&
197 export FAKE_LINES &&
198 test_when_finished "git rebase --abort" &&
199 ONTO=$(git rev-parse --short HEAD~2) &&
200 git rebase -i HEAD~2 &&
201 cat >expected <<EOF &&
202 interactive rebase in progress; onto $ONTO
203 Last commands done (2 commands done):
204 pick $COMMIT2 two_rebase_i
205 edit $COMMIT3 three_rebase_i
206 No commands remaining.
207 You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
208 (use "git commit --amend" to amend the current commit)
209 (use "git rebase --continue" once you are satisfied with your changes)
211 nothing to commit (use -u to show untracked files)
213 git status --untracked-files=no >actual &&
214 test_cmp expected actual
218 test_expect_success 'status when splitting a commit' '
219 git reset --hard main &&
220 git checkout -b split_commit &&
221 test_commit one_split main.txt one &&
222 test_commit two_split main.txt two &&
223 COMMIT2=$(git rev-parse --short split_commit) &&
224 test_commit three_split main.txt three &&
225 COMMIT3=$(git rev-parse --short split_commit) &&
226 test_commit four_split main.txt four &&
227 COMMIT4=$(git rev-parse --short split_commit) &&
228 FAKE_LINES="1 edit 2 3" &&
229 export FAKE_LINES &&
230 test_when_finished "git rebase --abort" &&
231 ONTO=$(git rev-parse --short HEAD~3) &&
232 git rebase -i HEAD~3 &&
233 git reset HEAD^ &&
234 cat >expected <<EOF &&
235 interactive rebase in progress; onto $ONTO
236 Last commands done (2 commands done):
237 pick $COMMIT2 two_split
238 edit $COMMIT3 three_split
239 Next command to do (1 remaining command):
240 pick $COMMIT4 four_split
241 (use "git rebase --edit-todo" to view and edit)
242 You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
243 (Once your working directory is clean, run "git rebase --continue")
245 Changes not staged for commit:
246 (use "git add <file>..." to update what will be committed)
247 (use "git restore <file>..." to discard changes in working directory)
248 modified: main.txt
250 no changes added to commit (use "git add" and/or "git commit -a")
252 git status --untracked-files=no >actual &&
253 test_cmp expected actual
257 test_expect_success 'status after editing the last commit with --amend during a rebase -i' '
258 git reset --hard main &&
259 git checkout -b amend_last &&
260 test_commit one_amend main.txt one &&
261 test_commit two_amend main.txt two &&
262 test_commit three_amend main.txt three &&
263 COMMIT3=$(git rev-parse --short amend_last) &&
264 test_commit four_amend main.txt four &&
265 COMMIT4=$(git rev-parse --short amend_last) &&
266 FAKE_LINES="1 2 edit 3" &&
267 export FAKE_LINES &&
268 test_when_finished "git rebase --abort" &&
269 ONTO=$(git rev-parse --short HEAD~3) &&
270 git rebase -i HEAD~3 &&
271 git commit --amend -m "foo" &&
272 cat >expected <<EOF &&
273 interactive rebase in progress; onto $ONTO
274 Last commands done (3 commands done):
275 pick $COMMIT3 three_amend
276 edit $COMMIT4 four_amend
277 (see more in file .git/rebase-merge/done)
278 No commands remaining.
279 You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
280 (use "git commit --amend" to amend the current commit)
281 (use "git rebase --continue" once you are satisfied with your changes)
283 nothing to commit (use -u to show untracked files)
285 git status --untracked-files=no >actual &&
286 test_cmp expected actual
290 test_expect_success 'prepare for several edits' '
291 git reset --hard main &&
292 git checkout -b several_edits &&
293 test_commit one_edits main.txt one &&
294 test_commit two_edits main.txt two &&
295 test_commit three_edits main.txt three &&
296 test_commit four_edits main.txt four
300 test_expect_success 'status: (continue first edit) second edit' '
301 FAKE_LINES="edit 1 edit 2 3" &&
302 export FAKE_LINES &&
303 test_when_finished "git rebase --abort" &&
304 COMMIT2=$(git rev-parse --short several_edits^^) &&
305 COMMIT3=$(git rev-parse --short several_edits^) &&
306 COMMIT4=$(git rev-parse --short several_edits) &&
307 ONTO=$(git rev-parse --short HEAD~3) &&
308 git rebase -i HEAD~3 &&
309 git rebase --continue &&
310 cat >expected <<EOF &&
311 interactive rebase in progress; onto $ONTO
312 Last commands done (2 commands done):
313 edit $COMMIT2 two_edits
314 edit $COMMIT3 three_edits
315 Next command to do (1 remaining command):
316 pick $COMMIT4 four_edits
317 (use "git rebase --edit-todo" to view and edit)
318 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
319 (use "git commit --amend" to amend the current commit)
320 (use "git rebase --continue" once you are satisfied with your changes)
322 nothing to commit (use -u to show untracked files)
324 git status --untracked-files=no >actual &&
325 test_cmp expected actual
329 test_expect_success 'status: (continue first edit) second edit and split' '
330 git reset --hard several_edits &&
331 FAKE_LINES="edit 1 edit 2 3" &&
332 export FAKE_LINES &&
333 test_when_finished "git rebase --abort" &&
334 COMMIT2=$(git rev-parse --short several_edits^^) &&
335 COMMIT3=$(git rev-parse --short several_edits^) &&
336 COMMIT4=$(git rev-parse --short several_edits) &&
337 ONTO=$(git rev-parse --short HEAD~3) &&
338 git rebase -i HEAD~3 &&
339 git rebase --continue &&
340 git reset HEAD^ &&
341 cat >expected <<EOF &&
342 interactive rebase in progress; onto $ONTO
343 Last commands done (2 commands done):
344 edit $COMMIT2 two_edits
345 edit $COMMIT3 three_edits
346 Next command to do (1 remaining command):
347 pick $COMMIT4 four_edits
348 (use "git rebase --edit-todo" to view and edit)
349 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
350 (Once your working directory is clean, run "git rebase --continue")
352 Changes not staged for commit:
353 (use "git add <file>..." to update what will be committed)
354 (use "git restore <file>..." to discard changes in working directory)
355 modified: main.txt
357 no changes added to commit (use "git add" and/or "git commit -a")
359 git status --untracked-files=no >actual &&
360 test_cmp expected actual
364 test_expect_success 'status: (continue first edit) second edit and amend' '
365 git reset --hard several_edits &&
366 FAKE_LINES="edit 1 edit 2 3" &&
367 export FAKE_LINES &&
368 test_when_finished "git rebase --abort" &&
369 COMMIT2=$(git rev-parse --short several_edits^^) &&
370 COMMIT3=$(git rev-parse --short several_edits^) &&
371 COMMIT4=$(git rev-parse --short several_edits) &&
372 ONTO=$(git rev-parse --short HEAD~3) &&
373 git rebase -i HEAD~3 &&
374 git rebase --continue &&
375 git commit --amend -m "foo" &&
376 cat >expected <<EOF &&
377 interactive rebase in progress; onto $ONTO
378 Last commands done (2 commands done):
379 edit $COMMIT2 two_edits
380 edit $COMMIT3 three_edits
381 Next command to do (1 remaining command):
382 pick $COMMIT4 four_edits
383 (use "git rebase --edit-todo" to view and edit)
384 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
385 (use "git commit --amend" to amend the current commit)
386 (use "git rebase --continue" once you are satisfied with your changes)
388 nothing to commit (use -u to show untracked files)
390 git status --untracked-files=no >actual &&
391 test_cmp expected actual
395 test_expect_success 'status: (amend first edit) second edit' '
396 git reset --hard several_edits &&
397 FAKE_LINES="edit 1 edit 2 3" &&
398 export FAKE_LINES &&
399 test_when_finished "git rebase --abort" &&
400 COMMIT2=$(git rev-parse --short several_edits^^) &&
401 COMMIT3=$(git rev-parse --short several_edits^) &&
402 COMMIT4=$(git rev-parse --short several_edits) &&
403 ONTO=$(git rev-parse --short HEAD~3) &&
404 git rebase -i HEAD~3 &&
405 git commit --amend -m "a" &&
406 git rebase --continue &&
407 cat >expected <<EOF &&
408 interactive rebase in progress; onto $ONTO
409 Last commands done (2 commands done):
410 edit $COMMIT2 two_edits
411 edit $COMMIT3 three_edits
412 Next command to do (1 remaining command):
413 pick $COMMIT4 four_edits
414 (use "git rebase --edit-todo" to view and edit)
415 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
416 (use "git commit --amend" to amend the current commit)
417 (use "git rebase --continue" once you are satisfied with your changes)
419 nothing to commit (use -u to show untracked files)
421 git status --untracked-files=no >actual &&
422 test_cmp expected actual
426 test_expect_success 'status: (amend first edit) second edit and split' '
427 git reset --hard several_edits &&
428 FAKE_LINES="edit 1 edit 2 3" &&
429 export FAKE_LINES &&
430 test_when_finished "git rebase --abort" &&
431 ONTO=$(git rev-parse --short HEAD~3) &&
432 COMMIT2=$(git rev-parse --short several_edits^^) &&
433 COMMIT3=$(git rev-parse --short several_edits^) &&
434 COMMIT4=$(git rev-parse --short several_edits) &&
435 git rebase -i HEAD~3 &&
436 git commit --amend -m "b" &&
437 git rebase --continue &&
438 git reset HEAD^ &&
439 cat >expected <<EOF &&
440 interactive rebase in progress; onto $ONTO
441 Last commands done (2 commands done):
442 edit $COMMIT2 two_edits
443 edit $COMMIT3 three_edits
444 Next command to do (1 remaining command):
445 pick $COMMIT4 four_edits
446 (use "git rebase --edit-todo" to view and edit)
447 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
448 (Once your working directory is clean, run "git rebase --continue")
450 Changes not staged for commit:
451 (use "git add <file>..." to update what will be committed)
452 (use "git restore <file>..." to discard changes in working directory)
453 modified: main.txt
455 no changes added to commit (use "git add" and/or "git commit -a")
457 git status --untracked-files=no >actual &&
458 test_cmp expected actual
462 test_expect_success 'status: (amend first edit) second edit and amend' '
463 git reset --hard several_edits &&
464 FAKE_LINES="edit 1 edit 2 3" &&
465 export FAKE_LINES &&
466 test_when_finished "git rebase --abort" &&
467 COMMIT2=$(git rev-parse --short several_edits^^) &&
468 COMMIT3=$(git rev-parse --short several_edits^) &&
469 COMMIT4=$(git rev-parse --short several_edits) &&
470 ONTO=$(git rev-parse --short HEAD~3) &&
471 git rebase -i HEAD~3 &&
472 git commit --amend -m "c" &&
473 git rebase --continue &&
474 git commit --amend -m "d" &&
475 cat >expected <<EOF &&
476 interactive rebase in progress; onto $ONTO
477 Last commands done (2 commands done):
478 edit $COMMIT2 two_edits
479 edit $COMMIT3 three_edits
480 Next command to do (1 remaining command):
481 pick $COMMIT4 four_edits
482 (use "git rebase --edit-todo" to view and edit)
483 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
484 (use "git commit --amend" to amend the current commit)
485 (use "git rebase --continue" once you are satisfied with your changes)
487 nothing to commit (use -u to show untracked files)
489 git status --untracked-files=no >actual &&
490 test_cmp expected actual
494 test_expect_success 'status: (split first edit) second edit' '
495 git reset --hard several_edits &&
496 FAKE_LINES="edit 1 edit 2 3" &&
497 export FAKE_LINES &&
498 test_when_finished "git rebase --abort" &&
499 COMMIT2=$(git rev-parse --short several_edits^^) &&
500 COMMIT3=$(git rev-parse --short several_edits^) &&
501 COMMIT4=$(git rev-parse --short several_edits) &&
502 ONTO=$(git rev-parse --short HEAD~3) &&
503 git rebase -i HEAD~3 &&
504 git reset HEAD^ &&
505 git add main.txt &&
506 git commit -m "e" &&
507 git rebase --continue &&
508 cat >expected <<EOF &&
509 interactive rebase in progress; onto $ONTO
510 Last commands done (2 commands done):
511 edit $COMMIT2 two_edits
512 edit $COMMIT3 three_edits
513 Next command to do (1 remaining command):
514 pick $COMMIT4 four_edits
515 (use "git rebase --edit-todo" to view and edit)
516 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
517 (use "git commit --amend" to amend the current commit)
518 (use "git rebase --continue" once you are satisfied with your changes)
520 nothing to commit (use -u to show untracked files)
522 git status --untracked-files=no >actual &&
523 test_cmp expected actual
527 test_expect_success 'status: (split first edit) second edit and split' '
528 git reset --hard several_edits &&
529 FAKE_LINES="edit 1 edit 2 3" &&
530 export FAKE_LINES &&
531 test_when_finished "git rebase --abort" &&
532 COMMIT2=$(git rev-parse --short several_edits^^) &&
533 COMMIT3=$(git rev-parse --short several_edits^) &&
534 COMMIT4=$(git rev-parse --short several_edits) &&
535 ONTO=$(git rev-parse --short HEAD~3) &&
536 git rebase -i HEAD~3 &&
537 git reset HEAD^ &&
538 git add main.txt &&
539 git commit --amend -m "f" &&
540 git rebase --continue &&
541 git reset HEAD^ &&
542 cat >expected <<EOF &&
543 interactive rebase in progress; onto $ONTO
544 Last commands done (2 commands done):
545 edit $COMMIT2 two_edits
546 edit $COMMIT3 three_edits
547 Next command to do (1 remaining command):
548 pick $COMMIT4 four_edits
549 (use "git rebase --edit-todo" to view and edit)
550 You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
551 (Once your working directory is clean, run "git rebase --continue")
553 Changes not staged for commit:
554 (use "git add <file>..." to update what will be committed)
555 (use "git restore <file>..." to discard changes in working directory)
556 modified: main.txt
558 no changes added to commit (use "git add" and/or "git commit -a")
560 git status --untracked-files=no >actual &&
561 test_cmp expected actual
565 test_expect_success 'status: (split first edit) second edit and amend' '
566 git reset --hard several_edits &&
567 FAKE_LINES="edit 1 edit 2 3" &&
568 export FAKE_LINES &&
569 test_when_finished "git rebase --abort" &&
570 COMMIT2=$(git rev-parse --short several_edits^^) &&
571 COMMIT3=$(git rev-parse --short several_edits^) &&
572 COMMIT4=$(git rev-parse --short several_edits) &&
573 ONTO=$(git rev-parse --short HEAD~3) &&
574 git rebase -i HEAD~3 &&
575 git reset HEAD^ &&
576 git add main.txt &&
577 git commit --amend -m "g" &&
578 git rebase --continue &&
579 git commit --amend -m "h" &&
580 cat >expected <<EOF &&
581 interactive rebase in progress; onto $ONTO
582 Last commands done (2 commands done):
583 edit $COMMIT2 two_edits
584 edit $COMMIT3 three_edits
585 Next command to do (1 remaining command):
586 pick $COMMIT4 four_edits
587 (use "git rebase --edit-todo" to view and edit)
588 You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
589 (use "git commit --amend" to amend the current commit)
590 (use "git rebase --continue" once you are satisfied with your changes)
592 nothing to commit (use -u to show untracked files)
594 git status --untracked-files=no >actual &&
595 test_cmp expected actual
599 test_expect_success 'prepare am_session' '
600 git reset --hard main &&
601 git checkout -b am_session &&
602 test_commit one_am one.txt "one" &&
603 test_commit two_am two.txt "two" &&
604 test_commit three_am three.txt "three"
608 test_expect_success 'status in an am session: file already exists' '
609 git checkout -b am_already_exists &&
610 test_when_finished "rm Maildir/* && git am --abort" &&
611 git format-patch -1 -oMaildir &&
612 test_must_fail git am Maildir/*.patch &&
613 cat >expected <<\EOF &&
614 On branch am_already_exists
615 You are in the middle of an am session.
616 (fix conflicts and then run "git am --continue")
617 (use "git am --skip" to skip this patch)
618 (use "git am --abort" to restore the original branch)
620 nothing to commit (use -u to show untracked files)
622 git status --untracked-files=no >actual &&
623 test_cmp expected actual
627 test_expect_success 'status in an am session: file does not exist' '
628 git reset --hard am_session &&
629 git checkout -b am_not_exists &&
630 git rm three.txt &&
631 git commit -m "delete three.txt" &&
632 test_when_finished "rm Maildir/* && git am --abort" &&
633 git format-patch -1 -oMaildir &&
634 test_must_fail git am Maildir/*.patch &&
635 cat >expected <<\EOF &&
636 On branch am_not_exists
637 You are in the middle of an am session.
638 (fix conflicts and then run "git am --continue")
639 (use "git am --skip" to skip this patch)
640 (use "git am --abort" to restore the original branch)
642 nothing to commit (use -u to show untracked files)
644 git status --untracked-files=no >actual &&
645 test_cmp expected actual
649 test_expect_success 'status in an am session: empty patch' '
650 git reset --hard am_session &&
651 git checkout -b am_empty &&
652 test_when_finished "rm Maildir/* && git am --abort" &&
653 git format-patch -3 -oMaildir &&
654 git rm one.txt two.txt three.txt &&
655 git commit -m "delete all am_empty" &&
656 echo error >Maildir/0002-two_am.patch &&
657 test_must_fail git am Maildir/*.patch &&
658 cat >expected <<\EOF &&
659 On branch am_empty
660 You are in the middle of an am session.
661 The current patch is empty.
662 (use "git am --skip" to skip this patch)
663 (use "git am --allow-empty" to record this patch as an empty commit)
664 (use "git am --abort" to restore the original branch)
666 nothing to commit (use -u to show untracked files)
668 git status --untracked-files=no >actual &&
669 test_cmp expected actual
673 test_expect_success 'status when bisecting' '
674 git reset --hard main &&
675 git checkout -b bisect &&
676 test_commit one_bisect main.txt one &&
677 test_commit two_bisect main.txt two &&
678 test_commit three_bisect main.txt three &&
679 test_when_finished "git bisect reset" &&
680 git bisect start &&
681 git bisect bad &&
682 git bisect good one_bisect &&
683 TGT=$(git rev-parse --short two_bisect) &&
684 cat >expected <<EOF &&
685 HEAD detached at $TGT
686 You are currently bisecting, started from branch '\''bisect'\''.
687 (use "git bisect reset" to get back to the original branch)
689 nothing to commit (use -u to show untracked files)
691 git status --untracked-files=no >actual &&
692 test_cmp expected actual
696 test_expect_success 'status when bisecting while rebasing' '
697 git reset --hard main &&
698 test_when_finished "git rebase --abort" &&
699 ONTO=$(git rev-parse --short HEAD^) &&
700 FAKE_LINES="break" git rebase -i HEAD^ &&
701 test_when_finished "git checkout -" &&
702 git checkout -b bisect_while_rebasing &&
703 test_when_finished "git bisect reset" &&
704 git bisect start &&
705 cat >expected <<EOF &&
706 On branch bisect_while_rebasing
707 Last command done (1 command done):
708 break
709 No commands remaining.
710 You are currently editing a commit while rebasing branch '\''bisect'\'' on '\''$ONTO'\''.
711 (use "git commit --amend" to amend the current commit)
712 (use "git rebase --continue" once you are satisfied with your changes)
714 You are currently bisecting, started from branch '\''bisect_while_rebasing'\''.
715 (use "git bisect reset" to get back to the original branch)
717 nothing to commit (use -u to show untracked files)
719 git status --untracked-files=no >actual &&
720 test_cmp expected actual
724 test_expect_success 'status when rebase --apply conflicts with statushints disabled' '
725 git reset --hard main &&
726 git checkout -b statushints_disabled &&
727 test_when_finished "git config --local advice.statushints true" &&
728 git config --local advice.statushints false &&
729 test_commit one_statushints main.txt one &&
730 test_commit two_statushints main.txt two &&
731 test_commit three_statushints main.txt three &&
732 test_when_finished "git rebase --abort" &&
733 ONTO=$(git rev-parse --short HEAD^^) &&
734 test_must_fail git rebase --apply HEAD^ --onto HEAD^^ &&
735 cat >expected <<EOF &&
736 rebase in progress; onto $ONTO
737 You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
739 Unmerged paths:
740 both modified: main.txt
742 no changes added to commit
744 git status --untracked-files=no >actual &&
745 test_cmp expected actual
749 test_expect_success 'prepare for cherry-pick conflicts' '
750 git reset --hard main &&
751 git checkout -b cherry_branch &&
752 test_commit one_cherry main.txt one &&
753 test_commit two_cherries main.txt two &&
754 git checkout -b cherry_branch_second &&
755 test_commit second_cherry main.txt second &&
756 git checkout cherry_branch &&
757 test_commit three_cherries main.txt three
761 test_expect_success 'status when cherry-picking before resolving conflicts' '
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 cat >expected <<EOF &&
766 On branch cherry_branch
767 You are currently cherry-picking commit $TO_CHERRY_PICK.
768 (fix conflicts and run "git cherry-pick --continue")
769 (use "git cherry-pick --skip" to skip this patch)
770 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
772 Unmerged paths:
773 (use "git add <file>..." to mark resolution)
774 both modified: main.txt
776 no changes added to commit (use "git add" and/or "git commit -a")
778 git status --untracked-files=no >actual &&
779 test_cmp expected actual
783 test_expect_success 'status when cherry-picking after resolving conflicts' '
784 git reset --hard cherry_branch &&
785 test_when_finished "git cherry-pick --abort" &&
786 test_must_fail git cherry-pick cherry_branch_second &&
787 TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
788 echo end >main.txt &&
789 git add main.txt &&
790 cat >expected <<EOF &&
791 On branch cherry_branch
792 You are currently cherry-picking commit $TO_CHERRY_PICK.
793 (all conflicts fixed: run "git cherry-pick --continue")
794 (use "git cherry-pick --skip" to skip this patch)
795 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
797 Changes to be committed:
798 modified: main.txt
800 Untracked files not listed (use -u option to show untracked files)
802 git status --untracked-files=no >actual &&
803 test_cmp expected actual
806 test_expect_success 'status when cherry-picking multiple commits' '
807 git reset --hard cherry_branch &&
808 test_when_finished "git cherry-pick --abort" &&
809 test_must_fail git cherry-pick cherry_branch_second one_cherry &&
810 TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
811 cat >expected <<EOF &&
812 On branch cherry_branch
813 You are currently cherry-picking commit $TO_CHERRY_PICK.
814 (fix conflicts and run "git cherry-pick --continue")
815 (use "git cherry-pick --skip" to skip this patch)
816 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
818 Unmerged paths:
819 (use "git add <file>..." to mark resolution)
820 both modified: main.txt
822 no changes added to commit (use "git add" and/or "git commit -a")
824 git status --untracked-files=no >actual &&
825 test_cmp expected actual
828 test_expect_success 'status when cherry-picking after committing conflict resolution' '
829 git reset --hard cherry_branch &&
830 test_when_finished "git cherry-pick --abort" &&
831 test_must_fail git cherry-pick cherry_branch_second one_cherry &&
832 echo end >main.txt &&
833 git commit -a &&
834 cat >expected <<EOF &&
835 On branch cherry_branch
836 Cherry-pick currently in progress.
837 (run "git cherry-pick --continue" to continue)
838 (use "git cherry-pick --skip" to skip this patch)
839 (use "git cherry-pick --abort" to cancel the cherry-pick operation)
841 nothing to commit (use -u to show untracked files)
843 git status --untracked-files=no >actual &&
844 test_cmp expected actual
847 test_expect_success 'status shows cherry-pick with invalid oid' '
848 mkdir .git/sequencer &&
849 test_write_lines "pick invalid-oid" >.git/sequencer/todo &&
850 git status --untracked-files=no >actual 2>err &&
851 git cherry-pick --quit &&
852 test_must_be_empty err &&
853 test_cmp expected actual
856 test_expect_success 'status does not show error if .git/sequencer is a file' '
857 test_when_finished "rm .git/sequencer" &&
858 test_write_lines hello >.git/sequencer &&
859 git status --untracked-files=no 2>err &&
860 test_must_be_empty err
863 test_expect_success 'status showing detached at and from a tag' '
864 test_commit atag tagging &&
865 git checkout atag &&
866 cat >expected <<\EOF &&
867 HEAD detached at atag
868 nothing to commit (use -u to show untracked files)
870 git status --untracked-files=no >actual &&
871 test_cmp expected actual &&
873 git reset --hard HEAD^ &&
874 cat >expected <<\EOF &&
875 HEAD detached from atag
876 nothing to commit (use -u to show untracked files)
878 git status --untracked-files=no >actual &&
879 test_cmp expected actual
882 test_expect_success 'status while reverting commit (conflicts)' '
883 git checkout main &&
884 echo before >to-revert.txt &&
885 test_commit before to-revert.txt &&
886 echo old >to-revert.txt &&
887 test_commit old to-revert.txt &&
888 echo new >to-revert.txt &&
889 test_commit new to-revert.txt &&
890 TO_REVERT=$(git rev-parse --short HEAD^) &&
891 test_must_fail git revert $TO_REVERT &&
892 cat >expected <<EOF &&
893 On branch main
894 You are currently reverting commit $TO_REVERT.
895 (fix conflicts and run "git revert --continue")
896 (use "git revert --skip" to skip this patch)
897 (use "git revert --abort" to cancel the revert operation)
899 Unmerged paths:
900 (use "git restore --staged <file>..." to unstage)
901 (use "git add <file>..." to mark resolution)
902 both modified: to-revert.txt
904 no changes added to commit (use "git add" and/or "git commit -a")
906 git status --untracked-files=no >actual &&
907 test_cmp expected actual
910 test_expect_success 'status while reverting commit (conflicts resolved)' '
911 echo reverted >to-revert.txt &&
912 git add to-revert.txt &&
913 cat >expected <<EOF &&
914 On branch main
915 You are currently reverting commit $TO_REVERT.
916 (all conflicts fixed: run "git revert --continue")
917 (use "git revert --skip" to skip this patch)
918 (use "git revert --abort" to cancel the revert operation)
920 Changes to be committed:
921 (use "git restore --staged <file>..." to unstage)
922 modified: to-revert.txt
924 Untracked files not listed (use -u option to show untracked files)
926 git status --untracked-files=no >actual &&
927 test_cmp expected actual
930 test_expect_success 'status after reverting commit' '
931 git revert --continue &&
932 cat >expected <<\EOF &&
933 On branch main
934 nothing to commit (use -u to show untracked files)
936 git status --untracked-files=no >actual &&
937 test_cmp expected actual
940 test_expect_success 'status while reverting after committing conflict resolution' '
941 test_when_finished "git revert --abort" &&
942 git reset --hard new &&
943 test_must_fail git revert old new &&
944 echo reverted >to-revert.txt &&
945 git commit -a &&
946 cat >expected <<EOF &&
947 On branch main
948 Revert currently in progress.
949 (run "git revert --continue" to continue)
950 (use "git revert --skip" to skip this patch)
951 (use "git revert --abort" to cancel the revert operation)
953 nothing to commit (use -u to show untracked files)
955 git status --untracked-files=no >actual &&
956 test_cmp expected actual
959 test_expect_success 'prepare for different number of commits rebased' '
960 git reset --hard main &&
961 git checkout -b several_commits &&
962 test_commit one_commit main.txt one &&
963 test_commit two_commit main.txt two &&
964 test_commit three_commit main.txt three &&
965 test_commit four_commit main.txt four
968 test_expect_success 'status: one command done nothing remaining' '
969 FAKE_LINES="exec_exit_15" &&
970 export FAKE_LINES &&
971 test_when_finished "git rebase --abort" &&
972 ONTO=$(git rev-parse --short HEAD~3) &&
973 test_must_fail git rebase -i HEAD~3 &&
974 cat >expected <<EOF &&
975 interactive rebase in progress; onto $ONTO
976 Last command done (1 command done):
977 exec exit 15
978 No commands remaining.
979 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
980 (use "git commit --amend" to amend the current commit)
981 (use "git rebase --continue" once you are satisfied with your changes)
983 nothing to commit (use -u to show untracked files)
985 git status --untracked-files=no >actual &&
986 test_cmp expected actual
989 test_expect_success 'status: two commands done with some white lines in done file' '
990 FAKE_LINES="1 > exec_exit_15 2 3" &&
991 export FAKE_LINES &&
992 test_when_finished "git rebase --abort" &&
993 ONTO=$(git rev-parse --short HEAD~3) &&
994 COMMIT4=$(git rev-parse --short HEAD) &&
995 COMMIT3=$(git rev-parse --short HEAD^) &&
996 COMMIT2=$(git rev-parse --short HEAD^^) &&
997 test_must_fail git rebase -i HEAD~3 &&
998 cat >expected <<EOF &&
999 interactive rebase in progress; onto $ONTO
1000 Last commands done (2 commands done):
1001 pick $COMMIT2 two_commit
1002 exec exit 15
1003 Next commands to do (2 remaining commands):
1004 pick $COMMIT3 three_commit
1005 pick $COMMIT4 four_commit
1006 (use "git rebase --edit-todo" to view and edit)
1007 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
1008 (use "git commit --amend" to amend the current commit)
1009 (use "git rebase --continue" once you are satisfied with your changes)
1011 nothing to commit (use -u to show untracked files)
1013 git status --untracked-files=no >actual &&
1014 test_cmp expected actual
1017 test_expect_success 'status: two remaining commands with some white lines in todo file' '
1018 FAKE_LINES="1 2 exec_exit_15 3 > 4" &&
1019 export FAKE_LINES &&
1020 test_when_finished "git rebase --abort" &&
1021 ONTO=$(git rev-parse --short HEAD~4) &&
1022 COMMIT4=$(git rev-parse --short HEAD) &&
1023 COMMIT3=$(git rev-parse --short HEAD^) &&
1024 COMMIT2=$(git rev-parse --short HEAD^^) &&
1025 test_must_fail git rebase -i HEAD~4 &&
1026 cat >expected <<EOF &&
1027 interactive rebase in progress; onto $ONTO
1028 Last commands done (3 commands done):
1029 pick $COMMIT2 two_commit
1030 exec exit 15
1031 (see more in file .git/rebase-merge/done)
1032 Next commands to do (2 remaining commands):
1033 pick $COMMIT3 three_commit
1034 pick $COMMIT4 four_commit
1035 (use "git rebase --edit-todo" to view and edit)
1036 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
1037 (use "git commit --amend" to amend the current commit)
1038 (use "git rebase --continue" once you are satisfied with your changes)
1040 nothing to commit (use -u to show untracked files)
1042 git status --untracked-files=no >actual &&
1043 test_cmp expected actual
1046 test_expect_success 'status: handle not-yet-started rebase -i gracefully' '
1047 ONTO=$(git rev-parse --short HEAD^) &&
1048 COMMIT=$(git rev-parse --short HEAD) &&
1049 EDITOR="git status --untracked-files=no >actual" git rebase -i HEAD^ &&
1050 cat >expected <<EOF &&
1051 On branch several_commits
1052 No commands done.
1053 Next command to do (1 remaining command):
1054 pick $COMMIT four_commit
1055 (use "git rebase --edit-todo" to view and edit)
1056 You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
1057 (use "git commit --amend" to amend the current commit)
1058 (use "git rebase --continue" once you are satisfied with your changes)
1060 nothing to commit (use -u to show untracked files)
1062 test_cmp expected actual
1065 test_done