t / t7512-status-help.shon commit send-email: simplify Gmail example in the documentation (4855f06)
   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        LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) &&
 138        test_must_fail git rebase -i rebase_i_conflicts &&
 139        cat >expected <<EOF &&
 140interactive rebase in progress; onto $ONTO
 141Last command done (1 command done):
 142   pick $LAST_COMMIT one_second
 143No commands remaining.
 144You 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
 149Unmerged paths:
 150  (use "git reset HEAD <file>..." to unstage)
 151  (use "git add <file>..." to mark resolution)
 152
 153        both modified:   main.txt
 154
 155no changes added to commit (use "git add" and/or "git commit -a")
 156EOF
 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        LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) &&
 167        test_must_fail git rebase -i rebase_i_conflicts &&
 168        git add main.txt &&
 169        cat >expected <<EOF &&
 170interactive rebase in progress; onto $ONTO
 171Last command done (1 command done):
 172   pick $LAST_COMMIT one_second
 173No commands remaining.
 174You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
 175  (all conflicts fixed: run "git rebase --continue")
 176
 177Changes to be committed:
 178  (use "git reset HEAD <file>..." to unstage)
 179
 180        modified:   main.txt
 181
 182Untracked files not listed (use -u option to show untracked files)
 183EOF
 184        git status --untracked-files=no >actual &&
 185        test_i18ncmp expected actual
 186'
 187
 188
 189test_expect_success 'status when rebasing -i in edit mode' '
 190        git reset --hard master &&
 191        git checkout -b rebase_i_edit &&
 192        test_commit one_rebase_i main.txt one &&
 193        test_commit two_rebase_i main.txt two &&
 194        COMMIT2=$(git rev-parse --short rebase_i_edit) &&
 195        test_commit three_rebase_i main.txt three &&
 196        COMMIT3=$(git rev-parse --short rebase_i_edit) &&
 197        FAKE_LINES="1 edit 2" &&
 198        export FAKE_LINES &&
 199        test_when_finished "git rebase --abort" &&
 200        ONTO=$(git rev-parse --short HEAD~2) &&
 201        git rebase -i HEAD~2 &&
 202        cat >expected <<EOF &&
 203interactive rebase in progress; onto $ONTO
 204Last commands done (2 commands done):
 205   pick $COMMIT2 two_rebase_i
 206   edit $COMMIT3 three_rebase_i
 207No commands remaining.
 208You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
 209  (use "git commit --amend" to amend the current commit)
 210  (use "git rebase --continue" once you are satisfied with your changes)
 211
 212nothing to commit (use -u to show untracked files)
 213EOF
 214        git status --untracked-files=no >actual &&
 215        test_i18ncmp expected actual
 216'
 217
 218
 219test_expect_success 'status when splitting a commit' '
 220        git reset --hard master &&
 221        git checkout -b split_commit &&
 222        test_commit one_split main.txt one &&
 223        test_commit two_split main.txt two &&
 224        COMMIT2=$(git rev-parse --short split_commit) &&
 225        test_commit three_split main.txt three &&
 226        COMMIT3=$(git rev-parse --short split_commit) &&
 227        test_commit four_split main.txt four &&
 228        COMMIT4=$(git rev-parse --short split_commit) &&
 229        FAKE_LINES="1 edit 2 3" &&
 230        export FAKE_LINES &&
 231        test_when_finished "git rebase --abort" &&
 232        ONTO=$(git rev-parse --short HEAD~3) &&
 233        git rebase -i HEAD~3 &&
 234        git reset HEAD^ &&
 235        cat >expected <<EOF &&
 236interactive rebase in progress; onto $ONTO
 237Last commands done (2 commands done):
 238   pick $COMMIT2 two_split
 239   edit $COMMIT3 three_split
 240Next command to do (1 remaining command):
 241   pick $COMMIT4 four_split
 242  (use "git rebase --edit-todo" to view and edit)
 243You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
 244  (Once your working directory is clean, run "git rebase --continue")
 245
 246Changes not staged for commit:
 247  (use "git add <file>..." to update what will be committed)
 248  (use "git checkout -- <file>..." to discard changes in working directory)
 249
 250        modified:   main.txt
 251
 252no changes added to commit (use "git add" and/or "git commit -a")
 253EOF
 254        git status --untracked-files=no >actual &&
 255        test_i18ncmp expected actual
 256'
 257
 258
 259test_expect_success 'status after editing the last commit with --amend during a rebase -i' '
 260        git reset --hard master &&
 261        git checkout -b amend_last &&
 262        test_commit one_amend main.txt one &&
 263        test_commit two_amend main.txt two &&
 264        test_commit three_amend main.txt three &&
 265        COMMIT3=$(git rev-parse --short amend_last) &&
 266        test_commit four_amend main.txt four &&
 267        COMMIT4=$(git rev-parse --short amend_last) &&
 268        FAKE_LINES="1 2 edit 3" &&
 269        export FAKE_LINES &&
 270        test_when_finished "git rebase --abort" &&
 271        ONTO=$(git rev-parse --short HEAD~3) &&
 272        git rebase -i HEAD~3 &&
 273        git commit --amend -m "foo" &&
 274        cat >expected <<EOF &&
 275interactive rebase in progress; onto $ONTO
 276Last commands done (3 commands done):
 277   pick $COMMIT3 three_amend
 278   edit $COMMIT4 four_amend
 279  (see more in file .git/rebase-merge/done)
 280No commands remaining.
 281You are currently editing a commit while rebasing branch '\''amend_last'\'' 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 'prepare for several edits' '
 293        git reset --hard master &&
 294        git checkout -b several_edits &&
 295        test_commit one_edits main.txt one &&
 296        test_commit two_edits main.txt two &&
 297        test_commit three_edits main.txt three &&
 298        test_commit four_edits main.txt four
 299'
 300
 301
 302test_expect_success 'status: (continue first edit) second edit' '
 303        FAKE_LINES="edit 1 edit 2 3" &&
 304        export FAKE_LINES &&
 305        test_when_finished "git rebase --abort" &&
 306        COMMIT2=$(git rev-parse --short several_edits^^) &&
 307        COMMIT3=$(git rev-parse --short several_edits^) &&
 308        COMMIT4=$(git rev-parse --short several_edits) &&
 309        ONTO=$(git rev-parse --short HEAD~3) &&
 310        git rebase -i HEAD~3 &&
 311        git rebase --continue &&
 312        cat >expected <<EOF &&
 313interactive rebase in progress; onto $ONTO
 314Last commands done (2 commands done):
 315   edit $COMMIT2 two_edits
 316   edit $COMMIT3 three_edits
 317Next command to do (1 remaining command):
 318   pick $COMMIT4 four_edits
 319  (use "git rebase --edit-todo" to view and edit)
 320You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 321  (use "git commit --amend" to amend the current commit)
 322  (use "git rebase --continue" once you are satisfied with your changes)
 323
 324nothing to commit (use -u to show untracked files)
 325EOF
 326        git status --untracked-files=no >actual &&
 327        test_i18ncmp expected actual
 328'
 329
 330
 331test_expect_success 'status: (continue first edit) second edit and split' '
 332        git reset --hard several_edits &&
 333        FAKE_LINES="edit 1 edit 2 3" &&
 334        export FAKE_LINES &&
 335        test_when_finished "git rebase --abort" &&
 336        COMMIT2=$(git rev-parse --short several_edits^^) &&
 337        COMMIT3=$(git rev-parse --short several_edits^) &&
 338        COMMIT4=$(git rev-parse --short several_edits) &&
 339        ONTO=$(git rev-parse --short HEAD~3) &&
 340        git rebase -i HEAD~3 &&
 341        git rebase --continue &&
 342        git reset HEAD^ &&
 343        cat >expected <<EOF &&
 344interactive rebase in progress; onto $ONTO
 345Last commands done (2 commands done):
 346   edit $COMMIT2 two_edits
 347   edit $COMMIT3 three_edits
 348Next command to do (1 remaining command):
 349   pick $COMMIT4 four_edits
 350  (use "git rebase --edit-todo" to view and edit)
 351You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 352  (Once your working directory is clean, run "git rebase --continue")
 353
 354Changes not staged for commit:
 355  (use "git add <file>..." to update what will be committed)
 356  (use "git checkout -- <file>..." to discard changes in working directory)
 357
 358        modified:   main.txt
 359
 360no changes added to commit (use "git add" and/or "git commit -a")
 361EOF
 362        git status --untracked-files=no >actual &&
 363        test_i18ncmp expected actual
 364'
 365
 366
 367test_expect_success 'status: (continue first edit) second edit and amend' '
 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        COMMIT2=$(git rev-parse --short several_edits^^) &&
 373        COMMIT3=$(git rev-parse --short several_edits^) &&
 374        COMMIT4=$(git rev-parse --short several_edits) &&
 375        ONTO=$(git rev-parse --short HEAD~3) &&
 376        git rebase -i HEAD~3 &&
 377        git rebase --continue &&
 378        git commit --amend -m "foo" &&
 379        cat >expected <<EOF &&
 380interactive rebase in progress; onto $ONTO
 381Last commands done (2 commands done):
 382   edit $COMMIT2 two_edits
 383   edit $COMMIT3 three_edits
 384Next command to do (1 remaining command):
 385   pick $COMMIT4 four_edits
 386  (use "git rebase --edit-todo" to view and edit)
 387You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 388  (use "git commit --amend" to amend the current commit)
 389  (use "git rebase --continue" once you are satisfied with your changes)
 390
 391nothing to commit (use -u to show untracked files)
 392EOF
 393        git status --untracked-files=no >actual &&
 394        test_i18ncmp expected actual
 395'
 396
 397
 398test_expect_success 'status: (amend first edit) second edit' '
 399        git reset --hard several_edits &&
 400        FAKE_LINES="edit 1 edit 2 3" &&
 401        export FAKE_LINES &&
 402        test_when_finished "git rebase --abort" &&
 403        COMMIT2=$(git rev-parse --short several_edits^^) &&
 404        COMMIT3=$(git rev-parse --short several_edits^) &&
 405        COMMIT4=$(git rev-parse --short several_edits) &&
 406        ONTO=$(git rev-parse --short HEAD~3) &&
 407        git rebase -i HEAD~3 &&
 408        git commit --amend -m "a" &&
 409        git rebase --continue &&
 410        cat >expected <<EOF &&
 411interactive rebase in progress; onto $ONTO
 412Last commands done (2 commands done):
 413   edit $COMMIT2 two_edits
 414   edit $COMMIT3 three_edits
 415Next command to do (1 remaining command):
 416   pick $COMMIT4 four_edits
 417  (use "git rebase --edit-todo" to view and edit)
 418You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 419  (use "git commit --amend" to amend the current commit)
 420  (use "git rebase --continue" once you are satisfied with your changes)
 421
 422nothing to commit (use -u to show untracked files)
 423EOF
 424        git status --untracked-files=no >actual &&
 425        test_i18ncmp expected actual
 426'
 427
 428
 429test_expect_success 'status: (amend first edit) second edit and split' '
 430        git reset --hard several_edits &&
 431        FAKE_LINES="edit 1 edit 2 3" &&
 432        export FAKE_LINES &&
 433        test_when_finished "git rebase --abort" &&
 434        ONTO=$(git rev-parse --short HEAD~3) &&
 435        COMMIT2=$(git rev-parse --short several_edits^^) &&
 436        COMMIT3=$(git rev-parse --short several_edits^) &&
 437        COMMIT4=$(git rev-parse --short several_edits) &&
 438        git rebase -i HEAD~3 &&
 439        git commit --amend -m "b" &&
 440        git rebase --continue &&
 441        git reset HEAD^ &&
 442        cat >expected <<EOF &&
 443interactive rebase in progress; onto $ONTO
 444Last commands done (2 commands done):
 445   edit $COMMIT2 two_edits
 446   edit $COMMIT3 three_edits
 447Next command to do (1 remaining command):
 448   pick $COMMIT4 four_edits
 449  (use "git rebase --edit-todo" to view and edit)
 450You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 451  (Once your working directory is clean, run "git rebase --continue")
 452
 453Changes not staged for commit:
 454  (use "git add <file>..." to update what will be committed)
 455  (use "git checkout -- <file>..." to discard changes in working directory)
 456
 457        modified:   main.txt
 458
 459no changes added to commit (use "git add" and/or "git commit -a")
 460EOF
 461        git status --untracked-files=no >actual &&
 462        test_i18ncmp expected actual
 463'
 464
 465
 466test_expect_success 'status: (amend first edit) second edit and amend' '
 467        git reset --hard several_edits &&
 468        FAKE_LINES="edit 1 edit 2 3" &&
 469        export FAKE_LINES &&
 470        test_when_finished "git rebase --abort" &&
 471        COMMIT2=$(git rev-parse --short several_edits^^) &&
 472        COMMIT3=$(git rev-parse --short several_edits^) &&
 473        COMMIT4=$(git rev-parse --short several_edits) &&
 474        ONTO=$(git rev-parse --short HEAD~3) &&
 475        git rebase -i HEAD~3 &&
 476        git commit --amend -m "c" &&
 477        git rebase --continue &&
 478        git commit --amend -m "d" &&
 479        cat >expected <<EOF &&
 480interactive rebase in progress; onto $ONTO
 481Last commands done (2 commands done):
 482   edit $COMMIT2 two_edits
 483   edit $COMMIT3 three_edits
 484Next command to do (1 remaining command):
 485   pick $COMMIT4 four_edits
 486  (use "git rebase --edit-todo" to view and edit)
 487You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 488  (use "git commit --amend" to amend the current commit)
 489  (use "git rebase --continue" once you are satisfied with your changes)
 490
 491nothing to commit (use -u to show untracked files)
 492EOF
 493        git status --untracked-files=no >actual &&
 494        test_i18ncmp expected actual
 495'
 496
 497
 498test_expect_success 'status: (split first edit) second edit' '
 499        git reset --hard several_edits &&
 500        FAKE_LINES="edit 1 edit 2 3" &&
 501        export FAKE_LINES &&
 502        test_when_finished "git rebase --abort" &&
 503        COMMIT2=$(git rev-parse --short several_edits^^) &&
 504        COMMIT3=$(git rev-parse --short several_edits^) &&
 505        COMMIT4=$(git rev-parse --short several_edits) &&
 506        ONTO=$(git rev-parse --short HEAD~3) &&
 507        git rebase -i HEAD~3 &&
 508        git reset HEAD^ &&
 509        git add main.txt &&
 510        git commit -m "e" &&
 511        git rebase --continue &&
 512        cat >expected <<EOF &&
 513interactive rebase in progress; onto $ONTO
 514Last commands done (2 commands done):
 515   edit $COMMIT2 two_edits
 516   edit $COMMIT3 three_edits
 517Next command to do (1 remaining command):
 518   pick $COMMIT4 four_edits
 519  (use "git rebase --edit-todo" to view and edit)
 520You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 521  (use "git commit --amend" to amend the current commit)
 522  (use "git rebase --continue" once you are satisfied with your changes)
 523
 524nothing to commit (use -u to show untracked files)
 525EOF
 526        git status --untracked-files=no >actual &&
 527        test_i18ncmp expected actual
 528'
 529
 530
 531test_expect_success 'status: (split first edit) second edit and split' '
 532        git reset --hard several_edits &&
 533        FAKE_LINES="edit 1 edit 2 3" &&
 534        export FAKE_LINES &&
 535        test_when_finished "git rebase --abort" &&
 536        COMMIT2=$(git rev-parse --short several_edits^^) &&
 537        COMMIT3=$(git rev-parse --short several_edits^) &&
 538        COMMIT4=$(git rev-parse --short several_edits) &&
 539        ONTO=$(git rev-parse --short HEAD~3) &&
 540        git rebase -i HEAD~3 &&
 541        git reset HEAD^ &&
 542        git add main.txt &&
 543        git commit --amend -m "f" &&
 544        git rebase --continue &&
 545        git reset HEAD^ &&
 546        cat >expected <<EOF &&
 547interactive rebase in progress; onto $ONTO
 548Last commands done (2 commands done):
 549   edit $COMMIT2 two_edits
 550   edit $COMMIT3 three_edits
 551Next command to do (1 remaining command):
 552   pick $COMMIT4 four_edits
 553  (use "git rebase --edit-todo" to view and edit)
 554You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 555  (Once your working directory is clean, run "git rebase --continue")
 556
 557Changes not staged for commit:
 558  (use "git add <file>..." to update what will be committed)
 559  (use "git checkout -- <file>..." to discard changes in working directory)
 560
 561        modified:   main.txt
 562
 563no changes added to commit (use "git add" and/or "git commit -a")
 564EOF
 565        git status --untracked-files=no >actual &&
 566        test_i18ncmp expected actual
 567'
 568
 569
 570test_expect_success 'status: (split first edit) second edit and amend' '
 571        git reset --hard several_edits &&
 572        FAKE_LINES="edit 1 edit 2 3" &&
 573        export FAKE_LINES &&
 574        test_when_finished "git rebase --abort" &&
 575        COMMIT2=$(git rev-parse --short several_edits^^) &&
 576        COMMIT3=$(git rev-parse --short several_edits^) &&
 577        COMMIT4=$(git rev-parse --short several_edits) &&
 578        ONTO=$(git rev-parse --short HEAD~3) &&
 579        git rebase -i HEAD~3 &&
 580        git reset HEAD^ &&
 581        git add main.txt &&
 582        git commit --amend -m "g" &&
 583        git rebase --continue &&
 584        git commit --amend -m "h" &&
 585        cat >expected <<EOF &&
 586interactive rebase in progress; onto $ONTO
 587Last commands done (2 commands done):
 588   edit $COMMIT2 two_edits
 589   edit $COMMIT3 three_edits
 590Next command to do (1 remaining command):
 591   pick $COMMIT4 four_edits
 592  (use "git rebase --edit-todo" to view and edit)
 593You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 594  (use "git commit --amend" to amend the current commit)
 595  (use "git rebase --continue" once you are satisfied with your changes)
 596
 597nothing to commit (use -u to show untracked files)
 598EOF
 599        git status --untracked-files=no >actual &&
 600        test_i18ncmp expected actual
 601'
 602
 603
 604test_expect_success 'prepare am_session' '
 605        git reset --hard master &&
 606        git checkout -b am_session &&
 607        test_commit one_am one.txt "one" &&
 608        test_commit two_am two.txt "two" &&
 609        test_commit three_am three.txt "three"
 610'
 611
 612
 613test_expect_success 'status in an am session: file already exists' '
 614        git checkout -b am_already_exists &&
 615        test_when_finished "rm Maildir/* && git am --abort" &&
 616        git format-patch -1 -oMaildir &&
 617        test_must_fail git am Maildir/*.patch &&
 618        cat >expected <<\EOF &&
 619On branch am_already_exists
 620You are in the middle of an am session.
 621  (fix conflicts and then run "git am --continue")
 622  (use "git am --skip" to skip this patch)
 623  (use "git am --abort" to restore the original branch)
 624
 625nothing to commit (use -u to show untracked files)
 626EOF
 627        git status --untracked-files=no >actual &&
 628        test_i18ncmp expected actual
 629'
 630
 631
 632test_expect_success 'status in an am session: file does not exist' '
 633        git reset --hard am_session &&
 634        git checkout -b am_not_exists &&
 635        git rm three.txt &&
 636        git commit -m "delete three.txt" &&
 637        test_when_finished "rm Maildir/* && git am --abort" &&
 638        git format-patch -1 -oMaildir &&
 639        test_must_fail git am Maildir/*.patch &&
 640        cat >expected <<\EOF &&
 641On branch am_not_exists
 642You are in the middle of an am session.
 643  (fix conflicts and then run "git am --continue")
 644  (use "git am --skip" to skip this patch)
 645  (use "git am --abort" to restore the original branch)
 646
 647nothing to commit (use -u to show untracked files)
 648EOF
 649        git status --untracked-files=no >actual &&
 650        test_i18ncmp expected actual
 651'
 652
 653
 654test_expect_success 'status in an am session: empty patch' '
 655        git reset --hard am_session &&
 656        git checkout -b am_empty &&
 657        test_when_finished "rm Maildir/* && git am --abort" &&
 658        git format-patch -3 -oMaildir &&
 659        git rm one.txt two.txt three.txt &&
 660        git commit -m "delete all am_empty" &&
 661        echo error >Maildir/0002-two_am.patch &&
 662        test_must_fail git am Maildir/*.patch &&
 663        cat >expected <<\EOF &&
 664On branch am_empty
 665You are in the middle of an am session.
 666The current patch is empty.
 667  (use "git am --skip" to skip this patch)
 668  (use "git am --abort" to restore the original branch)
 669
 670nothing to commit (use -u to show untracked files)
 671EOF
 672        git status --untracked-files=no >actual &&
 673        test_i18ncmp expected actual
 674'
 675
 676
 677test_expect_success 'status when bisecting' '
 678        git reset --hard master &&
 679        git checkout -b bisect &&
 680        test_commit one_bisect main.txt one &&
 681        test_commit two_bisect main.txt two &&
 682        test_commit three_bisect main.txt three &&
 683        test_when_finished "git bisect reset" &&
 684        git bisect start &&
 685        git bisect bad &&
 686        git bisect good one_bisect &&
 687        TGT=$(git rev-parse --short two_bisect) &&
 688        cat >expected <<EOF &&
 689HEAD detached at $TGT
 690You are currently bisecting, started from branch '\''bisect'\''.
 691  (use "git bisect reset" to get back to the original branch)
 692
 693nothing to commit (use -u to show untracked files)
 694EOF
 695        git status --untracked-files=no >actual &&
 696        test_i18ncmp expected actual
 697'
 698
 699
 700test_expect_success 'status when rebase conflicts with statushints disabled' '
 701        git reset --hard master &&
 702        git checkout -b statushints_disabled &&
 703        test_when_finished "git config --local advice.statushints true" &&
 704        git config --local advice.statushints false &&
 705        test_commit one_statushints main.txt one &&
 706        test_commit two_statushints main.txt two &&
 707        test_commit three_statushints main.txt three &&
 708        test_when_finished "git rebase --abort" &&
 709        ONTO=$(git rev-parse --short HEAD^^) &&
 710        test_must_fail git rebase HEAD^ --onto HEAD^^ &&
 711        cat >expected <<EOF &&
 712rebase in progress; onto $ONTO
 713You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
 714
 715Unmerged paths:
 716        both modified:   main.txt
 717
 718no changes added to commit
 719EOF
 720        git status --untracked-files=no >actual &&
 721        test_i18ncmp expected actual
 722'
 723
 724
 725test_expect_success 'prepare for cherry-pick conflicts' '
 726        git reset --hard master &&
 727        git checkout -b cherry_branch &&
 728        test_commit one_cherry main.txt one &&
 729        test_commit two_cherries main.txt two &&
 730        git checkout -b cherry_branch_second &&
 731        test_commit second_cherry main.txt second &&
 732        git checkout cherry_branch &&
 733        test_commit three_cherries main.txt three
 734'
 735
 736
 737test_expect_success 'status when cherry-picking before resolving conflicts' '
 738        test_when_finished "git cherry-pick --abort" &&
 739        test_must_fail git cherry-pick cherry_branch_second &&
 740        TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
 741        cat >expected <<EOF &&
 742On branch cherry_branch
 743You are currently cherry-picking commit $TO_CHERRY_PICK.
 744  (fix conflicts and run "git cherry-pick --continue")
 745  (use "git cherry-pick --abort" to cancel the cherry-pick operation)
 746
 747Unmerged paths:
 748  (use "git add <file>..." to mark resolution)
 749
 750        both modified:   main.txt
 751
 752no changes added to commit (use "git add" and/or "git commit -a")
 753EOF
 754        git status --untracked-files=no >actual &&
 755        test_i18ncmp expected actual
 756'
 757
 758
 759test_expect_success 'status when cherry-picking after resolving conflicts' '
 760        git reset --hard cherry_branch &&
 761        test_when_finished "git cherry-pick --abort" &&
 762        test_must_fail git cherry-pick cherry_branch_second &&
 763        TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) &&
 764        echo end >main.txt &&
 765        git add main.txt &&
 766        cat >expected <<EOF &&
 767On branch cherry_branch
 768You are currently cherry-picking commit $TO_CHERRY_PICK.
 769  (all conflicts fixed: run "git cherry-pick --continue")
 770  (use "git cherry-pick --abort" to cancel the cherry-pick operation)
 771
 772Changes to be committed:
 773
 774        modified:   main.txt
 775
 776Untracked files not listed (use -u option to show untracked files)
 777EOF
 778        git status --untracked-files=no >actual &&
 779        test_i18ncmp expected actual
 780'
 781
 782test_expect_success 'status showing detached at and from a tag' '
 783        test_commit atag tagging &&
 784        git checkout atag &&
 785        cat >expected <<\EOF &&
 786HEAD detached at atag
 787nothing to commit (use -u to show untracked files)
 788EOF
 789        git status --untracked-files=no >actual &&
 790        test_i18ncmp expected actual &&
 791
 792        git reset --hard HEAD^ &&
 793        cat >expected <<\EOF &&
 794HEAD detached from atag
 795nothing to commit (use -u to show untracked files)
 796EOF
 797        git status --untracked-files=no >actual &&
 798        test_i18ncmp expected actual
 799'
 800
 801test_expect_success 'status while reverting commit (conflicts)' '
 802        git checkout master &&
 803        echo before >to-revert.txt &&
 804        test_commit before to-revert.txt &&
 805        echo old >to-revert.txt &&
 806        test_commit old to-revert.txt &&
 807        echo new >to-revert.txt &&
 808        test_commit new to-revert.txt &&
 809        TO_REVERT=$(git rev-parse --short HEAD^) &&
 810        test_must_fail git revert $TO_REVERT &&
 811        cat >expected <<EOF &&
 812On branch master
 813You are currently reverting commit $TO_REVERT.
 814  (fix conflicts and run "git revert --continue")
 815  (use "git revert --abort" to cancel the revert operation)
 816
 817Unmerged paths:
 818  (use "git reset HEAD <file>..." to unstage)
 819  (use "git add <file>..." to mark resolution)
 820
 821        both modified:   to-revert.txt
 822
 823no changes added to commit (use "git add" and/or "git commit -a")
 824EOF
 825        git status --untracked-files=no >actual &&
 826        test_i18ncmp expected actual
 827'
 828
 829test_expect_success 'status while reverting commit (conflicts resolved)' '
 830        echo reverted >to-revert.txt &&
 831        git add to-revert.txt &&
 832        cat >expected <<EOF &&
 833On branch master
 834You are currently reverting commit $TO_REVERT.
 835  (all conflicts fixed: run "git revert --continue")
 836  (use "git revert --abort" to cancel the revert operation)
 837
 838Changes to be committed:
 839  (use "git reset HEAD <file>..." to unstage)
 840
 841        modified:   to-revert.txt
 842
 843Untracked files not listed (use -u option to show untracked files)
 844EOF
 845        git status --untracked-files=no >actual &&
 846        test_i18ncmp expected actual
 847'
 848
 849test_expect_success 'status after reverting commit' '
 850        git revert --continue &&
 851        cat >expected <<\EOF &&
 852On branch master
 853nothing to commit (use -u to show untracked files)
 854EOF
 855        git status --untracked-files=no >actual &&
 856        test_i18ncmp expected actual
 857'
 858
 859test_expect_success 'prepare for different number of commits rebased' '
 860        git reset --hard master &&
 861        git checkout -b several_commits &&
 862        test_commit one_commit main.txt one &&
 863        test_commit two_commit main.txt two &&
 864        test_commit three_commit main.txt three &&
 865        test_commit four_commit main.txt four
 866'
 867
 868test_expect_success 'status: one command done nothing remaining' '
 869        FAKE_LINES="exec_exit_15" &&
 870        export FAKE_LINES &&
 871        test_when_finished "git rebase --abort" &&
 872        ONTO=$(git rev-parse --short HEAD~3) &&
 873        test_must_fail git rebase -i HEAD~3 &&
 874        cat >expected <<EOF &&
 875interactive rebase in progress; onto $ONTO
 876Last command done (1 command done):
 877   exec exit 15
 878No commands remaining.
 879You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
 880  (use "git commit --amend" to amend the current commit)
 881  (use "git rebase --continue" once you are satisfied with your changes)
 882
 883nothing to commit (use -u to show untracked files)
 884EOF
 885        git status --untracked-files=no >actual &&
 886        test_i18ncmp expected actual
 887'
 888
 889test_expect_success 'status: two commands done with some white lines in done file' '
 890        FAKE_LINES="1 > exec_exit_15  2 3" &&
 891        export FAKE_LINES &&
 892        test_when_finished "git rebase --abort" &&
 893        ONTO=$(git rev-parse --short HEAD~3) &&
 894        COMMIT4=$(git rev-parse --short HEAD) &&
 895        COMMIT3=$(git rev-parse --short HEAD^) &&
 896        COMMIT2=$(git rev-parse --short HEAD^^) &&
 897        test_must_fail git rebase -i HEAD~3 &&
 898        cat >expected <<EOF &&
 899interactive rebase in progress; onto $ONTO
 900Last commands done (2 commands done):
 901   pick $COMMIT2 two_commit
 902   exec exit 15
 903Next commands to do (2 remaining commands):
 904   pick $COMMIT3 three_commit
 905   pick $COMMIT4 four_commit
 906  (use "git rebase --edit-todo" to view and edit)
 907You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
 908  (use "git commit --amend" to amend the current commit)
 909  (use "git rebase --continue" once you are satisfied with your changes)
 910
 911nothing to commit (use -u to show untracked files)
 912EOF
 913        git status --untracked-files=no >actual &&
 914        test_i18ncmp expected actual
 915'
 916
 917test_expect_success 'status: two remaining commands with some white lines in todo file' '
 918        FAKE_LINES="1 2 exec_exit_15 3 > 4" &&
 919        export FAKE_LINES &&
 920        test_when_finished "git rebase --abort" &&
 921        ONTO=$(git rev-parse --short HEAD~4) &&
 922        COMMIT4=$(git rev-parse --short HEAD) &&
 923        COMMIT3=$(git rev-parse --short HEAD^) &&
 924        COMMIT2=$(git rev-parse --short HEAD^^) &&
 925        test_must_fail git rebase -i HEAD~4 &&
 926        cat >expected <<EOF &&
 927interactive rebase in progress; onto $ONTO
 928Last commands done (3 commands done):
 929   pick $COMMIT2 two_commit
 930   exec exit 15
 931  (see more in file .git/rebase-merge/done)
 932Next commands to do (2 remaining commands):
 933   pick $COMMIT3 three_commit
 934   pick $COMMIT4 four_commit
 935  (use "git rebase --edit-todo" to view and edit)
 936You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
 937  (use "git commit --amend" to amend the current commit)
 938  (use "git rebase --continue" once you are satisfied with your changes)
 939
 940nothing to commit (use -u to show untracked files)
 941EOF
 942        git status --untracked-files=no >actual &&
 943        test_i18ncmp expected actual
 944'
 945
 946test_done