Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t7512-status-help.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t7512-status-help.sh` 1095 lines ยท 36702 bytes Raw Blame History 1 #!/bin/sh 2 # 3 # Copyright (c) 2012 Valentin Duperray, Lucien Kong, Franck Jonas, 4 # Thomas Nguy, Khoi Nguyen 5 # Grenoble INP Ensimag 6 # 7 8 test_description='git status advice' 9 10 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 11 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 12 13 . ./test-lib.sh 14 15 . "$TEST_DIRECTORY"/lib-rebase.sh 16 17 set_fake_editor 18 19 test_expect_success 'prepare for conflicts' ' 20 git config --global advice.statusuoption false && 21 test_commit init main.txt init && 22 git branch conflicts && 23 test_commit on_main main.txt on_main && 24 git checkout conflicts && 25 test_commit on_conflicts main.txt on_conflicts 26 ' 27 28 29 test_expect_success 'status when conflicts unresolved' ' 30 test_must_fail git merge main && 31 cat >expected <<\EOF && 32 On branch conflicts 33 You have unmerged paths. 34 (fix conflicts and run "git merge --continue") 35 (use "git merge --abort" to abort the merge) 36 37 Unmerged paths: 38 (use "git add ..." to mark resolution) 39 both modified: main.txt 40 41 no changes added to commit (use "git add" and/or "git commit -a") 42 EOF 43 git status --untracked-files=no >actual && 44 test_cmp expected actual 45 ' 46 47 48 test_expect_success 'status when conflicts resolved before commit' ' 49 git reset --hard conflicts && 50 test_must_fail git merge main && 51 echo one >main.txt && 52 git add main.txt && 53 cat >expected <<\EOF && 54 On branch conflicts 55 All conflicts fixed but you are still merging. 56 (use "git merge --continue" to conclude the merge) 57 58 Changes to be committed: 59 modified: main.txt 60 61 Untracked files not listed (use -u option to show untracked files) 62 EOF 63 git status --untracked-files=no >actual && 64 test_cmp expected actual 65 ' 66 67 68 test_expect_success 'prepare for rebase conflicts' ' 69 git reset --hard main && 70 git checkout -b rebase_conflicts && 71 test_commit one_rebase main.txt one && 72 test_commit two_rebase main.txt two && 73 test_commit three_rebase main.txt three 74 ' 75 76 77 test_expect_success 'status when rebase --apply in progress before resolving conflicts' ' 78 test_when_finished "git rebase --abort" && 79 ONTO=$(git rev-parse --short HEAD^^) && 80 test_must_fail git rebase --apply HEAD^ --onto HEAD^^ && 81 cat >expected <..." to unstage) 90 (use "git add ..." to mark resolution) 91 both modified: main.txt 92 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_cmp expected actual 97 ' 98 99 100 test_expect_success 'status when rebase --apply 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 --apply HEAD^ --onto HEAD^^ && 105 echo three >main.txt && 106 git add main.txt && 107 cat >expected <..." to unstage) 114 modified: main.txt 115 116 Untracked files not listed (use -u option to show untracked files) 117 EOF 118 git status --untracked-files=no >actual && 119 test_cmp expected actual 120 ' 121 122 123 test_expect_success 'prepare for rebase_i_conflicts' ' 124 git reset --hard main && 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_main main.txt one_main && 129 git checkout rebase_i_conflicts_second && 130 test_commit one_second main.txt one_second 131 ' 132 133 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 <..." to unstage) 151 (use "git add ..." to mark resolution) 152 both modified: main.txt 153 154 no changes added to commit (use "git add" and/or "git commit -a") 155 EOF 156 git status --untracked-files=no >actual && 157 test_cmp expected actual 158 ' 159 160 161 test_expect_success 'status during rebase -i after resolving conflicts' ' 162 git reset --hard rebase_i_conflicts_second && 163 test_when_finished "git rebase --abort" && 164 ONTO=$(git rev-parse --short rebase_i_conflicts) && 165 LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) && 166 test_must_fail git rebase -i rebase_i_conflicts && 167 git add main.txt && 168 cat >expected <..." to unstage) 178 modified: main.txt 179 180 Untracked files not listed (use -u option to show untracked files) 181 EOF 182 git status --untracked-files=no >actual && 183 test_cmp expected actual 184 ' 185 186 187 test_expect_success 'status when rebasing -i in edit mode' ' 188 git reset --hard main && 189 git checkout -b rebase_i_edit && 190 test_commit one_rebase_i main.txt one && 191 test_commit two_rebase_i main.txt two && 192 COMMIT2=$(git rev-parse --short rebase_i_edit) && 193 test_commit three_rebase_i main.txt three && 194 COMMIT3=$(git rev-parse --short rebase_i_edit) && 195 FAKE_LINES="1 edit 2" && 196 export FAKE_LINES && 197 test_when_finished "git rebase --abort" && 198 ONTO=$(git rev-parse --short HEAD~2) && 199 git rebase -i HEAD~2 && 200 cat >expected <actual && 213 test_cmp expected actual 214 ' 215 216 217 test_expect_success 'status when splitting a commit' ' 218 git reset --hard main && 219 git checkout -b split_commit && 220 test_commit one_split main.txt one && 221 test_commit two_split main.txt two && 222 COMMIT2=$(git rev-parse --short split_commit) && 223 test_commit three_split main.txt three && 224 COMMIT3=$(git rev-parse --short split_commit) && 225 test_commit four_split main.txt four && 226 COMMIT4=$(git rev-parse --short split_commit) && 227 FAKE_LINES="reword 1 edit 2 fixup_-C 3" && 228 export FAKE_LINES && 229 test_when_finished "git rebase --abort" && 230 ONTO=$(git rev-parse --short HEAD~3) && 231 git rebase -i HEAD~3 && 232 git reset HEAD^ && 233 cat >expected <..." to update what will be committed) 246 (use "git restore ..." to discard changes in working directory) 247 modified: main.txt 248 249 no changes added to commit (use "git add" and/or "git commit -a") 250 EOF 251 git status --untracked-files=no >actual && 252 test_cmp expected actual 253 ' 254 255 256 test_expect_success 'status after editing the last commit with --amend during a rebase -i' ' 257 git reset --hard main && 258 git checkout -b amend_last && 259 test_commit one_amend main.txt one && 260 test_commit two_amend main.txt two && 261 test_commit three_amend main.txt three && 262 COMMIT3=$(git rev-parse --short amend_last) && 263 test_commit four_amend main.txt four && 264 COMMIT4=$(git rev-parse --short amend_last) && 265 FAKE_LINES="1 2 edit 3" && 266 export FAKE_LINES && 267 test_when_finished "git rebase --abort" && 268 ONTO=$(git rev-parse --short HEAD~3) && 269 git rebase -i HEAD~3 && 270 git commit --amend -m "foo" && 271 cat >expected <actual && 285 test_cmp expected actual 286 ' 287 288 289 test_expect_success 'prepare for several edits' ' 290 git reset --hard main && 291 git checkout -b several_edits && 292 test_commit one_edits main.txt one && 293 test_commit two_edits main.txt two && 294 test_commit three_edits main.txt three && 295 test_commit four_edits main.txt four 296 ' 297 298 299 test_expect_success 'status: (continue first edit) second edit' ' 300 FAKE_LINES="edit 1 edit 2 drop 3" && 301 export FAKE_LINES && 302 test_when_finished "git rebase --abort" && 303 COMMIT2=$(git rev-parse --short several_edits^^) && 304 COMMIT3=$(git rev-parse --short several_edits^) && 305 COMMIT4=$(git rev-parse --short several_edits) && 306 ONTO=$(git rev-parse --short HEAD~3) && 307 git rebase -i HEAD~3 && 308 git rebase --continue && 309 cat >expected <actual && 324 test_cmp expected actual 325 ' 326 327 328 test_expect_success 'status: (continue first edit) second edit and split' ' 329 git reset --hard several_edits && 330 FAKE_LINES="edit 1 edit 2 squash 3" && 331 export FAKE_LINES && 332 test_when_finished "git rebase --abort" && 333 COMMIT2=$(git rev-parse --short several_edits^^) && 334 COMMIT3=$(git rev-parse --short several_edits^) && 335 COMMIT4=$(git rev-parse --short several_edits) && 336 ONTO=$(git rev-parse --short HEAD~3) && 337 git rebase -i HEAD~3 && 338 git rebase --continue && 339 git reset HEAD^ && 340 cat >expected <..." to update what will be committed) 353 (use "git restore ..." to discard changes in working directory) 354 modified: main.txt 355 356 no changes added to commit (use "git add" and/or "git commit -a") 357 EOF 358 git status --untracked-files=no >actual && 359 test_cmp expected actual 360 ' 361 362 363 test_expect_success 'status: (continue first edit) second edit and amend' ' 364 git reset --hard several_edits && 365 FAKE_LINES="edit 1 edit 2 fixup 3" && 366 export FAKE_LINES && 367 test_when_finished "git rebase --abort" && 368 COMMIT2=$(git rev-parse --short several_edits^^) && 369 COMMIT3=$(git rev-parse --short several_edits^) && 370 COMMIT4=$(git rev-parse --short several_edits) && 371 ONTO=$(git rev-parse --short HEAD~3) && 372 git rebase -i HEAD~3 && 373 git rebase --continue && 374 git commit --amend -m "foo" && 375 cat >expected <actual && 390 test_cmp expected actual 391 ' 392 393 394 test_expect_success 'status: (amend first edit) second edit' ' 395 git reset --hard several_edits && 396 FAKE_LINES="edit 1 edit 2 fixup_-c 3" && 397 export FAKE_LINES && 398 test_when_finished "git rebase --abort" && 399 COMMIT2=$(git rev-parse --short several_edits^^) && 400 COMMIT3=$(git rev-parse --short several_edits^) && 401 COMMIT4=$(git rev-parse --short several_edits) && 402 ONTO=$(git rev-parse --short HEAD~3) && 403 git rebase -i HEAD~3 && 404 git commit --amend -m "a" && 405 git rebase --continue && 406 cat >expected <actual && 421 test_cmp expected actual 422 ' 423 424 425 test_expect_success 'status: (amend first edit) second edit and split' ' 426 git reset --hard several_edits && 427 FAKE_LINES="edit 1 edit 2 3" && 428 export FAKE_LINES && 429 test_when_finished "git rebase --abort" && 430 ONTO=$(git rev-parse --short HEAD~3) && 431 COMMIT2=$(git rev-parse --short several_edits^^) && 432 COMMIT3=$(git rev-parse --short several_edits^) && 433 COMMIT4=$(git rev-parse --short several_edits) && 434 git rebase -i HEAD~3 && 435 git commit --amend -m "b" && 436 git rebase --continue && 437 git reset HEAD^ && 438 cat >expected <..." to update what will be committed) 451 (use "git restore ..." to discard changes in working directory) 452 modified: main.txt 453 454 no changes added to commit (use "git add" and/or "git commit -a") 455 EOF 456 git status --untracked-files=no >actual && 457 test_cmp expected actual 458 ' 459 460 461 test_expect_success 'status: (amend first edit) second edit and amend' ' 462 git reset --hard several_edits && 463 test_when_finished "git rebase --abort" && 464 COMMIT2=$(git rev-parse --short several_edits^^) && 465 COMMIT3=$(git rev-parse --short several_edits^) && 466 COMMIT4=$(git rev-parse --short several_edits) && 467 ONTO=$(git rev-parse --short HEAD~3) && 468 cat >todo <<-EOF && 469 edit several_edits^^ # two_edits 470 edit several_edits^ # three_edits 471 merge $(git rev-parse main) $(git rev-parse several_edits) 472 EOF 473 ( 474 set_replace_editor todo && 475 git rebase -i HEAD~3 476 ) && 477 git commit --amend -m "c" && 478 git rebase --continue && 479 git commit --amend -m "d" && 480 cat >expected <actual && 495 test_cmp expected actual 496 ' 497 498 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 <actual && 528 test_cmp expected actual 529 ' 530 531 532 test_expect_success 'status: (split first edit) second edit and split' ' 533 git reset --hard several_edits && 534 test_when_finished "git rebase --abort" && 535 COMMIT2=$(git rev-parse --short several_edits^^) && 536 COMMIT3=$(git rev-parse --short several_edits^) && 537 COMMIT4=$(git rev-parse --short several_edits) && 538 cat >todo <<-EOF && 539 edit several_edits^^ # two_edits 540 edit several_edits^ # three_edits 541 reset $(git rev-parse main) 542 merge -C several_edits topic # title 543 EOF 544 ONTO=$(git rev-parse --short HEAD~3) && 545 ( 546 set_replace_editor todo && 547 git rebase -i HEAD~3 548 ) && 549 git reset HEAD^ && 550 git add main.txt && 551 git commit --amend -m "f" && 552 git rebase --continue && 553 git reset HEAD^ && 554 cat >expected <..." to update what will be committed) 568 (use "git restore ..." to discard changes in working directory) 569 modified: main.txt 570 571 no changes added to commit (use "git add" and/or "git commit -a") 572 EOF 573 git status --untracked-files=no >actual && 574 test_cmp expected actual 575 ' 576 577 578 test_expect_success 'status: (split first edit) second edit and amend' ' 579 git reset --hard several_edits && 580 test_when_finished "git rebase --abort" && 581 git branch cafe main && 582 COMMIT2=$(git rev-parse --short several_edits^^) && 583 COMMIT3=$(git rev-parse --short several_edits^) && 584 cat >todo <<-EOF && 585 edit several_edits^^ # two_edits 586 edit several_edits^ # three_edits 587 update-ref refs/heads/main 588 reset cafe 589 EOF 590 ONTO=$(git rev-parse --short HEAD~3) && 591 ( 592 set_replace_editor todo && 593 git rebase -i HEAD~3 594 ) && 595 git reset HEAD^ && 596 git add main.txt && 597 git commit --amend -m "g" && 598 git rebase --continue && 599 git commit --amend -m "h" && 600 cat >expected <actual && 616 test_cmp expected actual 617 ' 618 619 test_expect_success 'rebase in a linked worktree' ' 620 test_might_fail git rebase --abort && 621 git worktree add wt && 622 test_when_finished "test_might_fail git -C wt rebase --abort; 623 git worktree remove wt" && 624 GIT_SEQUENCE_EDITOR="echo break >" git -C wt rebase -i HEAD && 625 git -C wt status >actual && 626 test_grep "interactive rebase in progress" actual 627 ' 628 629 test_expect_success 'prepare am_session' ' 630 git reset --hard main && 631 git checkout -b am_session && 632 test_commit one_am one.txt "one" && 633 test_commit two_am two.txt "two" && 634 test_commit three_am three.txt "three" 635 ' 636 637 638 test_expect_success 'status in an am session: file already exists' ' 639 git checkout -b am_already_exists && 640 test_when_finished "rm Maildir/* && git am --abort" && 641 git format-patch -1 -oMaildir && 642 test_must_fail git am Maildir/*.patch && 643 cat >expected <<\EOF && 644 On branch am_already_exists 645 You are in the middle of an am session. 646 (fix conflicts and then run "git am --continue") 647 (use "git am --skip" to skip this patch) 648 (use "git am --abort" to restore the original branch) 649 650 nothing to commit (use -u to show untracked files) 651 EOF 652 git status --untracked-files=no >actual && 653 test_cmp expected actual 654 ' 655 656 657 test_expect_success 'status in an am session: file does not exist' ' 658 git reset --hard am_session && 659 git checkout -b am_not_exists && 660 git rm three.txt && 661 git commit -m "delete three.txt" && 662 test_when_finished "rm Maildir/* && git am --abort" && 663 git format-patch -1 -oMaildir && 664 test_must_fail git am Maildir/*.patch && 665 cat >expected <<\EOF && 666 On branch am_not_exists 667 You are in the middle of an am session. 668 (fix conflicts and then run "git am --continue") 669 (use "git am --skip" to skip this patch) 670 (use "git am --abort" to restore the original branch) 671 672 nothing to commit (use -u to show untracked files) 673 EOF 674 git status --untracked-files=no >actual && 675 test_cmp expected actual 676 ' 677 678 679 test_expect_success 'status in an am session: empty patch' ' 680 git reset --hard am_session && 681 git checkout -b am_empty && 682 test_when_finished "rm Maildir/* && git am --abort" && 683 git format-patch -3 -oMaildir && 684 git rm one.txt two.txt three.txt && 685 git commit -m "delete all am_empty" && 686 echo error >Maildir/0002-two_am.patch && 687 test_must_fail git am Maildir/*.patch && 688 cat >expected <<\EOF && 689 On branch am_empty 690 You are in the middle of an am session. 691 The current patch is empty. 692 (use "git am --skip" to skip this patch) 693 (use "git am --allow-empty" to record this patch as an empty commit) 694 (use "git am --abort" to restore the original branch) 695 696 nothing to commit (use -u to show untracked files) 697 EOF 698 git status --untracked-files=no >actual && 699 test_cmp expected actual 700 ' 701 702 703 test_expect_success 'status when bisecting' ' 704 git reset --hard main && 705 git checkout -b bisect && 706 test_commit one_bisect main.txt one && 707 test_commit two_bisect main.txt two && 708 test_commit three_bisect main.txt three && 709 test_when_finished "git bisect reset" && 710 git bisect start && 711 git bisect bad && 712 git bisect good one_bisect && 713 TGT=$(git rev-parse --short two_bisect) && 714 cat >expected <actual && 722 test_cmp expected actual 723 ' 724 725 726 test_expect_success 'status when bisecting while rebasing' ' 727 git reset --hard main && 728 test_when_finished "git rebase --abort" && 729 ONTO=$(git rev-parse --short HEAD^) && 730 FAKE_LINES="break" git rebase -i HEAD^ && 731 test_when_finished "git checkout -" && 732 git checkout -b bisect_while_rebasing && 733 test_when_finished "git bisect reset" && 734 git bisect start && 735 cat >expected <actual && 750 test_cmp expected actual 751 ' 752 753 754 test_expect_success 'status when rebase --apply conflicts with statushints disabled' ' 755 git reset --hard main && 756 git checkout -b statushints_disabled && 757 test_when_finished "git config --local advice.statushints true" && 758 git config --local advice.statushints false && 759 test_commit one_statushints main.txt one && 760 test_commit two_statushints main.txt two && 761 test_commit three_statushints main.txt three && 762 test_when_finished "git rebase --abort" && 763 ONTO=$(git rev-parse --short HEAD^^) && 764 test_must_fail git rebase --apply HEAD^ --onto HEAD^^ && 765 cat >expected <actual && 775 test_cmp expected actual 776 ' 777 778 779 test_expect_success 'prepare for cherry-pick conflicts' ' 780 git reset --hard main && 781 git checkout -b cherry_branch && 782 test_commit one_cherry main.txt one && 783 test_commit two_cherries main.txt two && 784 git checkout -b cherry_branch_second && 785 test_commit second_cherry main.txt second && 786 git checkout cherry_branch && 787 test_commit three_cherries main.txt three 788 ' 789 790 791 test_expect_success 'status when cherry-picking before resolving conflicts' ' 792 test_when_finished "git cherry-pick --abort" && 793 test_must_fail git cherry-pick cherry_branch_second && 794 TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) && 795 cat >expected <..." to mark resolution) 804 both modified: main.txt 805 806 no changes added to commit (use "git add" and/or "git commit -a") 807 EOF 808 git status --untracked-files=no >actual && 809 test_cmp expected actual 810 ' 811 812 813 test_expect_success 'status when cherry-picking after resolving conflicts' ' 814 git reset --hard cherry_branch && 815 test_when_finished "git cherry-pick --abort" && 816 test_must_fail git cherry-pick cherry_branch_second && 817 TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) && 818 echo end >main.txt && 819 git add main.txt && 820 cat >expected <actual && 833 test_cmp expected actual 834 ' 835 836 test_expect_success 'status when cherry-picking multiple commits' ' 837 git reset --hard cherry_branch && 838 test_when_finished "git cherry-pick --abort" && 839 test_must_fail git cherry-pick cherry_branch_second one_cherry && 840 TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) && 841 cat >expected <..." to mark resolution) 850 both modified: main.txt 851 852 no changes added to commit (use "git add" and/or "git commit -a") 853 EOF 854 git status --untracked-files=no >actual && 855 test_cmp expected actual 856 ' 857 858 test_expect_success 'status when cherry-picking after committing conflict resolution' ' 859 git reset --hard cherry_branch && 860 test_when_finished "git cherry-pick --abort" && 861 test_must_fail git cherry-pick cherry_branch_second one_cherry && 862 echo end >main.txt && 863 git commit -a && 864 cat >expected <actual && 874 test_cmp expected actual 875 ' 876 877 test_expect_success 'status shows cherry-pick with invalid oid' ' 878 mkdir .git/sequencer && 879 test_write_lines "pick invalid-oid" >.git/sequencer/todo && 880 git status --untracked-files=no >actual 2>err && 881 git cherry-pick --quit && 882 test_must_be_empty err && 883 test_cmp expected actual 884 ' 885 886 test_expect_success 'status does not show error if .git/sequencer is a file' ' 887 test_when_finished "rm .git/sequencer" && 888 test_write_lines hello >.git/sequencer && 889 git status --untracked-files=no 2>err && 890 test_must_be_empty err 891 ' 892 893 test_expect_success 'status showing detached at and from a tag' ' 894 test_commit atag tagging && 895 git checkout atag && 896 cat >expected <<\EOF && 897 HEAD detached at atag 898 nothing to commit (use -u to show untracked files) 899 EOF 900 git status --untracked-files=no >actual && 901 test_cmp expected actual && 902 903 git reset --hard HEAD^ && 904 cat >expected <<\EOF && 905 HEAD detached from atag 906 nothing to commit (use -u to show untracked files) 907 EOF 908 git status --untracked-files=no >actual && 909 test_cmp expected actual 910 ' 911 912 test_expect_success 'status while reverting commit (conflicts)' ' 913 git checkout main && 914 echo before >to-revert.txt && 915 test_commit before to-revert.txt && 916 echo old >to-revert.txt && 917 test_commit old to-revert.txt && 918 echo new >to-revert.txt && 919 test_commit new to-revert.txt && 920 TO_REVERT=$(git rev-parse --short HEAD^) && 921 test_must_fail git revert $TO_REVERT && 922 cat >expected <..." to unstage) 931 (use "git add ..." to mark resolution) 932 both modified: to-revert.txt 933 934 no changes added to commit (use "git add" and/or "git commit -a") 935 EOF 936 git status --untracked-files=no >actual && 937 test_cmp expected actual 938 ' 939 940 test_expect_success 'status while reverting commit (conflicts resolved)' ' 941 echo reverted >to-revert.txt && 942 git add to-revert.txt && 943 cat >expected <..." to unstage) 952 modified: to-revert.txt 953 954 Untracked files not listed (use -u option to show untracked files) 955 EOF 956 git status --untracked-files=no >actual && 957 test_cmp expected actual 958 ' 959 960 test_expect_success 'status after reverting commit' ' 961 git revert --continue && 962 cat >expected <<\EOF && 963 On branch main 964 nothing to commit (use -u to show untracked files) 965 EOF 966 git status --untracked-files=no >actual && 967 test_cmp expected actual 968 ' 969 970 test_expect_success 'status while reverting after committing conflict resolution' ' 971 test_when_finished "git revert --abort" && 972 git reset --hard new && 973 test_must_fail git revert old new && 974 echo reverted >to-revert.txt && 975 git commit -a && 976 cat >expected <actual && 986 test_cmp expected actual 987 ' 988 989 test_expect_success 'prepare for different number of commits rebased' ' 990 git reset --hard main && 991 git checkout -b several_commits && 992 test_commit one_commit main.txt one && 993 test_commit two_commit main.txt two && 994 test_commit three_commit main.txt three && 995 test_commit four_commit main.txt four 996 ' 997 998 test_expect_success 'status: one command done nothing remaining' ' 999 FAKE_LINES="exec_exit_15" && 1000 export FAKE_LINES && 1001 test_when_finished "git rebase --abort" && 1002 ONTO=$(git rev-parse --short HEAD~3) && 1003 test_must_fail git rebase -i HEAD~3 && 1004 cat >expected <actual && 1016 test_cmp expected actual 1017 ' 1018 1019 test_expect_success 'status: two commands done with some white lines in done file' ' 1020 FAKE_LINES="1 > exec_exit_15 2 3" && 1021 export FAKE_LINES && 1022 test_when_finished "git rebase --abort" && 1023 ONTO=$(git rev-parse --short HEAD~3) && 1024 COMMIT4=$(git rev-parse --short HEAD) && 1025 COMMIT3=$(git rev-parse --short HEAD^) && 1026 COMMIT2=$(git rev-parse --short HEAD^^) && 1027 test_must_fail git rebase -i HEAD~3 && 1028 cat >expected <actual && 1044 test_cmp expected actual 1045 ' 1046 1047 test_expect_success 'status: two remaining commands with some white lines in todo file' ' 1048 FAKE_LINES="1 2 exec_exit_15 3 > 4" && 1049 export FAKE_LINES && 1050 test_when_finished "git rebase --abort" && 1051 ONTO=$(git rev-parse --short HEAD~4) && 1052 COMMIT4=$(git rev-parse --short HEAD) && 1053 COMMIT3=$(git rev-parse --short HEAD^) && 1054 COMMIT2=$(git rev-parse --short HEAD^^) && 1055 test_must_fail git rebase -i HEAD~4 && 1056 cat >expected <actual && 1073 test_cmp expected actual 1074 ' 1075 1076 test_expect_success 'status: handle not-yet-started rebase -i gracefully' ' 1077 ONTO=$(git rev-parse --short HEAD^) && 1078 COMMIT=$(git rev-parse --short HEAD) && 1079 EDITOR="git status --untracked-files=no >actual" git rebase -i HEAD^ && 1080 cat >expected <