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