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