t / t7512-status-help.shon commit worktree: add: make -b/-B default to HEAD when <branch> is omitted (0f4af3b)
   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
   8test_description='git status advice'
   9
  10. ./test-lib.sh
  11
  12. "$TEST_DIRECTORY"/lib-rebase.sh
  13
  14set_fake_editor
  15
  16test_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
  23'
  24
  25
  26test_expect_success 'status when conflicts unresolved' '
  27        test_must_fail git merge master &&
  28        cat >expected <<\EOF &&
  29On branch conflicts
  30You have unmerged paths.
  31  (fix conflicts and run "git commit")
  32
  33Unmerged paths:
  34  (use "git add <file>..." to mark resolution)
  35
  36        both modified:   main.txt
  37
  38no changes added to commit (use "git add" and/or "git commit -a")
  39EOF
  40        git status --untracked-files=no >actual &&
  41        test_i18ncmp expected actual
  42'
  43
  44
  45test_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 &&
  51On branch conflicts
  52All conflicts fixed but you are still merging.
  53  (use "git commit" to conclude merge)
  54
  55Changes to be committed:
  56
  57        modified:   main.txt
  58
  59Untracked files not listed (use -u option to show untracked files)
  60EOF
  61        git status --untracked-files=no >actual &&
  62        test_i18ncmp expected actual
  63'
  64
  65
  66test_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
  72'
  73
  74
  75test_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 &&
  80rebase in progress; onto $ONTO
  81You 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)
  85
  86Unmerged paths:
  87  (use "git reset HEAD <file>..." to unstage)
  88  (use "git add <file>..." to mark resolution)
  89
  90        both modified:   main.txt
  91
  92no changes added to commit (use "git add" and/or "git commit -a")
  93EOF
  94        git status --untracked-files=no >actual &&
  95        test_i18ncmp expected actual
  96'
  97
  98
  99test_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 &&
 107rebase in progress; onto $ONTO
 108You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
 109  (all conflicts fixed: run "git rebase --continue")
 110
 111Changes to be committed:
 112  (use "git reset HEAD <file>..." to unstage)
 113
 114        modified:   main.txt
 115
 116Untracked files not listed (use -u option to show untracked files)
 117EOF
 118        git status --untracked-files=no >actual &&
 119        test_i18ncmp expected actual
 120'
 121
 122
 123test_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
 131'
 132
 133
 134test_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        test_must_fail git rebase -i rebase_i_conflicts &&
 138        cat >expected <<EOF &&
 139rebase in progress; onto $ONTO
 140You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
 141  (fix conflicts and then run "git rebase --continue")
 142  (use "git rebase --skip" to skip this patch)
 143  (use "git rebase --abort" to check out the original branch)
 144
 145Unmerged paths:
 146  (use "git reset HEAD <file>..." to unstage)
 147  (use "git add <file>..." to mark resolution)
 148
 149        both modified:   main.txt
 150
 151no changes added to commit (use "git add" and/or "git commit -a")
 152EOF
 153        git status --untracked-files=no >actual &&
 154        test_i18ncmp expected actual
 155'
 156
 157
 158test_expect_success 'status during rebase -i after resolving conflicts' '
 159        git reset --hard rebase_i_conflicts_second &&
 160        test_when_finished "git rebase --abort" &&
 161        ONTO=$(git rev-parse --short rebase_i_conflicts) &&
 162        test_must_fail git rebase -i rebase_i_conflicts &&
 163        git add main.txt &&
 164        cat >expected <<EOF &&
 165rebase in progress; onto $ONTO
 166You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
 167  (all conflicts fixed: run "git rebase --continue")
 168
 169Changes to be committed:
 170  (use "git reset HEAD <file>..." to unstage)
 171
 172        modified:   main.txt
 173
 174Untracked files not listed (use -u option to show untracked files)
 175EOF
 176        git status --untracked-files=no >actual &&
 177        test_i18ncmp expected actual
 178'
 179
 180
 181test_expect_success 'status when rebasing -i in edit mode' '
 182        git reset --hard master &&
 183        git checkout -b rebase_i_edit &&
 184        test_commit one_rebase_i main.txt one &&
 185        test_commit two_rebase_i main.txt two &&
 186        test_commit three_rebase_i main.txt three &&
 187        FAKE_LINES="1 edit 2" &&
 188        export FAKE_LINES &&
 189        test_when_finished "git rebase --abort" &&
 190        ONTO=$(git rev-parse --short HEAD~2) &&
 191        git rebase -i HEAD~2 &&
 192        cat >expected <<EOF &&
 193rebase in progress; onto $ONTO
 194You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
 195  (use "git commit --amend" to amend the current commit)
 196  (use "git rebase --continue" once you are satisfied with your changes)
 197
 198nothing to commit (use -u to show untracked files)
 199EOF
 200        git status --untracked-files=no >actual &&
 201        test_i18ncmp expected actual
 202'
 203
 204
 205test_expect_success 'status when splitting a commit' '
 206        git reset --hard master &&
 207        git checkout -b split_commit &&
 208        test_commit one_split main.txt one &&
 209        test_commit two_split main.txt two &&
 210        test_commit three_split main.txt three &&
 211        test_commit four_split main.txt four &&
 212        FAKE_LINES="1 edit 2 3" &&
 213        export FAKE_LINES &&
 214        test_when_finished "git rebase --abort" &&
 215        ONTO=$(git rev-parse --short HEAD~3) &&
 216        git rebase -i HEAD~3 &&
 217        git reset HEAD^ &&
 218        cat >expected <<EOF &&
 219rebase in progress; onto $ONTO
 220You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
 221  (Once your working directory is clean, run "git rebase --continue")
 222
 223Changes not staged for commit:
 224  (use "git add <file>..." to update what will be committed)
 225  (use "git checkout -- <file>..." to discard changes in working directory)
 226
 227        modified:   main.txt
 228
 229no changes added to commit (use "git add" and/or "git commit -a")
 230EOF
 231        git status --untracked-files=no >actual &&
 232        test_i18ncmp expected actual
 233'
 234
 235
 236test_expect_success 'status after editing the last commit with --amend during a rebase -i' '
 237        git reset --hard master &&
 238        git checkout -b amend_last &&
 239        test_commit one_amend main.txt one &&
 240        test_commit two_amend main.txt two &&
 241        test_commit three_amend main.txt three &&
 242        test_commit four_amend main.txt four &&
 243        FAKE_LINES="1 2 edit 3" &&
 244        export FAKE_LINES &&
 245        test_when_finished "git rebase --abort" &&
 246        ONTO=$(git rev-parse --short HEAD~3) &&
 247        git rebase -i HEAD~3 &&
 248        git commit --amend -m "foo" &&
 249        cat >expected <<EOF &&
 250rebase in progress; onto $ONTO
 251You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
 252  (use "git commit --amend" to amend the current commit)
 253  (use "git rebase --continue" once you are satisfied with your changes)
 254
 255nothing to commit (use -u to show untracked files)
 256EOF
 257        git status --untracked-files=no >actual &&
 258        test_i18ncmp expected actual
 259'
 260
 261
 262test_expect_success 'prepare for several edits' '
 263        git reset --hard master &&
 264        git checkout -b several_edits &&
 265        test_commit one_edits main.txt one &&
 266        test_commit two_edits main.txt two &&
 267        test_commit three_edits main.txt three &&
 268        test_commit four_edits main.txt four
 269'
 270
 271
 272test_expect_success 'status: (continue first edit) second edit' '
 273        FAKE_LINES="edit 1 edit 2 3" &&
 274        export FAKE_LINES &&
 275        test_when_finished "git rebase --abort" &&
 276        ONTO=$(git rev-parse --short HEAD~3) &&
 277        git rebase -i HEAD~3 &&
 278        git rebase --continue &&
 279        cat >expected <<EOF &&
 280rebase in progress; onto $ONTO
 281You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 282  (use "git commit --amend" to amend the current commit)
 283  (use "git rebase --continue" once you are satisfied with your changes)
 284
 285nothing to commit (use -u to show untracked files)
 286EOF
 287        git status --untracked-files=no >actual &&
 288        test_i18ncmp expected actual
 289'
 290
 291
 292test_expect_success 'status: (continue first edit) second edit and split' '
 293        git reset --hard several_edits &&
 294        FAKE_LINES="edit 1 edit 2 3" &&
 295        export FAKE_LINES &&
 296        test_when_finished "git rebase --abort" &&
 297        ONTO=$(git rev-parse --short HEAD~3) &&
 298        git rebase -i HEAD~3 &&
 299        git rebase --continue &&
 300        git reset HEAD^ &&
 301        cat >expected <<EOF &&
 302rebase in progress; onto $ONTO
 303You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 304  (Once your working directory is clean, run "git rebase --continue")
 305
 306Changes not staged for commit:
 307  (use "git add <file>..." to update what will be committed)
 308  (use "git checkout -- <file>..." to discard changes in working directory)
 309
 310        modified:   main.txt
 311
 312no changes added to commit (use "git add" and/or "git commit -a")
 313EOF
 314        git status --untracked-files=no >actual &&
 315        test_i18ncmp expected actual
 316'
 317
 318
 319test_expect_success 'status: (continue first edit) second edit and amend' '
 320        git reset --hard several_edits &&
 321        FAKE_LINES="edit 1 edit 2 3" &&
 322        export FAKE_LINES &&
 323        test_when_finished "git rebase --abort" &&
 324        ONTO=$(git rev-parse --short HEAD~3) &&
 325        git rebase -i HEAD~3 &&
 326        git rebase --continue &&
 327        git commit --amend -m "foo" &&
 328        cat >expected <<EOF &&
 329rebase in progress; onto $ONTO
 330You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 331  (use "git commit --amend" to amend the current commit)
 332  (use "git rebase --continue" once you are satisfied with your changes)
 333
 334nothing to commit (use -u to show untracked files)
 335EOF
 336        git status --untracked-files=no >actual &&
 337        test_i18ncmp expected actual
 338'
 339
 340
 341test_expect_success 'status: (amend first edit) second edit' '
 342        git reset --hard several_edits &&
 343        FAKE_LINES="edit 1 edit 2 3" &&
 344        export FAKE_LINES &&
 345        test_when_finished "git rebase --abort" &&
 346        ONTO=$(git rev-parse --short HEAD~3) &&
 347        git rebase -i HEAD~3 &&
 348        git commit --amend -m "a" &&
 349        git rebase --continue &&
 350        cat >expected <<EOF &&
 351rebase in progress; onto $ONTO
 352You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 353  (use "git commit --amend" to amend the current commit)
 354  (use "git rebase --continue" once you are satisfied with your changes)
 355
 356nothing to commit (use -u to show untracked files)
 357EOF
 358        git status --untracked-files=no >actual &&
 359        test_i18ncmp expected actual
 360'
 361
 362
 363test_expect_success 'status: (amend first edit) second edit and split' '
 364        git reset --hard several_edits &&
 365        FAKE_LINES="edit 1 edit 2 3" &&
 366        export FAKE_LINES &&
 367        test_when_finished "git rebase --abort" &&
 368        ONTO=$(git rev-parse --short HEAD~3) &&
 369        git rebase -i HEAD~3 &&
 370        git commit --amend -m "b" &&
 371        git rebase --continue &&
 372        git reset HEAD^ &&
 373        cat >expected <<EOF &&
 374rebase in progress; onto $ONTO
 375You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 376  (Once your working directory is clean, run "git rebase --continue")
 377
 378Changes not staged for commit:
 379  (use "git add <file>..." to update what will be committed)
 380  (use "git checkout -- <file>..." to discard changes in working directory)
 381
 382        modified:   main.txt
 383
 384no changes added to commit (use "git add" and/or "git commit -a")
 385EOF
 386        git status --untracked-files=no >actual &&
 387        test_i18ncmp expected actual
 388'
 389
 390
 391test_expect_success 'status: (amend first edit) second edit and amend' '
 392        git reset --hard several_edits &&
 393        FAKE_LINES="edit 1 edit 2 3" &&
 394        export FAKE_LINES &&
 395        test_when_finished "git rebase --abort" &&
 396        ONTO=$(git rev-parse --short HEAD~3) &&
 397        git rebase -i HEAD~3 &&
 398        git commit --amend -m "c" &&
 399        git rebase --continue &&
 400        git commit --amend -m "d" &&
 401        cat >expected <<EOF &&
 402rebase in progress; onto $ONTO
 403You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 404  (use "git commit --amend" to amend the current commit)
 405  (use "git rebase --continue" once you are satisfied with your changes)
 406
 407nothing to commit (use -u to show untracked files)
 408EOF
 409        git status --untracked-files=no >actual &&
 410        test_i18ncmp expected actual
 411'
 412
 413
 414test_expect_success 'status: (split first edit) second edit' '
 415        git reset --hard several_edits &&
 416        FAKE_LINES="edit 1 edit 2 3" &&
 417        export FAKE_LINES &&
 418        test_when_finished "git rebase --abort" &&
 419        ONTO=$(git rev-parse --short HEAD~3) &&
 420        git rebase -i HEAD~3 &&
 421        git reset HEAD^ &&
 422        git add main.txt &&
 423        git commit -m "e" &&
 424        git rebase --continue &&
 425        cat >expected <<EOF &&
 426rebase in progress; onto $ONTO
 427You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 428  (use "git commit --amend" to amend the current commit)
 429  (use "git rebase --continue" once you are satisfied with your changes)
 430
 431nothing to commit (use -u to show untracked files)
 432EOF
 433        git status --untracked-files=no >actual &&
 434        test_i18ncmp expected actual
 435'
 436
 437
 438test_expect_success 'status: (split first edit) second edit and split' '
 439        git reset --hard several_edits &&
 440        FAKE_LINES="edit 1 edit 2 3" &&
 441        export FAKE_LINES &&
 442        test_when_finished "git rebase --abort" &&
 443        ONTO=$(git rev-parse --short HEAD~3) &&
 444        git rebase -i HEAD~3 &&
 445        git reset HEAD^ &&
 446        git add main.txt &&
 447        git commit --amend -m "f" &&
 448        git rebase --continue &&
 449        git reset HEAD^ &&
 450        cat >expected <<EOF &&
 451rebase in progress; onto $ONTO
 452You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 453  (Once your working directory is clean, run "git rebase --continue")
 454
 455Changes not staged for commit:
 456  (use "git add <file>..." to update what will be committed)
 457  (use "git checkout -- <file>..." to discard changes in working directory)
 458
 459        modified:   main.txt
 460
 461no changes added to commit (use "git add" and/or "git commit -a")
 462EOF
 463        git status --untracked-files=no >actual &&
 464        test_i18ncmp expected actual
 465'
 466
 467
 468test_expect_success 'status: (split first edit) second edit and amend' '
 469        git reset --hard several_edits &&
 470        FAKE_LINES="edit 1 edit 2 3" &&
 471        export FAKE_LINES &&
 472        test_when_finished "git rebase --abort" &&
 473        ONTO=$(git rev-parse --short HEAD~3) &&
 474        git rebase -i HEAD~3 &&
 475        git reset HEAD^ &&
 476        git add main.txt &&
 477        git commit --amend -m "g" &&
 478        git rebase --continue &&
 479        git commit --amend -m "h" &&
 480        cat >expected <<EOF &&
 481rebase in progress; onto $ONTO
 482You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 483  (use "git commit --amend" to amend the current commit)
 484  (use "git rebase --continue" once you are satisfied with your changes)
 485
 486nothing to commit (use -u to show untracked files)
 487EOF
 488        git status --untracked-files=no >actual &&
 489        test_i18ncmp expected actual
 490'
 491
 492
 493test_expect_success 'prepare am_session' '
 494        git reset --hard master &&
 495        git checkout -b am_session &&
 496        test_commit one_am one.txt "one" &&
 497        test_commit two_am two.txt "two" &&
 498        test_commit three_am three.txt "three"
 499'
 500
 501
 502test_expect_success 'status in an am session: file already exists' '
 503        git checkout -b am_already_exists &&
 504        test_when_finished "rm Maildir/* && git am --abort" &&
 505        git format-patch -1 -oMaildir &&
 506        test_must_fail git am Maildir/*.patch &&
 507        cat >expected <<\EOF &&
 508On branch am_already_exists
 509You are in the middle of an am session.
 510  (fix conflicts and then run "git am --continue")
 511  (use "git am --skip" to skip this patch)
 512  (use "git am --abort" to restore the original branch)
 513
 514nothing to commit (use -u to show untracked files)
 515EOF
 516        git status --untracked-files=no >actual &&
 517        test_i18ncmp expected actual
 518'
 519
 520
 521test_expect_success 'status in an am session: file does not exist' '
 522        git reset --hard am_session &&
 523        git checkout -b am_not_exists &&
 524        git rm three.txt &&
 525        git commit -m "delete three.txt" &&
 526        test_when_finished "rm Maildir/* && git am --abort" &&
 527        git format-patch -1 -oMaildir &&
 528        test_must_fail git am Maildir/*.patch &&
 529        cat >expected <<\EOF &&
 530On branch am_not_exists
 531You are in the middle of an am session.
 532  (fix conflicts and then run "git am --continue")
 533  (use "git am --skip" to skip this patch)
 534  (use "git am --abort" to restore the original branch)
 535
 536nothing to commit (use -u to show untracked files)
 537EOF
 538        git status --untracked-files=no >actual &&
 539        test_i18ncmp expected actual
 540'
 541
 542
 543test_expect_success 'status in an am session: empty patch' '
 544        git reset --hard am_session &&
 545        git checkout -b am_empty &&
 546        test_when_finished "rm Maildir/* && git am --abort" &&
 547        git format-patch -3 -oMaildir &&
 548        git rm one.txt two.txt three.txt &&
 549        git commit -m "delete all am_empty" &&
 550        echo error >Maildir/0002-two_am.patch &&
 551        test_must_fail git am Maildir/*.patch &&
 552        cat >expected <<\EOF &&
 553On branch am_empty
 554You are in the middle of an am session.
 555The current patch is empty.
 556  (use "git am --skip" to skip this patch)
 557  (use "git am --abort" to restore the original branch)
 558
 559nothing to commit (use -u to show untracked files)
 560EOF
 561        git status --untracked-files=no >actual &&
 562        test_i18ncmp expected actual
 563'
 564
 565
 566test_expect_success 'status when bisecting' '
 567        git reset --hard master &&
 568        git checkout -b bisect &&
 569        test_commit one_bisect main.txt one &&
 570        test_commit two_bisect main.txt two &&
 571        test_commit three_bisect main.txt three &&
 572        test_when_finished "git bisect reset" &&
 573        git bisect start &&
 574        git bisect bad &&
 575        git bisect good one_bisect &&
 576        TGT=$(git rev-parse --short two_bisect) &&
 577        cat >expected <<EOF &&
 578HEAD detached at $TGT
 579You are currently bisecting, started from branch '\''bisect'\''.
 580  (use "git bisect reset" to get back to the original branch)
 581
 582nothing to commit (use -u to show untracked files)
 583EOF
 584        git status --untracked-files=no >actual &&
 585        test_i18ncmp expected actual
 586'
 587
 588
 589test_expect_success 'status when rebase conflicts with statushints disabled' '
 590        git reset --hard master &&
 591        git checkout -b statushints_disabled &&
 592        test_when_finished "git config --local advice.statushints true" &&
 593        git config --local advice.statushints false &&
 594        test_commit one_statushints main.txt one &&
 595        test_commit two_statushints main.txt two &&
 596        test_commit three_statushints main.txt three &&
 597        test_when_finished "git rebase --abort" &&
 598        ONTO=$(git rev-parse --short HEAD^^) &&
 599        test_must_fail git rebase HEAD^ --onto HEAD^^ &&
 600        cat >expected <<EOF &&
 601rebase in progress; onto $ONTO
 602You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
 603
 604Unmerged paths:
 605        both modified:   main.txt
 606
 607no changes added to commit
 608EOF
 609        git status --untracked-files=no >actual &&
 610        test_i18ncmp expected actual
 611'
 612
 613
 614test_expect_success 'prepare for cherry-pick conflicts' '
 615        git reset --hard master &&
 616        git checkout -b cherry_branch &&
 617        test_commit one_cherry main.txt one &&
 618        test_commit two_cherries main.txt two &&
 619        git checkout -b cherry_branch_second &&
 620        test_commit second_cherry main.txt second &&
 621        git checkout cherry_branch &&
 622        test_commit three_cherries main.txt three
 623'
 624
 625
 626test_expect_success 'status when cherry-picking before resolving conflicts' '
 627        test_when_finished "git cherry-pick --abort" &&
 628        test_must_fail git cherry-pick cherry_branch_second &&
 629        TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
 630        cat >expected <<EOF &&
 631On branch cherry_branch
 632You are currently cherry-picking commit $TO_CHERRY_PICK.
 633  (fix conflicts and run "git cherry-pick --continue")
 634  (use "git cherry-pick --abort" to cancel the cherry-pick operation)
 635
 636Unmerged paths:
 637  (use "git add <file>..." to mark resolution)
 638
 639        both modified:   main.txt
 640
 641no changes added to commit (use "git add" and/or "git commit -a")
 642EOF
 643        git status --untracked-files=no >actual &&
 644        test_i18ncmp expected actual
 645'
 646
 647
 648test_expect_success 'status when cherry-picking after resolving conflicts' '
 649        git reset --hard cherry_branch &&
 650        test_when_finished "git cherry-pick --abort" &&
 651        test_must_fail git cherry-pick cherry_branch_second &&
 652        TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
 653        echo end >main.txt &&
 654        git add main.txt &&
 655        cat >expected <<EOF &&
 656On branch cherry_branch
 657You are currently cherry-picking commit $TO_CHERRY_PICK.
 658  (all conflicts fixed: run "git cherry-pick --continue")
 659  (use "git cherry-pick --abort" to cancel the cherry-pick operation)
 660
 661Changes to be committed:
 662
 663        modified:   main.txt
 664
 665Untracked files not listed (use -u option to show untracked files)
 666EOF
 667        git status --untracked-files=no >actual &&
 668        test_i18ncmp expected actual
 669'
 670
 671test_expect_success 'status showing detached at and from a tag' '
 672        test_commit atag tagging &&
 673        git checkout atag &&
 674        cat >expected <<\EOF &&
 675HEAD detached at atag
 676nothing to commit (use -u to show untracked files)
 677EOF
 678        git status --untracked-files=no >actual &&
 679        test_i18ncmp expected actual &&
 680
 681        git reset --hard HEAD^ &&
 682        cat >expected <<\EOF &&
 683HEAD detached from atag
 684nothing to commit (use -u to show untracked files)
 685EOF
 686        git status --untracked-files=no >actual &&
 687        test_i18ncmp expected actual
 688'
 689
 690test_expect_success 'status while reverting commit (conflicts)' '
 691        git checkout master &&
 692        echo before >to-revert.txt &&
 693        test_commit before to-revert.txt &&
 694        echo old >to-revert.txt &&
 695        test_commit old to-revert.txt &&
 696        echo new >to-revert.txt &&
 697        test_commit new to-revert.txt &&
 698        TO_REVERT=$(git rev-parse --short HEAD^) &&
 699        test_must_fail git revert $TO_REVERT &&
 700        cat >expected <<EOF &&
 701On branch master
 702You are currently reverting commit $TO_REVERT.
 703  (fix conflicts and run "git revert --continue")
 704  (use "git revert --abort" to cancel the revert operation)
 705
 706Unmerged paths:
 707  (use "git reset HEAD <file>..." to unstage)
 708  (use "git add <file>..." to mark resolution)
 709
 710        both modified:   to-revert.txt
 711
 712no changes added to commit (use "git add" and/or "git commit -a")
 713EOF
 714        git status --untracked-files=no >actual &&
 715        test_i18ncmp expected actual
 716'
 717
 718test_expect_success 'status while reverting commit (conflicts resolved)' '
 719        echo reverted >to-revert.txt &&
 720        git add to-revert.txt &&
 721        cat >expected <<EOF &&
 722On branch master
 723You are currently reverting commit $TO_REVERT.
 724  (all conflicts fixed: run "git revert --continue")
 725  (use "git revert --abort" to cancel the revert operation)
 726
 727Changes to be committed:
 728  (use "git reset HEAD <file>..." to unstage)
 729
 730        modified:   to-revert.txt
 731
 732Untracked files not listed (use -u option to show untracked files)
 733EOF
 734        git status --untracked-files=no >actual &&
 735        test_i18ncmp expected actual
 736'
 737
 738test_expect_success 'status after reverting commit' '
 739        git revert --continue &&
 740        cat >expected <<\EOF &&
 741On branch master
 742nothing to commit (use -u to show untracked files)
 743EOF
 744        git status --untracked-files=no >actual &&
 745        test_i18ncmp expected actual
 746'
 747
 748test_done