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