a000ed4e7f5a3c7951842fc8b72fefb14eaa9ad9
   1#!/bin/sh
   2#
   3# Copyright (c) 2007 Johannes E. Schindelin
   4#
   5
   6test_description='git status'
   7
   8. ./test-lib.sh
   9
  10test_expect_success 'status -h in broken repository' '
  11        git config --global advice.statusuoption false &&
  12        mkdir broken &&
  13        test_when_finished "rm -fr broken" &&
  14        (
  15                cd broken &&
  16                git init &&
  17                echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
  18                test_expect_code 129 git status -h >usage 2>&1
  19        ) &&
  20        test_i18ngrep "[Uu]sage" broken/usage
  21'
  22
  23test_expect_success 'commit -h in broken repository' '
  24        mkdir broken &&
  25        test_when_finished "rm -fr broken" &&
  26        (
  27                cd broken &&
  28                git init &&
  29                echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
  30                test_expect_code 129 git commit -h >usage 2>&1
  31        ) &&
  32        test_i18ngrep "[Uu]sage" broken/usage
  33'
  34
  35test_expect_success 'create upstream branch' '
  36        git checkout -b upstream &&
  37        test_commit upstream1 &&
  38        test_commit upstream2 &&
  39        # leave the first commit on master as root because several
  40        # tests depend on this case; for our upstream we only
  41        # care about commit counts anyway, so a totally divergent
  42        # history is OK
  43        git checkout --orphan master
  44'
  45
  46test_expect_success 'setup' '
  47        : >tracked &&
  48        : >modified &&
  49        mkdir dir1 &&
  50        : >dir1/tracked &&
  51        : >dir1/modified &&
  52        mkdir dir2 &&
  53        : >dir1/tracked &&
  54        : >dir1/modified &&
  55        git add . &&
  56
  57        git status >output &&
  58
  59        test_tick &&
  60        git commit -m initial &&
  61        : >untracked &&
  62        : >dir1/untracked &&
  63        : >dir2/untracked &&
  64        echo 1 >dir1/modified &&
  65        echo 2 >dir2/modified &&
  66        echo 3 >dir2/added &&
  67        git add dir2/added &&
  68
  69        git branch --set-upstream-to=upstream
  70'
  71
  72test_expect_success 'status (1)' '
  73        test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output
  74'
  75
  76strip_comments () {
  77        tab='   '
  78        sed "s/^\# //; s/^\#$//; s/^#$tab/$tab/" <"$1" >"$1".tmp &&
  79        rm "$1" && mv "$1".tmp "$1"
  80}
  81
  82cat >.gitignore <<\EOF
  83.gitignore
  84expect*
  85output*
  86EOF
  87
  88test_expect_success 'status --column' '
  89        cat >expect <<\EOF &&
  90# On branch master
  91# Your branch and '\''upstream'\'' have diverged,
  92# and have 1 and 2 different commits each, respectively.
  93#   (use "git pull" to merge the remote branch into yours)
  94#
  95# Changes to be committed:
  96#   (use "git reset HEAD <file>..." to unstage)
  97#
  98#       new file:   dir2/added
  99#
 100# Changes not staged for commit:
 101#   (use "git add <file>..." to update what will be committed)
 102#   (use "git checkout -- <file>..." to discard changes in working directory)
 103#
 104#       modified:   dir1/modified
 105#
 106# Untracked files:
 107#   (use "git add <file>..." to include in what will be committed)
 108#
 109#       dir1/untracked dir2/untracked
 110#       dir2/modified  untracked
 111#
 112EOF
 113        COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
 114        test_i18ncmp expect output
 115'
 116
 117test_expect_success 'status --column status.displayCommentPrefix=false' '
 118        strip_comments expect &&
 119        COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
 120        test_i18ncmp expect output
 121'
 122
 123cat >expect <<\EOF
 124# On branch master
 125# Your branch and 'upstream' have diverged,
 126# and have 1 and 2 different commits each, respectively.
 127#   (use "git pull" to merge the remote branch into yours)
 128#
 129# Changes to be committed:
 130#   (use "git reset HEAD <file>..." to unstage)
 131#
 132#       new file:   dir2/added
 133#
 134# Changes not staged for commit:
 135#   (use "git add <file>..." to update what will be committed)
 136#   (use "git checkout -- <file>..." to discard changes in working directory)
 137#
 138#       modified:   dir1/modified
 139#
 140# Untracked files:
 141#   (use "git add <file>..." to include in what will be committed)
 142#
 143#       dir1/untracked
 144#       dir2/modified
 145#       dir2/untracked
 146#       untracked
 147#
 148EOF
 149
 150test_expect_success 'status with status.displayCommentPrefix=true' '
 151        git -c status.displayCommentPrefix=true status >output &&
 152        test_i18ncmp expect output
 153'
 154
 155test_expect_success 'status with status.displayCommentPrefix=false' '
 156        strip_comments expect &&
 157        git -c status.displayCommentPrefix=false status >output &&
 158        test_i18ncmp expect output
 159'
 160
 161test_expect_success 'status -v' '
 162        (cat expect && git diff --cached) >expect-with-v &&
 163        git status -v >output &&
 164        test_i18ncmp expect-with-v output
 165'
 166
 167test_expect_success 'status -v -v' '
 168        (cat expect &&
 169         echo "Changes to be committed:" &&
 170         git -c diff.mnemonicprefix=true diff --cached &&
 171         echo "--------------------------------------------------" &&
 172         echo "Changes not staged for commit:" &&
 173         git -c diff.mnemonicprefix=true diff) >expect-with-v &&
 174        git status -v -v >output &&
 175        test_i18ncmp expect-with-v output
 176'
 177
 178test_expect_success 'setup fake editor' '
 179        cat >.git/editor <<-\EOF &&
 180        #! /bin/sh
 181        cp "$1" output
 182EOF
 183        chmod 755 .git/editor
 184'
 185
 186commit_template_commented () {
 187        (
 188                EDITOR=.git/editor &&
 189                export EDITOR &&
 190                # Fails due to empty message
 191                test_must_fail git commit
 192        ) &&
 193        ! grep '^[^#]' output
 194}
 195
 196test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
 197        commit_template_commented
 198'
 199
 200cat >expect <<\EOF
 201On branch master
 202Your branch and 'upstream' have diverged,
 203and have 1 and 2 different commits each, respectively.
 204
 205Changes to be committed:
 206        new file:   dir2/added
 207
 208Changes not staged for commit:
 209        modified:   dir1/modified
 210
 211Untracked files:
 212        dir1/untracked
 213        dir2/modified
 214        dir2/untracked
 215        untracked
 216
 217EOF
 218
 219test_expect_success 'status (advice.statusHints false)' '
 220        test_config advice.statusHints false &&
 221        git status >output &&
 222        test_i18ncmp expect output
 223
 224'
 225
 226cat >expect <<\EOF
 227 M dir1/modified
 228A  dir2/added
 229?? dir1/untracked
 230?? dir2/modified
 231?? dir2/untracked
 232?? untracked
 233EOF
 234
 235test_expect_success 'status -s' '
 236
 237        git status -s >output &&
 238        test_cmp expect output
 239
 240'
 241
 242test_expect_success 'status with gitignore' '
 243        {
 244                echo ".gitignore" &&
 245                echo "expect*" &&
 246                echo "output" &&
 247                echo "untracked"
 248        } >.gitignore &&
 249
 250        cat >expect <<-\EOF &&
 251         M dir1/modified
 252        A  dir2/added
 253        ?? dir2/modified
 254        EOF
 255        git status -s >output &&
 256        test_cmp expect output &&
 257
 258        cat >expect <<-\EOF &&
 259         M dir1/modified
 260        A  dir2/added
 261        ?? dir2/modified
 262        !! .gitignore
 263        !! dir1/untracked
 264        !! dir2/untracked
 265        !! expect
 266        !! expect-with-v
 267        !! output
 268        !! untracked
 269        EOF
 270        git status -s --ignored >output &&
 271        test_cmp expect output &&
 272
 273        cat >expect <<\EOF &&
 274On branch master
 275Your branch and '\''upstream'\'' have diverged,
 276and have 1 and 2 different commits each, respectively.
 277  (use "git pull" to merge the remote branch into yours)
 278
 279Changes to be committed:
 280  (use "git reset HEAD <file>..." to unstage)
 281
 282        new file:   dir2/added
 283
 284Changes not staged for commit:
 285  (use "git add <file>..." to update what will be committed)
 286  (use "git checkout -- <file>..." to discard changes in working directory)
 287
 288        modified:   dir1/modified
 289
 290Untracked files:
 291  (use "git add <file>..." to include in what will be committed)
 292
 293        dir2/modified
 294
 295Ignored files:
 296  (use "git add -f <file>..." to include in what will be committed)
 297
 298        .gitignore
 299        dir1/untracked
 300        dir2/untracked
 301        expect
 302        expect-with-v
 303        output
 304        untracked
 305
 306EOF
 307        git status --ignored >output &&
 308        test_i18ncmp expect output
 309'
 310
 311test_expect_success 'status with gitignore (nothing untracked)' '
 312        {
 313                echo ".gitignore" &&
 314                echo "expect*" &&
 315                echo "dir2/modified" &&
 316                echo "output" &&
 317                echo "untracked"
 318        } >.gitignore &&
 319
 320        cat >expect <<-\EOF &&
 321         M dir1/modified
 322        A  dir2/added
 323        EOF
 324        git status -s >output &&
 325        test_cmp expect output &&
 326
 327        cat >expect <<-\EOF &&
 328         M dir1/modified
 329        A  dir2/added
 330        !! .gitignore
 331        !! dir1/untracked
 332        !! dir2/modified
 333        !! dir2/untracked
 334        !! expect
 335        !! expect-with-v
 336        !! output
 337        !! untracked
 338        EOF
 339        git status -s --ignored >output &&
 340        test_cmp expect output &&
 341
 342        cat >expect <<\EOF &&
 343On branch master
 344Your branch and '\''upstream'\'' have diverged,
 345and have 1 and 2 different commits each, respectively.
 346  (use "git pull" to merge the remote branch into yours)
 347
 348Changes to be committed:
 349  (use "git reset HEAD <file>..." to unstage)
 350
 351        new file:   dir2/added
 352
 353Changes not staged for commit:
 354  (use "git add <file>..." to update what will be committed)
 355  (use "git checkout -- <file>..." to discard changes in working directory)
 356
 357        modified:   dir1/modified
 358
 359Ignored files:
 360  (use "git add -f <file>..." to include in what will be committed)
 361
 362        .gitignore
 363        dir1/untracked
 364        dir2/modified
 365        dir2/untracked
 366        expect
 367        expect-with-v
 368        output
 369        untracked
 370
 371EOF
 372        git status --ignored >output &&
 373        test_i18ncmp expect output
 374'
 375
 376cat >.gitignore <<\EOF
 377.gitignore
 378expect*
 379output*
 380EOF
 381
 382cat >expect <<\EOF
 383## master...upstream [ahead 1, behind 2]
 384 M dir1/modified
 385A  dir2/added
 386?? dir1/untracked
 387?? dir2/modified
 388?? dir2/untracked
 389?? untracked
 390EOF
 391
 392test_expect_success 'status -s -b' '
 393
 394        git status -s -b >output &&
 395        test_cmp expect output
 396
 397'
 398
 399test_expect_success 'status -s -z -b' '
 400        tr "\\n" Q <expect >expect.q &&
 401        mv expect.q expect &&
 402        git status -s -z -b >output &&
 403        nul_to_q <output >output.q &&
 404        mv output.q output &&
 405        test_cmp expect output
 406'
 407
 408test_expect_success 'setup dir3' '
 409        mkdir dir3 &&
 410        : >dir3/untracked1 &&
 411        : >dir3/untracked2
 412'
 413
 414test_expect_success 'status -uno' '
 415        cat >expect <<EOF &&
 416On branch master
 417Your branch and '\''upstream'\'' have diverged,
 418and have 1 and 2 different commits each, respectively.
 419  (use "git pull" to merge the remote branch into yours)
 420
 421Changes to be committed:
 422  (use "git reset HEAD <file>..." to unstage)
 423
 424        new file:   dir2/added
 425
 426Changes not staged for commit:
 427  (use "git add <file>..." to update what will be committed)
 428  (use "git checkout -- <file>..." to discard changes in working directory)
 429
 430        modified:   dir1/modified
 431
 432Untracked files not listed (use -u option to show untracked files)
 433EOF
 434        git status -uno >output &&
 435        test_i18ncmp expect output
 436'
 437
 438test_expect_success 'status (status.showUntrackedFiles no)' '
 439        test_config status.showuntrackedfiles no &&
 440        git status >output &&
 441        test_i18ncmp expect output
 442'
 443
 444test_expect_success 'status -uno (advice.statusHints false)' '
 445        cat >expect <<EOF &&
 446On branch master
 447Your branch and '\''upstream'\'' have diverged,
 448and have 1 and 2 different commits each, respectively.
 449
 450Changes to be committed:
 451        new file:   dir2/added
 452
 453Changes not staged for commit:
 454        modified:   dir1/modified
 455
 456Untracked files not listed
 457EOF
 458        test_config advice.statusHints false &&
 459        git status -uno >output &&
 460        test_i18ncmp expect output
 461'
 462
 463cat >expect << EOF
 464 M dir1/modified
 465A  dir2/added
 466EOF
 467test_expect_success 'status -s -uno' '
 468        git status -s -uno >output &&
 469        test_cmp expect output
 470'
 471
 472test_expect_success 'status -s (status.showUntrackedFiles no)' '
 473        git config status.showuntrackedfiles no &&
 474        git status -s >output &&
 475        test_cmp expect output
 476'
 477
 478test_expect_success 'status -unormal' '
 479        cat >expect <<EOF &&
 480On branch master
 481Your branch and '\''upstream'\'' have diverged,
 482and have 1 and 2 different commits each, respectively.
 483  (use "git pull" to merge the remote branch into yours)
 484
 485Changes to be committed:
 486  (use "git reset HEAD <file>..." to unstage)
 487
 488        new file:   dir2/added
 489
 490Changes not staged for commit:
 491  (use "git add <file>..." to update what will be committed)
 492  (use "git checkout -- <file>..." to discard changes in working directory)
 493
 494        modified:   dir1/modified
 495
 496Untracked files:
 497  (use "git add <file>..." to include in what will be committed)
 498
 499        dir1/untracked
 500        dir2/modified
 501        dir2/untracked
 502        dir3/
 503        untracked
 504
 505EOF
 506        git status -unormal >output &&
 507        test_i18ncmp expect output
 508'
 509
 510test_expect_success 'status (status.showUntrackedFiles normal)' '
 511        test_config status.showuntrackedfiles normal &&
 512        git status >output &&
 513        test_i18ncmp expect output
 514'
 515
 516cat >expect <<EOF
 517 M dir1/modified
 518A  dir2/added
 519?? dir1/untracked
 520?? dir2/modified
 521?? dir2/untracked
 522?? dir3/
 523?? untracked
 524EOF
 525test_expect_success 'status -s -unormal' '
 526        git status -s -unormal >output &&
 527        test_cmp expect output
 528'
 529
 530test_expect_success 'status -s (status.showUntrackedFiles normal)' '
 531        git config status.showuntrackedfiles normal &&
 532        git status -s >output &&
 533        test_cmp expect output
 534'
 535
 536test_expect_success 'status -uall' '
 537        cat >expect <<EOF &&
 538On branch master
 539Your branch and '\''upstream'\'' have diverged,
 540and have 1 and 2 different commits each, respectively.
 541  (use "git pull" to merge the remote branch into yours)
 542
 543Changes to be committed:
 544  (use "git reset HEAD <file>..." to unstage)
 545
 546        new file:   dir2/added
 547
 548Changes not staged for commit:
 549  (use "git add <file>..." to update what will be committed)
 550  (use "git checkout -- <file>..." to discard changes in working directory)
 551
 552        modified:   dir1/modified
 553
 554Untracked files:
 555  (use "git add <file>..." to include in what will be committed)
 556
 557        dir1/untracked
 558        dir2/modified
 559        dir2/untracked
 560        dir3/untracked1
 561        dir3/untracked2
 562        untracked
 563
 564EOF
 565        git status -uall >output &&
 566        test_i18ncmp expect output
 567'
 568
 569test_expect_success 'status (status.showUntrackedFiles all)' '
 570        test_config status.showuntrackedfiles all &&
 571        git status >output &&
 572        test_i18ncmp expect output
 573'
 574
 575test_expect_success 'teardown dir3' '
 576        rm -rf dir3
 577'
 578
 579cat >expect <<EOF
 580 M dir1/modified
 581A  dir2/added
 582?? dir1/untracked
 583?? dir2/modified
 584?? dir2/untracked
 585?? untracked
 586EOF
 587test_expect_success 'status -s -uall' '
 588        test_unconfig status.showuntrackedfiles &&
 589        git status -s -uall >output &&
 590        test_cmp expect output
 591'
 592test_expect_success 'status -s (status.showUntrackedFiles all)' '
 593        test_config status.showuntrackedfiles all &&
 594        git status -s >output &&
 595        rm -rf dir3 &&
 596        test_cmp expect output
 597'
 598
 599test_expect_success 'status with relative paths' '
 600        cat >expect <<\EOF &&
 601On branch master
 602Your branch and '\''upstream'\'' have diverged,
 603and have 1 and 2 different commits each, respectively.
 604  (use "git pull" to merge the remote branch into yours)
 605
 606Changes to be committed:
 607  (use "git reset HEAD <file>..." to unstage)
 608
 609        new file:   ../dir2/added
 610
 611Changes not staged for commit:
 612  (use "git add <file>..." to update what will be committed)
 613  (use "git checkout -- <file>..." to discard changes in working directory)
 614
 615        modified:   modified
 616
 617Untracked files:
 618  (use "git add <file>..." to include in what will be committed)
 619
 620        untracked
 621        ../dir2/modified
 622        ../dir2/untracked
 623        ../untracked
 624
 625EOF
 626        (cd dir1 && git status) >output &&
 627        test_i18ncmp expect output
 628'
 629
 630cat >expect <<\EOF
 631 M modified
 632A  ../dir2/added
 633?? untracked
 634?? ../dir2/modified
 635?? ../dir2/untracked
 636?? ../untracked
 637EOF
 638test_expect_success 'status -s with relative paths' '
 639
 640        (cd dir1 && git status -s) >output &&
 641        test_cmp expect output
 642
 643'
 644
 645cat >expect <<\EOF
 646 M dir1/modified
 647A  dir2/added
 648?? dir1/untracked
 649?? dir2/modified
 650?? dir2/untracked
 651?? untracked
 652EOF
 653
 654test_expect_success 'status --porcelain ignores relative paths setting' '
 655
 656        (cd dir1 && git status --porcelain) >output &&
 657        test_cmp expect output
 658
 659'
 660
 661test_expect_success 'setup unique colors' '
 662
 663        git config status.color.untracked blue &&
 664        git config status.color.branch green
 665
 666'
 667
 668test_expect_success 'status with color.ui' '
 669        cat >expect <<\EOF &&
 670On branch <GREEN>master<RESET>
 671Your branch and '\''upstream'\'' have diverged,
 672and have 1 and 2 different commits each, respectively.
 673  (use "git pull" to merge the remote branch into yours)
 674
 675Changes to be committed:
 676  (use "git reset HEAD <file>..." to unstage)
 677
 678        <GREEN>new file:   dir2/added<RESET>
 679
 680Changes not staged for commit:
 681  (use "git add <file>..." to update what will be committed)
 682  (use "git checkout -- <file>..." to discard changes in working directory)
 683
 684        <RED>modified:   dir1/modified<RESET>
 685
 686Untracked files:
 687  (use "git add <file>..." to include in what will be committed)
 688
 689        <BLUE>dir1/untracked<RESET>
 690        <BLUE>dir2/modified<RESET>
 691        <BLUE>dir2/untracked<RESET>
 692        <BLUE>untracked<RESET>
 693
 694EOF
 695        test_config color.ui always &&
 696        git status | test_decode_color >output &&
 697        test_i18ncmp expect output
 698'
 699
 700test_expect_success 'status with color.status' '
 701        test_config color.status always &&
 702        git status | test_decode_color >output &&
 703        test_i18ncmp expect output
 704'
 705
 706cat >expect <<\EOF
 707 <RED>M<RESET> dir1/modified
 708<GREEN>A<RESET>  dir2/added
 709<BLUE>??<RESET> dir1/untracked
 710<BLUE>??<RESET> dir2/modified
 711<BLUE>??<RESET> dir2/untracked
 712<BLUE>??<RESET> untracked
 713EOF
 714
 715test_expect_success 'status -s with color.ui' '
 716
 717        git config color.ui always &&
 718        git status -s | test_decode_color >output &&
 719        test_cmp expect output
 720
 721'
 722
 723test_expect_success 'status -s with color.status' '
 724
 725        git config --unset color.ui &&
 726        git config color.status always &&
 727        git status -s | test_decode_color >output &&
 728        test_cmp expect output
 729
 730'
 731
 732cat >expect <<\EOF
 733## <GREEN>master<RESET>...<RED>upstream<RESET> [ahead <GREEN>1<RESET>, behind <RED>2<RESET>]
 734 <RED>M<RESET> dir1/modified
 735<GREEN>A<RESET>  dir2/added
 736<BLUE>??<RESET> dir1/untracked
 737<BLUE>??<RESET> dir2/modified
 738<BLUE>??<RESET> dir2/untracked
 739<BLUE>??<RESET> untracked
 740EOF
 741
 742test_expect_success 'status -s -b with color.status' '
 743
 744        git status -s -b | test_decode_color >output &&
 745        test_cmp expect output
 746
 747'
 748
 749cat >expect <<\EOF
 750 M dir1/modified
 751A  dir2/added
 752?? dir1/untracked
 753?? dir2/modified
 754?? dir2/untracked
 755?? untracked
 756EOF
 757
 758test_expect_success 'status --porcelain ignores color.ui' '
 759
 760        git config --unset color.status &&
 761        git config color.ui always &&
 762        git status --porcelain | test_decode_color >output &&
 763        test_cmp expect output
 764
 765'
 766
 767test_expect_success 'status --porcelain ignores color.status' '
 768
 769        git config --unset color.ui &&
 770        git config color.status always &&
 771        git status --porcelain | test_decode_color >output &&
 772        test_cmp expect output
 773
 774'
 775
 776# recover unconditionally from color tests
 777git config --unset color.status
 778git config --unset color.ui
 779
 780test_expect_success 'status --porcelain respects -b' '
 781
 782        git status --porcelain -b >output &&
 783        {
 784                echo "## master...upstream [ahead 1, behind 2]" &&
 785                cat expect
 786        } >tmp &&
 787        mv tmp expect &&
 788        test_cmp expect output
 789
 790'
 791
 792
 793
 794test_expect_success 'status without relative paths' '
 795        cat >expect <<\EOF &&
 796On branch master
 797Your branch and '\''upstream'\'' have diverged,
 798and have 1 and 2 different commits each, respectively.
 799  (use "git pull" to merge the remote branch into yours)
 800
 801Changes to be committed:
 802  (use "git reset HEAD <file>..." to unstage)
 803
 804        new file:   dir2/added
 805
 806Changes not staged for commit:
 807  (use "git add <file>..." to update what will be committed)
 808  (use "git checkout -- <file>..." to discard changes in working directory)
 809
 810        modified:   dir1/modified
 811
 812Untracked files:
 813  (use "git add <file>..." to include in what will be committed)
 814
 815        dir1/untracked
 816        dir2/modified
 817        dir2/untracked
 818        untracked
 819
 820EOF
 821        test_config status.relativePaths false &&
 822        (cd dir1 && git status) >output &&
 823        test_i18ncmp expect output
 824
 825'
 826
 827cat >expect <<\EOF
 828 M dir1/modified
 829A  dir2/added
 830?? dir1/untracked
 831?? dir2/modified
 832?? dir2/untracked
 833?? untracked
 834EOF
 835
 836test_expect_success 'status -s without relative paths' '
 837
 838        test_config status.relativePaths false &&
 839        (cd dir1 && git status -s) >output &&
 840        test_cmp expect output
 841
 842'
 843
 844test_expect_success 'dry-run of partial commit excluding new file in index' '
 845        cat >expect <<EOF &&
 846On branch master
 847Your branch and '\''upstream'\'' have diverged,
 848and have 1 and 2 different commits each, respectively.
 849  (use "git pull" to merge the remote branch into yours)
 850
 851Changes to be committed:
 852  (use "git reset HEAD <file>..." to unstage)
 853
 854        modified:   dir1/modified
 855
 856Untracked files:
 857  (use "git add <file>..." to include in what will be committed)
 858
 859        dir1/untracked
 860        dir2/
 861        untracked
 862
 863EOF
 864        git commit --dry-run dir1/modified >output &&
 865        test_i18ncmp expect output
 866'
 867
 868cat >expect <<EOF
 869:100644 100644 $EMPTY_BLOB 0000000000000000000000000000000000000000 M   dir1/modified
 870EOF
 871test_expect_success 'status refreshes the index' '
 872        touch dir2/added &&
 873        git status &&
 874        git diff-files >output &&
 875        test_cmp expect output
 876'
 877
 878test_expect_success 'setup status submodule summary' '
 879        test_create_repo sm && (
 880                cd sm &&
 881                >foo &&
 882                git add foo &&
 883                git commit -m "Add foo"
 884        ) &&
 885        git add sm
 886'
 887
 888test_expect_success 'status submodule summary is disabled by default' '
 889        cat >expect <<EOF &&
 890On branch master
 891Your branch and '\''upstream'\'' have diverged,
 892and have 1 and 2 different commits each, respectively.
 893  (use "git pull" to merge the remote branch into yours)
 894
 895Changes to be committed:
 896  (use "git reset HEAD <file>..." to unstage)
 897
 898        new file:   dir2/added
 899        new file:   sm
 900
 901Changes not staged for commit:
 902  (use "git add <file>..." to update what will be committed)
 903  (use "git checkout -- <file>..." to discard changes in working directory)
 904
 905        modified:   dir1/modified
 906
 907Untracked files:
 908  (use "git add <file>..." to include in what will be committed)
 909
 910        dir1/untracked
 911        dir2/modified
 912        dir2/untracked
 913        untracked
 914
 915EOF
 916        git status >output &&
 917        test_i18ncmp expect output
 918'
 919
 920# we expect the same as the previous test
 921test_expect_success 'status --untracked-files=all does not show submodule' '
 922        git status --untracked-files=all >output &&
 923        test_i18ncmp expect output
 924'
 925
 926cat >expect <<EOF
 927 M dir1/modified
 928A  dir2/added
 929A  sm
 930?? dir1/untracked
 931?? dir2/modified
 932?? dir2/untracked
 933?? untracked
 934EOF
 935test_expect_success 'status -s submodule summary is disabled by default' '
 936        git status -s >output &&
 937        test_cmp expect output
 938'
 939
 940# we expect the same as the previous test
 941test_expect_success 'status -s --untracked-files=all does not show submodule' '
 942        git status -s --untracked-files=all >output &&
 943        test_cmp expect output
 944'
 945
 946head=$(cd sm && git rev-parse --short=7 --verify HEAD)
 947
 948test_expect_success 'status submodule summary' '
 949        cat >expect <<EOF &&
 950On branch master
 951Your branch and '\''upstream'\'' have diverged,
 952and have 1 and 2 different commits each, respectively.
 953  (use "git pull" to merge the remote branch into yours)
 954
 955Changes to be committed:
 956  (use "git reset HEAD <file>..." to unstage)
 957
 958        new file:   dir2/added
 959        new file:   sm
 960
 961Changes not staged for commit:
 962  (use "git add <file>..." to update what will be committed)
 963  (use "git checkout -- <file>..." to discard changes in working directory)
 964
 965        modified:   dir1/modified
 966
 967Submodule changes to be committed:
 968
 969* sm 0000000...$head (1):
 970  > Add foo
 971
 972Untracked files:
 973  (use "git add <file>..." to include in what will be committed)
 974
 975        dir1/untracked
 976        dir2/modified
 977        dir2/untracked
 978        untracked
 979
 980EOF
 981        git config status.submodulesummary 10 &&
 982        git status >output &&
 983        test_i18ncmp expect output
 984'
 985
 986test_expect_success 'status submodule summary with status.displayCommentPrefix=false' '
 987        strip_comments expect &&
 988        git -c status.displayCommentPrefix=false status >output &&
 989        test_i18ncmp expect output
 990'
 991
 992test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' '
 993        commit_template_commented
 994'
 995
 996cat >expect <<EOF
 997 M dir1/modified
 998A  dir2/added
 999A  sm
1000?? dir1/untracked
1001?? dir2/modified
1002?? dir2/untracked
1003?? untracked
1004EOF
1005test_expect_success 'status -s submodule summary' '
1006        git status -s >output &&
1007        test_cmp expect output
1008'
1009
1010test_expect_success 'status submodule summary (clean submodule): commit' '
1011        cat >expect <<EOF &&
1012On branch master
1013Your branch and '\''upstream'\'' have diverged,
1014and have 2 and 2 different commits each, respectively.
1015  (use "git pull" to merge the remote branch into yours)
1016
1017Changes not staged for commit:
1018  (use "git add <file>..." to update what will be committed)
1019  (use "git checkout -- <file>..." to discard changes in working directory)
1020
1021        modified:   dir1/modified
1022
1023Untracked files:
1024  (use "git add <file>..." to include in what will be committed)
1025
1026        dir1/untracked
1027        dir2/modified
1028        dir2/untracked
1029        untracked
1030
1031no changes added to commit (use "git add" and/or "git commit -a")
1032EOF
1033        git commit -m "commit submodule" &&
1034        git config status.submodulesummary 10 &&
1035        test_must_fail git commit --dry-run >output &&
1036        test_i18ncmp expect output &&
1037        git status >output &&
1038        test_i18ncmp expect output
1039'
1040
1041cat >expect <<EOF
1042 M dir1/modified
1043?? dir1/untracked
1044?? dir2/modified
1045?? dir2/untracked
1046?? untracked
1047EOF
1048test_expect_success 'status -s submodule summary (clean submodule)' '
1049        git status -s >output &&
1050        test_cmp expect output
1051'
1052
1053test_expect_success 'status -z implies porcelain' '
1054        git status --porcelain |
1055        perl -pe "s/\012/\000/g" >expect &&
1056        git status -z >output &&
1057        test_cmp expect output
1058'
1059
1060test_expect_success 'commit --dry-run submodule summary (--amend)' '
1061        cat >expect <<EOF &&
1062On branch master
1063Your branch and '\''upstream'\'' have diverged,
1064and have 2 and 2 different commits each, respectively.
1065  (use "git pull" to merge the remote branch into yours)
1066
1067Changes to be committed:
1068  (use "git reset HEAD^1 <file>..." to unstage)
1069
1070        new file:   dir2/added
1071        new file:   sm
1072
1073Changes not staged for commit:
1074  (use "git add <file>..." to update what will be committed)
1075  (use "git checkout -- <file>..." to discard changes in working directory)
1076
1077        modified:   dir1/modified
1078
1079Submodule changes to be committed:
1080
1081* sm 0000000...$head (1):
1082  > Add foo
1083
1084Untracked files:
1085  (use "git add <file>..." to include in what will be committed)
1086
1087        dir1/untracked
1088        dir2/modified
1089        dir2/untracked
1090        untracked
1091
1092EOF
1093        git config status.submodulesummary 10 &&
1094        git commit --dry-run --amend >output &&
1095        test_i18ncmp expect output
1096'
1097
1098test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
1099        (
1100                chmod a-w .git &&
1101                # make dir1/tracked stat-dirty
1102                >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
1103                git status -s >output &&
1104                ! grep dir1/tracked output &&
1105                # make sure "status" succeeded without writing index out
1106                git diff-files | grep dir1/tracked
1107        )
1108        status=$?
1109        chmod 775 .git
1110        (exit $status)
1111'
1112
1113(cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
1114new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
1115touch .gitmodules
1116
1117test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1118        cat > expect << EOF &&
1119On branch master
1120Your branch and '\''upstream'\'' have diverged,
1121and have 2 and 2 different commits each, respectively.
1122  (use "git pull" to merge the remote branch into yours)
1123
1124Changes to be committed:
1125  (use "git reset HEAD <file>..." to unstage)
1126
1127        modified:   sm
1128
1129Changes not staged for commit:
1130  (use "git add <file>..." to update what will be committed)
1131  (use "git checkout -- <file>..." to discard changes in working directory)
1132
1133        modified:   dir1/modified
1134
1135Submodule changes to be committed:
1136
1137* sm $head...$new_head (1):
1138  > Add bar
1139
1140Untracked files:
1141  (use "git add <file>..." to include in what will be committed)
1142
1143        .gitmodules
1144        dir1/untracked
1145        dir2/modified
1146        dir2/untracked
1147        untracked
1148
1149EOF
1150        echo modified  sm/untracked &&
1151        git status --ignore-submodules=untracked >output &&
1152        test_i18ncmp expect output
1153'
1154
1155test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1156        test_config diff.ignoreSubmodules dirty &&
1157        git status >output &&
1158        test_i18ncmp expect output &&
1159        git config --add -f .gitmodules submodule.subname.ignore untracked &&
1160        git config --add -f .gitmodules submodule.subname.path sm &&
1161        git status >output &&
1162        test_i18ncmp expect output &&
1163        git config -f .gitmodules  --remove-section submodule.subname
1164'
1165
1166test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1167        git config --add -f .gitmodules submodule.subname.ignore none &&
1168        git config --add -f .gitmodules submodule.subname.path sm &&
1169        git config --add submodule.subname.ignore untracked &&
1170        git config --add submodule.subname.path sm &&
1171        git status >output &&
1172        test_i18ncmp expect output &&
1173        git config --remove-section submodule.subname &&
1174        git config --remove-section -f .gitmodules submodule.subname
1175'
1176
1177test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1178        git status --ignore-submodules=dirty >output &&
1179        test_i18ncmp expect output
1180'
1181
1182test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1183        test_config diff.ignoreSubmodules dirty &&
1184        git status >output &&
1185        ! test -s actual &&
1186        git config --add -f .gitmodules submodule.subname.ignore dirty &&
1187        git config --add -f .gitmodules submodule.subname.path sm &&
1188        git status >output &&
1189        test_i18ncmp expect output &&
1190        git config -f .gitmodules  --remove-section submodule.subname
1191'
1192
1193test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1194        git config --add -f .gitmodules submodule.subname.ignore none &&
1195        git config --add -f .gitmodules submodule.subname.path sm &&
1196        git config --add submodule.subname.ignore dirty &&
1197        git config --add submodule.subname.path sm &&
1198        git status >output &&
1199        test_i18ncmp expect output &&
1200        git config --remove-section submodule.subname &&
1201        git config -f .gitmodules  --remove-section submodule.subname
1202'
1203
1204test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1205        echo modified >sm/foo &&
1206        git status --ignore-submodules=dirty >output &&
1207        test_i18ncmp expect output
1208'
1209
1210test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
1211        git config --add -f .gitmodules submodule.subname.ignore dirty &&
1212        git config --add -f .gitmodules submodule.subname.path sm &&
1213        git status >output &&
1214        test_i18ncmp expect output &&
1215        git config -f .gitmodules  --remove-section submodule.subname
1216'
1217
1218test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
1219        git config --add -f .gitmodules submodule.subname.ignore none &&
1220        git config --add -f .gitmodules submodule.subname.path sm &&
1221        git config --add submodule.subname.ignore dirty &&
1222        git config --add submodule.subname.path sm &&
1223        git status >output &&
1224        test_i18ncmp expect output &&
1225        git config --remove-section submodule.subname &&
1226        git config -f .gitmodules  --remove-section submodule.subname
1227'
1228
1229test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1230        cat > expect << EOF &&
1231On branch master
1232Your branch and '\''upstream'\'' have diverged,
1233and have 2 and 2 different commits each, respectively.
1234  (use "git pull" to merge the remote branch into yours)
1235
1236Changes to be committed:
1237  (use "git reset HEAD <file>..." to unstage)
1238
1239        modified:   sm
1240
1241Changes not staged for commit:
1242  (use "git add <file>..." to update what will be committed)
1243  (use "git checkout -- <file>..." to discard changes in working directory)
1244  (commit or discard the untracked or modified content in submodules)
1245
1246        modified:   dir1/modified
1247        modified:   sm (modified content)
1248
1249Submodule changes to be committed:
1250
1251* sm $head...$new_head (1):
1252  > Add bar
1253
1254Untracked files:
1255  (use "git add <file>..." to include in what will be committed)
1256
1257        .gitmodules
1258        dir1/untracked
1259        dir2/modified
1260        dir2/untracked
1261        untracked
1262
1263EOF
1264        git status --ignore-submodules=untracked > output &&
1265        test_i18ncmp expect output
1266'
1267
1268test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
1269        git config --add -f .gitmodules submodule.subname.ignore untracked &&
1270        git config --add -f .gitmodules submodule.subname.path sm &&
1271        git status >output &&
1272        test_i18ncmp expect output &&
1273        git config -f .gitmodules  --remove-section submodule.subname
1274'
1275
1276test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1277        git config --add -f .gitmodules submodule.subname.ignore none &&
1278        git config --add -f .gitmodules submodule.subname.path sm &&
1279        git config --add submodule.subname.ignore untracked &&
1280        git config --add submodule.subname.path sm &&
1281        git status >output &&
1282        test_i18ncmp expect output &&
1283        git config --remove-section submodule.subname &&
1284        git config -f .gitmodules  --remove-section submodule.subname
1285'
1286
1287head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1288
1289test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1290        cat > expect << EOF &&
1291On branch master
1292Your branch and '\''upstream'\'' have diverged,
1293and have 2 and 2 different commits each, respectively.
1294  (use "git pull" to merge the remote branch into yours)
1295
1296Changes to be committed:
1297  (use "git reset HEAD <file>..." to unstage)
1298
1299        modified:   sm
1300
1301Changes not staged for commit:
1302  (use "git add <file>..." to update what will be committed)
1303  (use "git checkout -- <file>..." to discard changes in working directory)
1304
1305        modified:   dir1/modified
1306        modified:   sm (new commits)
1307
1308Submodule changes to be committed:
1309
1310* sm $head...$new_head (1):
1311  > Add bar
1312
1313Submodules changed but not updated:
1314
1315* sm $new_head...$head2 (1):
1316  > 2nd commit
1317
1318Untracked files:
1319  (use "git add <file>..." to include in what will be committed)
1320
1321        .gitmodules
1322        dir1/untracked
1323        dir2/modified
1324        dir2/untracked
1325        untracked
1326
1327EOF
1328        git status --ignore-submodules=untracked > output &&
1329        test_i18ncmp expect output
1330'
1331
1332test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1333        git config --add -f .gitmodules submodule.subname.ignore untracked &&
1334        git config --add -f .gitmodules submodule.subname.path sm &&
1335        git status >output &&
1336        test_i18ncmp expect output &&
1337        git config -f .gitmodules  --remove-section submodule.subname
1338'
1339
1340test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1341        git config --add -f .gitmodules submodule.subname.ignore none &&
1342        git config --add -f .gitmodules submodule.subname.path sm &&
1343        git config --add submodule.subname.ignore untracked &&
1344        git config --add submodule.subname.path sm &&
1345        git status >output &&
1346        test_i18ncmp expect output &&
1347        git config --remove-section submodule.subname &&
1348        git config -f .gitmodules  --remove-section submodule.subname
1349'
1350
1351test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1352        git status --ignore-submodules=dirty > output &&
1353        test_i18ncmp expect output
1354'
1355test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1356        git config --add -f .gitmodules submodule.subname.ignore dirty &&
1357        git config --add -f .gitmodules submodule.subname.path sm &&
1358        git status >output &&
1359        test_i18ncmp expect output &&
1360        git config -f .gitmodules  --remove-section submodule.subname
1361'
1362
1363test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1364        git config --add -f .gitmodules submodule.subname.ignore none &&
1365        git config --add -f .gitmodules submodule.subname.path sm &&
1366        git config --add submodule.subname.ignore dirty &&
1367        git config --add submodule.subname.path sm &&
1368        git status >output &&
1369        test_i18ncmp expect output &&
1370        git config --remove-section submodule.subname &&
1371        git config -f .gitmodules  --remove-section submodule.subname
1372'
1373
1374cat > expect << EOF
1375; On branch master
1376; Your branch and 'upstream' have diverged,
1377; and have 2 and 2 different commits each, respectively.
1378;   (use "git pull" to merge the remote branch into yours)
1379;
1380; Changes to be committed:
1381;   (use "git reset HEAD <file>..." to unstage)
1382;
1383;       modified:   sm
1384;
1385; Changes not staged for commit:
1386;   (use "git add <file>..." to update what will be committed)
1387;   (use "git checkout -- <file>..." to discard changes in working directory)
1388;
1389;       modified:   dir1/modified
1390;       modified:   sm (new commits)
1391;
1392; Submodule changes to be committed:
1393;
1394; * sm $head...$new_head (1):
1395;   > Add bar
1396;
1397; Submodules changed but not updated:
1398;
1399; * sm $new_head...$head2 (1):
1400;   > 2nd commit
1401;
1402; Untracked files:
1403;   (use "git add <file>..." to include in what will be committed)
1404;
1405;       .gitmodules
1406;       dir1/untracked
1407;       dir2/modified
1408;       dir2/untracked
1409;       untracked
1410;
1411EOF
1412
1413test_expect_success "status (core.commentchar with submodule summary)" '
1414        test_config core.commentchar ";" &&
1415        git -c status.displayCommentPrefix=true status >output &&
1416        test_i18ncmp expect output
1417'
1418
1419test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1420        test_config core.commentchar ";;" &&
1421        test_must_fail git -c status.displayCommentPrefix=true status
1422'
1423
1424test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1425        cat > expect << EOF &&
1426On branch master
1427Your branch and '\''upstream'\'' have diverged,
1428and have 2 and 2 different commits each, respectively.
1429  (use "git pull" to merge the remote branch into yours)
1430
1431Changes not staged for commit:
1432  (use "git add <file>..." to update what will be committed)
1433  (use "git checkout -- <file>..." to discard changes in working directory)
1434
1435        modified:   dir1/modified
1436
1437Untracked files:
1438  (use "git add <file>..." to include in what will be committed)
1439
1440        .gitmodules
1441        dir1/untracked
1442        dir2/modified
1443        dir2/untracked
1444        untracked
1445
1446no changes added to commit (use "git add" and/or "git commit -a")
1447EOF
1448        git status --ignore-submodules=all > output &&
1449        test_i18ncmp expect output
1450'
1451
1452test_expect_success '.gitmodules ignore=all suppresses unstaged submodule summary' '
1453        cat > expect << EOF &&
1454On branch master
1455Your branch and '\''upstream'\'' have diverged,
1456and have 2 and 2 different commits each, respectively.
1457  (use "git pull" to merge the remote branch into yours)
1458
1459Changes to be committed:
1460  (use "git reset HEAD <file>..." to unstage)
1461
1462        modified:   sm
1463
1464Changes not staged for commit:
1465  (use "git add <file>..." to update what will be committed)
1466  (use "git checkout -- <file>..." to discard changes in working directory)
1467
1468        modified:   dir1/modified
1469
1470Untracked files:
1471  (use "git add <file>..." to include in what will be committed)
1472
1473        .gitmodules
1474        dir1/untracked
1475        dir2/modified
1476        dir2/untracked
1477        untracked
1478
1479EOF
1480        git config --add -f .gitmodules submodule.subname.ignore all &&
1481        git config --add -f .gitmodules submodule.subname.path sm &&
1482        git status > output &&
1483        test_i18ncmp expect output &&
1484        git config -f .gitmodules  --remove-section submodule.subname
1485'
1486
1487test_expect_success '.git/config ignore=all suppresses unstaged submodule summary' '
1488        git config --add -f .gitmodules submodule.subname.ignore none &&
1489        git config --add -f .gitmodules submodule.subname.path sm &&
1490        git config --add submodule.subname.ignore all &&
1491        git config --add submodule.subname.path sm &&
1492        git status > output &&
1493        test_i18ncmp expect output &&
1494        git config --remove-section submodule.subname &&
1495        git config -f .gitmodules  --remove-section submodule.subname
1496'
1497
1498test_expect_success 'setup of test environment' '
1499        git config status.showUntrackedFiles no &&
1500        git status -s >expected_short &&
1501        git status --no-short >expected_noshort
1502'
1503
1504test_expect_success '"status.short=true" same as "-s"' '
1505        git -c status.short=true status >actual &&
1506        test_cmp expected_short actual
1507'
1508
1509test_expect_success '"status.short=true" weaker than "--no-short"' '
1510        git -c status.short=true status --no-short >actual &&
1511        test_cmp expected_noshort actual
1512'
1513
1514test_expect_success '"status.short=false" same as "--no-short"' '
1515        git -c status.short=false status >actual &&
1516        test_cmp expected_noshort actual
1517'
1518
1519test_expect_success '"status.short=false" weaker than "-s"' '
1520        git -c status.short=false status -s >actual &&
1521        test_cmp expected_short actual
1522'
1523
1524test_expect_success '"status.branch=true" same as "-b"' '
1525        git status -sb >expected_branch &&
1526        git -c status.branch=true status -s >actual &&
1527        test_cmp expected_branch actual
1528'
1529
1530test_expect_success '"status.branch=true" different from "--no-branch"' '
1531        git status -s --no-branch  >expected_nobranch &&
1532        git -c status.branch=true status -s >actual &&
1533        test_must_fail test_cmp expected_nobranch actual
1534'
1535
1536test_expect_success '"status.branch=true" weaker than "--no-branch"' '
1537        git -c status.branch=true status -s --no-branch >actual &&
1538        test_cmp expected_nobranch actual
1539'
1540
1541test_expect_success '"status.branch=true" weaker than "--porcelain"' '
1542       git -c status.branch=true status --porcelain >actual &&
1543       test_cmp expected_nobranch actual
1544'
1545
1546test_expect_success '"status.branch=false" same as "--no-branch"' '
1547        git -c status.branch=false status -s >actual &&
1548        test_cmp expected_nobranch actual
1549'
1550
1551test_expect_success '"status.branch=false" weaker than "-b"' '
1552        git -c status.branch=false status -sb >actual &&
1553        test_cmp expected_branch actual
1554'
1555
1556test_expect_success 'Restore default test environment' '
1557        git config --unset status.showUntrackedFiles
1558'
1559
1560test_expect_success 'git commit will commit a staged but ignored submodule' '
1561        git config --add -f .gitmodules submodule.subname.ignore all &&
1562        git config --add -f .gitmodules submodule.subname.path sm &&
1563        git config --add submodule.subname.ignore all &&
1564        git status -s --ignore-submodules=dirty >output &&
1565        test_i18ngrep "^M. sm" output &&
1566        GIT_EDITOR="echo hello >>\"\$1\"" &&
1567        export GIT_EDITOR &&
1568        git commit -uno &&
1569        git status -s --ignore-submodules=dirty >output &&
1570        test_i18ngrep ! "^M. sm" output
1571'
1572
1573test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '
1574        git reset HEAD^ &&
1575        git add sm &&
1576        cat >expect << EOF &&
1577On branch master
1578Your branch and '\''upstream'\'' have diverged,
1579and have 2 and 2 different commits each, respectively.
1580  (use "git pull" to merge the remote branch into yours)
1581
1582Changes to be committed:
1583  (use "git reset HEAD <file>..." to unstage)
1584
1585        modified:   sm
1586
1587Changes not staged for commit:
1588  (use "git add <file>..." to update what will be committed)
1589  (use "git checkout -- <file>..." to discard changes in working directory)
1590
1591        modified:   dir1/modified
1592
1593Untracked files not listed (use -u option to show untracked files)
1594EOF
1595        git commit -uno --dry-run >output &&
1596        test_i18ncmp expect output &&
1597        git status -s --ignore-submodules=dirty >output &&
1598        test_i18ngrep "^M. sm" output
1599'
1600
1601test_expect_success 'git commit -m will commit a staged but ignored submodule' '
1602        git commit -uno -m message &&
1603        git status -s --ignore-submodules=dirty >output &&
1604         test_i18ngrep ! "^M. sm" output &&
1605        git config --remove-section submodule.subname &&
1606        git config -f .gitmodules  --remove-section submodule.subname
1607'
1608
1609test_done