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