t / t7508-status.shon commit Merge branch 'sg/completion-updates' (0184435)
   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        mkdir broken &&
  12        test_when_finished "rm -fr broken" &&
  13        (
  14                cd broken &&
  15                git init &&
  16                echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
  17                test_expect_code 129 git status -h >usage 2>&1
  18        ) &&
  19        test_i18ngrep "[Uu]sage" broken/usage
  20'
  21
  22test_expect_success 'commit -h in broken repository' '
  23        mkdir broken &&
  24        test_when_finished "rm -fr broken" &&
  25        (
  26                cd broken &&
  27                git init &&
  28                echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
  29                test_expect_code 129 git commit -h >usage 2>&1
  30        ) &&
  31        test_i18ngrep "[Uu]sage" broken/usage
  32'
  33
  34test_expect_success 'setup' '
  35        : >tracked &&
  36        : >modified &&
  37        mkdir dir1 &&
  38        : >dir1/tracked &&
  39        : >dir1/modified &&
  40        mkdir dir2 &&
  41        : >dir1/tracked &&
  42        : >dir1/modified &&
  43        git add . &&
  44
  45        git status >output &&
  46
  47        test_tick &&
  48        git commit -m initial &&
  49        : >untracked &&
  50        : >dir1/untracked &&
  51        : >dir2/untracked &&
  52        echo 1 >dir1/modified &&
  53        echo 2 >dir2/modified &&
  54        echo 3 >dir2/added &&
  55        git add dir2/added
  56'
  57
  58test_expect_success 'status (1)' '
  59        test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output
  60'
  61
  62cat >expect <<\EOF
  63# On branch master
  64# Changes to be committed:
  65#   (use "git reset HEAD <file>..." to unstage)
  66#
  67#       new file:   dir2/added
  68#
  69# Changes not staged for commit:
  70#   (use "git add <file>..." to update what will be committed)
  71#   (use "git checkout -- <file>..." to discard changes in working directory)
  72#
  73#       modified:   dir1/modified
  74#
  75# Untracked files:
  76#   (use "git add <file>..." to include in what will be committed)
  77#
  78#       dir1/untracked
  79#       dir2/modified
  80#       dir2/untracked
  81#       expect
  82#       output
  83#       untracked
  84EOF
  85
  86test_expect_success 'status (2)' '
  87        git status >output &&
  88        test_i18ncmp expect output
  89'
  90
  91cat >expect <<\EOF
  92# On branch master
  93# Changes to be committed:
  94#       new file:   dir2/added
  95#
  96# Changes not staged for commit:
  97#       modified:   dir1/modified
  98#
  99# Untracked files:
 100#       dir1/untracked
 101#       dir2/modified
 102#       dir2/untracked
 103#       expect
 104#       output
 105#       untracked
 106EOF
 107
 108test_expect_success 'status (advice.statusHints false)' '
 109        test_when_finished "git config --unset advice.statusHints" &&
 110        git config advice.statusHints false &&
 111        git status >output &&
 112        test_i18ncmp expect output
 113
 114'
 115
 116cat >expect <<\EOF
 117 M dir1/modified
 118A  dir2/added
 119?? dir1/untracked
 120?? dir2/modified
 121?? dir2/untracked
 122?? expect
 123?? output
 124?? untracked
 125EOF
 126
 127test_expect_success 'status -s' '
 128
 129        git status -s >output &&
 130        test_cmp expect output
 131
 132'
 133
 134cat >expect <<\EOF
 135## master
 136 M dir1/modified
 137A  dir2/added
 138?? dir1/untracked
 139?? dir2/modified
 140?? dir2/untracked
 141?? expect
 142?? output
 143?? untracked
 144EOF
 145
 146test_expect_success 'status -s -b' '
 147
 148        git status -s -b >output &&
 149        test_cmp expect output
 150
 151'
 152
 153test_expect_success 'setup dir3' '
 154        mkdir dir3 &&
 155        : >dir3/untracked1 &&
 156        : >dir3/untracked2
 157'
 158
 159cat >expect <<EOF
 160# On branch master
 161# Changes to be committed:
 162#   (use "git reset HEAD <file>..." to unstage)
 163#
 164#       new file:   dir2/added
 165#
 166# Changes not staged for commit:
 167#   (use "git add <file>..." to update what will be committed)
 168#   (use "git checkout -- <file>..." to discard changes in working directory)
 169#
 170#       modified:   dir1/modified
 171#
 172# Untracked files not listed (use -u option to show untracked files)
 173EOF
 174test_expect_success 'status -uno' '
 175        git status -uno >output &&
 176        test_i18ncmp expect output
 177'
 178
 179test_expect_success 'status (status.showUntrackedFiles no)' '
 180        git config status.showuntrackedfiles no
 181        test_when_finished "git config --unset status.showuntrackedfiles" &&
 182        git status >output &&
 183        test_i18ncmp expect output
 184'
 185
 186cat >expect <<EOF
 187# On branch master
 188# Changes to be committed:
 189#       new file:   dir2/added
 190#
 191# Changes not staged for commit:
 192#       modified:   dir1/modified
 193#
 194# Untracked files not listed
 195EOF
 196git config advice.statusHints false
 197test_expect_success 'status -uno (advice.statusHints false)' '
 198        git status -uno >output &&
 199        test_i18ncmp expect output
 200'
 201git config --unset advice.statusHints
 202
 203cat >expect << EOF
 204 M dir1/modified
 205A  dir2/added
 206EOF
 207test_expect_success 'status -s -uno' '
 208        git status -s -uno >output &&
 209        test_cmp expect output
 210'
 211
 212test_expect_success 'status -s (status.showUntrackedFiles no)' '
 213        git config status.showuntrackedfiles no
 214        git status -s >output &&
 215        test_cmp expect output
 216'
 217
 218cat >expect <<EOF
 219# On branch master
 220# Changes to be committed:
 221#   (use "git reset HEAD <file>..." to unstage)
 222#
 223#       new file:   dir2/added
 224#
 225# Changes not staged for commit:
 226#   (use "git add <file>..." to update what will be committed)
 227#   (use "git checkout -- <file>..." to discard changes in working directory)
 228#
 229#       modified:   dir1/modified
 230#
 231# Untracked files:
 232#   (use "git add <file>..." to include in what will be committed)
 233#
 234#       dir1/untracked
 235#       dir2/modified
 236#       dir2/untracked
 237#       dir3/
 238#       expect
 239#       output
 240#       untracked
 241EOF
 242test_expect_success 'status -unormal' '
 243        git status -unormal >output &&
 244        test_i18ncmp expect output
 245'
 246
 247test_expect_success 'status (status.showUntrackedFiles normal)' '
 248        git config status.showuntrackedfiles normal
 249        test_when_finished "git config --unset status.showuntrackedfiles" &&
 250        git status >output &&
 251        test_i18ncmp expect output
 252'
 253
 254cat >expect <<EOF
 255 M dir1/modified
 256A  dir2/added
 257?? dir1/untracked
 258?? dir2/modified
 259?? dir2/untracked
 260?? dir3/
 261?? expect
 262?? output
 263?? untracked
 264EOF
 265test_expect_success 'status -s -unormal' '
 266        git status -s -unormal >output &&
 267        test_cmp expect output
 268'
 269
 270test_expect_success 'status -s (status.showUntrackedFiles normal)' '
 271        git config status.showuntrackedfiles normal
 272        git status -s >output &&
 273        test_cmp expect output
 274'
 275
 276cat >expect <<EOF
 277# On branch master
 278# Changes to be committed:
 279#   (use "git reset HEAD <file>..." to unstage)
 280#
 281#       new file:   dir2/added
 282#
 283# Changes not staged for commit:
 284#   (use "git add <file>..." to update what will be committed)
 285#   (use "git checkout -- <file>..." to discard changes in working directory)
 286#
 287#       modified:   dir1/modified
 288#
 289# Untracked files:
 290#   (use "git add <file>..." to include in what will be committed)
 291#
 292#       dir1/untracked
 293#       dir2/modified
 294#       dir2/untracked
 295#       dir3/untracked1
 296#       dir3/untracked2
 297#       expect
 298#       output
 299#       untracked
 300EOF
 301test_expect_success 'status -uall' '
 302        git status -uall >output &&
 303        test_i18ncmp expect output
 304'
 305
 306test_expect_success 'status (status.showUntrackedFiles all)' '
 307        git config status.showuntrackedfiles all
 308        test_when_finished "git config --unset status.showuntrackedfiles" &&
 309        git status >output &&
 310        test_i18ncmp expect output
 311'
 312
 313test_expect_success 'teardown dir3' '
 314        rm -rf dir3
 315'
 316
 317cat >expect <<EOF
 318 M dir1/modified
 319A  dir2/added
 320?? dir1/untracked
 321?? dir2/modified
 322?? dir2/untracked
 323?? expect
 324?? output
 325?? untracked
 326EOF
 327test_expect_success 'status -s -uall' '
 328        git config --unset status.showuntrackedfiles
 329        git status -s -uall >output &&
 330        test_cmp expect output
 331'
 332test_expect_success 'status -s (status.showUntrackedFiles all)' '
 333        git config status.showuntrackedfiles all
 334        git status -s >output &&
 335        rm -rf dir3 &&
 336        git config --unset status.showuntrackedfiles &&
 337        test_cmp expect output
 338'
 339
 340cat >expect <<\EOF
 341# On branch master
 342# Changes to be committed:
 343#   (use "git reset HEAD <file>..." to unstage)
 344#
 345#       new file:   ../dir2/added
 346#
 347# Changes not staged for commit:
 348#   (use "git add <file>..." to update what will be committed)
 349#   (use "git checkout -- <file>..." to discard changes in working directory)
 350#
 351#       modified:   modified
 352#
 353# Untracked files:
 354#   (use "git add <file>..." to include in what will be committed)
 355#
 356#       untracked
 357#       ../dir2/modified
 358#       ../dir2/untracked
 359#       ../expect
 360#       ../output
 361#       ../untracked
 362EOF
 363
 364test_expect_success 'status with relative paths' '
 365        (cd dir1 && git status) >output &&
 366        test_i18ncmp expect output
 367'
 368
 369cat >expect <<\EOF
 370 M modified
 371A  ../dir2/added
 372?? untracked
 373?? ../dir2/modified
 374?? ../dir2/untracked
 375?? ../expect
 376?? ../output
 377?? ../untracked
 378EOF
 379test_expect_success 'status -s with relative paths' '
 380
 381        (cd dir1 && git status -s) >output &&
 382        test_cmp expect output
 383
 384'
 385
 386cat >expect <<\EOF
 387 M dir1/modified
 388A  dir2/added
 389?? dir1/untracked
 390?? dir2/modified
 391?? dir2/untracked
 392?? expect
 393?? output
 394?? untracked
 395EOF
 396
 397test_expect_success 'status --porcelain ignores relative paths setting' '
 398
 399        (cd dir1 && git status --porcelain) >output &&
 400        test_cmp expect output
 401
 402'
 403
 404test_expect_success 'setup unique colors' '
 405
 406        git config status.color.untracked blue &&
 407        git config status.color.branch green
 408
 409'
 410
 411cat >expect <<\EOF
 412# On branch <GREEN>master<RESET>
 413# Changes to be committed:
 414#   (use "git reset HEAD <file>..." to unstage)
 415#
 416#       <GREEN>new file:   dir2/added<RESET>
 417#
 418# Changes not staged for commit:
 419#   (use "git add <file>..." to update what will be committed)
 420#   (use "git checkout -- <file>..." to discard changes in working directory)
 421#
 422#       <RED>modified:   dir1/modified<RESET>
 423#
 424# Untracked files:
 425#   (use "git add <file>..." to include in what will be committed)
 426#
 427#       <BLUE>dir1/untracked<RESET>
 428#       <BLUE>dir2/modified<RESET>
 429#       <BLUE>dir2/untracked<RESET>
 430#       <BLUE>expect<RESET>
 431#       <BLUE>output<RESET>
 432#       <BLUE>untracked<RESET>
 433EOF
 434
 435test_expect_success 'status with color.ui' '
 436        git config color.ui always &&
 437        test_when_finished "git config --unset color.ui" &&
 438        git status | test_decode_color >output &&
 439        test_i18ncmp expect output
 440'
 441
 442test_expect_success 'status with color.status' '
 443        git config color.status always &&
 444        test_when_finished "git config --unset color.status" &&
 445        git status | test_decode_color >output &&
 446        test_i18ncmp expect output
 447'
 448
 449cat >expect <<\EOF
 450 <RED>M<RESET> dir1/modified
 451<GREEN>A<RESET>  dir2/added
 452<BLUE>??<RESET> dir1/untracked
 453<BLUE>??<RESET> dir2/modified
 454<BLUE>??<RESET> dir2/untracked
 455<BLUE>??<RESET> expect
 456<BLUE>??<RESET> output
 457<BLUE>??<RESET> untracked
 458EOF
 459
 460test_expect_success 'status -s with color.ui' '
 461
 462        git config color.ui always &&
 463        git status -s | test_decode_color >output &&
 464        test_cmp expect output
 465
 466'
 467
 468test_expect_success 'status -s with color.status' '
 469
 470        git config --unset color.ui &&
 471        git config color.status always &&
 472        git status -s | test_decode_color >output &&
 473        test_cmp expect output
 474
 475'
 476
 477cat >expect <<\EOF
 478## <GREEN>master<RESET>
 479 <RED>M<RESET> dir1/modified
 480<GREEN>A<RESET>  dir2/added
 481<BLUE>??<RESET> dir1/untracked
 482<BLUE>??<RESET> dir2/modified
 483<BLUE>??<RESET> dir2/untracked
 484<BLUE>??<RESET> expect
 485<BLUE>??<RESET> output
 486<BLUE>??<RESET> untracked
 487EOF
 488
 489test_expect_success 'status -s -b with color.status' '
 490
 491        git status -s -b | test_decode_color >output &&
 492        test_cmp expect output
 493
 494'
 495
 496cat >expect <<\EOF
 497 M dir1/modified
 498A  dir2/added
 499?? dir1/untracked
 500?? dir2/modified
 501?? dir2/untracked
 502?? expect
 503?? output
 504?? untracked
 505EOF
 506
 507test_expect_success 'status --porcelain ignores color.ui' '
 508
 509        git config --unset color.status &&
 510        git config color.ui always &&
 511        git status --porcelain | test_decode_color >output &&
 512        test_cmp expect output
 513
 514'
 515
 516test_expect_success 'status --porcelain ignores color.status' '
 517
 518        git config --unset color.ui &&
 519        git config color.status always &&
 520        git status --porcelain | test_decode_color >output &&
 521        test_cmp expect output
 522
 523'
 524
 525# recover unconditionally from color tests
 526git config --unset color.status
 527git config --unset color.ui
 528
 529test_expect_success 'status --porcelain ignores -b' '
 530
 531        git status --porcelain -b >output &&
 532        test_cmp expect output
 533
 534'
 535
 536cat >expect <<\EOF
 537# On branch master
 538# Changes to be committed:
 539#   (use "git reset HEAD <file>..." to unstage)
 540#
 541#       new file:   dir2/added
 542#
 543# Changes not staged for commit:
 544#   (use "git add <file>..." to update what will be committed)
 545#   (use "git checkout -- <file>..." to discard changes in working directory)
 546#
 547#       modified:   dir1/modified
 548#
 549# Untracked files:
 550#   (use "git add <file>..." to include in what will be committed)
 551#
 552#       dir1/untracked
 553#       dir2/modified
 554#       dir2/untracked
 555#       expect
 556#       output
 557#       untracked
 558EOF
 559
 560
 561test_expect_success 'status without relative paths' '
 562
 563        git config status.relativePaths false &&
 564        test_when_finished "git config --unset status.relativePaths" &&
 565        (cd dir1 && git status) >output &&
 566        test_i18ncmp expect output
 567
 568'
 569
 570cat >expect <<\EOF
 571 M dir1/modified
 572A  dir2/added
 573?? dir1/untracked
 574?? dir2/modified
 575?? dir2/untracked
 576?? expect
 577?? output
 578?? untracked
 579EOF
 580
 581test_expect_success 'status -s without relative paths' '
 582
 583        git config status.relativePaths false &&
 584        test_when_finished "git config --unset status.relativePaths" &&
 585        (cd dir1 && git status -s) >output &&
 586        test_cmp expect output
 587
 588'
 589
 590cat <<EOF >expect
 591# On branch master
 592# Changes to be committed:
 593#   (use "git reset HEAD <file>..." to unstage)
 594#
 595#       modified:   dir1/modified
 596#
 597# Untracked files:
 598#   (use "git add <file>..." to include in what will be committed)
 599#
 600#       dir1/untracked
 601#       dir2/
 602#       expect
 603#       output
 604#       untracked
 605EOF
 606test_expect_success 'dry-run of partial commit excluding new file in index' '
 607        git commit --dry-run dir1/modified >output &&
 608        test_i18ncmp expect output
 609'
 610
 611cat >expect <<EOF
 612:100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M      dir1/modified
 613EOF
 614test_expect_success 'status refreshes the index' '
 615        touch dir2/added &&
 616        git status &&
 617        git diff-files >output &&
 618        test_cmp expect output
 619'
 620
 621test_expect_success 'setup status submodule summary' '
 622        test_create_repo sm && (
 623                cd sm &&
 624                >foo &&
 625                git add foo &&
 626                git commit -m "Add foo"
 627        ) &&
 628        git add sm
 629'
 630
 631cat >expect <<EOF
 632# On branch master
 633# Changes to be committed:
 634#   (use "git reset HEAD <file>..." to unstage)
 635#
 636#       new file:   dir2/added
 637#       new file:   sm
 638#
 639# Changes not staged for commit:
 640#   (use "git add <file>..." to update what will be committed)
 641#   (use "git checkout -- <file>..." to discard changes in working directory)
 642#
 643#       modified:   dir1/modified
 644#
 645# Untracked files:
 646#   (use "git add <file>..." to include in what will be committed)
 647#
 648#       dir1/untracked
 649#       dir2/modified
 650#       dir2/untracked
 651#       expect
 652#       output
 653#       untracked
 654EOF
 655test_expect_success 'status submodule summary is disabled by default' '
 656        git status >output &&
 657        test_i18ncmp expect output
 658'
 659
 660# we expect the same as the previous test
 661test_expect_success 'status --untracked-files=all does not show submodule' '
 662        git status --untracked-files=all >output &&
 663        test_i18ncmp expect output
 664'
 665
 666cat >expect <<EOF
 667 M dir1/modified
 668A  dir2/added
 669A  sm
 670?? dir1/untracked
 671?? dir2/modified
 672?? dir2/untracked
 673?? expect
 674?? output
 675?? untracked
 676EOF
 677test_expect_success 'status -s submodule summary is disabled by default' '
 678        git status -s >output &&
 679        test_cmp expect output
 680'
 681
 682# we expect the same as the previous test
 683test_expect_success 'status -s --untracked-files=all does not show submodule' '
 684        git status -s --untracked-files=all >output &&
 685        test_cmp expect output
 686'
 687
 688head=$(cd sm && git rev-parse --short=7 --verify HEAD)
 689
 690cat >expect <<EOF
 691# On branch master
 692# Changes to be committed:
 693#   (use "git reset HEAD <file>..." to unstage)
 694#
 695#       new file:   dir2/added
 696#       new file:   sm
 697#
 698# Changes not staged for commit:
 699#   (use "git add <file>..." to update what will be committed)
 700#   (use "git checkout -- <file>..." to discard changes in working directory)
 701#
 702#       modified:   dir1/modified
 703#
 704# Submodule changes to be committed:
 705#
 706# * sm 0000000...$head (1):
 707#   > Add foo
 708#
 709# Untracked files:
 710#   (use "git add <file>..." to include in what will be committed)
 711#
 712#       dir1/untracked
 713#       dir2/modified
 714#       dir2/untracked
 715#       expect
 716#       output
 717#       untracked
 718EOF
 719test_expect_success 'status submodule summary' '
 720        git config status.submodulesummary 10 &&
 721        git status >output &&
 722        test_i18ncmp expect output
 723'
 724
 725cat >expect <<EOF
 726 M dir1/modified
 727A  dir2/added
 728A  sm
 729?? dir1/untracked
 730?? dir2/modified
 731?? dir2/untracked
 732?? expect
 733?? output
 734?? untracked
 735EOF
 736test_expect_success 'status -s submodule summary' '
 737        git status -s >output &&
 738        test_cmp expect output
 739'
 740
 741cat >expect <<EOF
 742# On branch master
 743# Changes not staged for commit:
 744#   (use "git add <file>..." to update what will be committed)
 745#   (use "git checkout -- <file>..." to discard changes in working directory)
 746#
 747#       modified:   dir1/modified
 748#
 749# Untracked files:
 750#   (use "git add <file>..." to include in what will be committed)
 751#
 752#       dir1/untracked
 753#       dir2/modified
 754#       dir2/untracked
 755#       expect
 756#       output
 757#       untracked
 758no changes added to commit (use "git add" and/or "git commit -a")
 759EOF
 760test_expect_success 'status submodule summary (clean submodule): commit' '
 761        git commit -m "commit submodule" &&
 762        git config status.submodulesummary 10 &&
 763        test_must_fail git commit --dry-run >output &&
 764        test_i18ncmp expect output &&
 765        git status >output &&
 766        test_i18ncmp expect output
 767'
 768
 769cat >expect <<EOF
 770 M dir1/modified
 771?? dir1/untracked
 772?? dir2/modified
 773?? dir2/untracked
 774?? expect
 775?? output
 776?? untracked
 777EOF
 778test_expect_success 'status -s submodule summary (clean submodule)' '
 779        git status -s >output &&
 780        test_cmp expect output
 781'
 782
 783cat >expect <<EOF
 784# On branch master
 785# Changes to be committed:
 786#   (use "git reset HEAD^1 <file>..." to unstage)
 787#
 788#       new file:   dir2/added
 789#       new file:   sm
 790#
 791# Changes not staged for commit:
 792#   (use "git add <file>..." to update what will be committed)
 793#   (use "git checkout -- <file>..." to discard changes in working directory)
 794#
 795#       modified:   dir1/modified
 796#
 797# Submodule changes to be committed:
 798#
 799# * sm 0000000...$head (1):
 800#   > Add foo
 801#
 802# Untracked files:
 803#   (use "git add <file>..." to include in what will be committed)
 804#
 805#       dir1/untracked
 806#       dir2/modified
 807#       dir2/untracked
 808#       expect
 809#       output
 810#       untracked
 811EOF
 812test_expect_success 'commit --dry-run submodule summary (--amend)' '
 813        git config status.submodulesummary 10 &&
 814        git commit --dry-run --amend >output &&
 815        test_i18ncmp expect output
 816'
 817
 818test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
 819        (
 820                chmod a-w .git &&
 821                # make dir1/tracked stat-dirty
 822                >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
 823                git status -s >output &&
 824                ! grep dir1/tracked output &&
 825                # make sure "status" succeeded without writing index out
 826                git diff-files | grep dir1/tracked
 827        )
 828        status=$?
 829        chmod 775 .git
 830        (exit $status)
 831'
 832
 833(cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
 834new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
 835touch .gitmodules
 836
 837cat > expect << EOF
 838# On branch master
 839# Changes to be committed:
 840#   (use "git reset HEAD <file>..." to unstage)
 841#
 842#       modified:   sm
 843#
 844# Changes not staged for commit:
 845#   (use "git add <file>..." to update what will be committed)
 846#   (use "git checkout -- <file>..." to discard changes in working directory)
 847#
 848#       modified:   dir1/modified
 849#
 850# Submodule changes to be committed:
 851#
 852# * sm $head...$new_head (1):
 853#   > Add bar
 854#
 855# Untracked files:
 856#   (use "git add <file>..." to include in what will be committed)
 857#
 858#       .gitmodules
 859#       dir1/untracked
 860#       dir2/modified
 861#       dir2/untracked
 862#       expect
 863#       output
 864#       untracked
 865EOF
 866
 867test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
 868        echo modified  sm/untracked &&
 869        git status --ignore-submodules=untracked >output &&
 870        test_i18ncmp expect output
 871'
 872
 873test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
 874        git config diff.ignoreSubmodules dirty &&
 875        git status >output &&
 876        test_i18ncmp expect output &&
 877        git config --add -f .gitmodules submodule.subname.ignore untracked &&
 878        git config --add -f .gitmodules submodule.subname.path sm &&
 879        git status >output &&
 880        test_i18ncmp expect output &&
 881        git config -f .gitmodules  --remove-section submodule.subname &&
 882        git config --unset diff.ignoreSubmodules
 883'
 884
 885test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
 886        git config --add -f .gitmodules submodule.subname.ignore none &&
 887        git config --add -f .gitmodules submodule.subname.path sm &&
 888        git config --add submodule.subname.ignore untracked &&
 889        git config --add submodule.subname.path sm &&
 890        git status >output &&
 891        test_i18ncmp expect output &&
 892        git config --remove-section submodule.subname &&
 893        git config --remove-section -f .gitmodules submodule.subname
 894'
 895
 896test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
 897        git status --ignore-submodules=dirty >output &&
 898        test_i18ncmp expect output
 899'
 900
 901test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
 902        git config diff.ignoreSubmodules dirty &&
 903        git status >output &&
 904        ! test -s actual &&
 905        git config --add -f .gitmodules submodule.subname.ignore dirty &&
 906        git config --add -f .gitmodules submodule.subname.path sm &&
 907        git status >output &&
 908        test_i18ncmp expect output &&
 909        git config -f .gitmodules  --remove-section submodule.subname &&
 910        git config --unset diff.ignoreSubmodules
 911'
 912
 913test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
 914        git config --add -f .gitmodules submodule.subname.ignore none &&
 915        git config --add -f .gitmodules submodule.subname.path sm &&
 916        git config --add submodule.subname.ignore dirty &&
 917        git config --add submodule.subname.path sm &&
 918        git status >output &&
 919        test_i18ncmp expect output &&
 920        git config --remove-section submodule.subname &&
 921        git config -f .gitmodules  --remove-section submodule.subname
 922'
 923
 924test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
 925        echo modified >sm/foo &&
 926        git status --ignore-submodules=dirty >output &&
 927        test_i18ncmp expect output
 928'
 929
 930test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
 931        git config --add -f .gitmodules submodule.subname.ignore dirty &&
 932        git config --add -f .gitmodules submodule.subname.path sm &&
 933        git status >output &&
 934        test_i18ncmp expect output &&
 935        git config -f .gitmodules  --remove-section submodule.subname
 936'
 937
 938test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
 939        git config --add -f .gitmodules submodule.subname.ignore none &&
 940        git config --add -f .gitmodules submodule.subname.path sm &&
 941        git config --add submodule.subname.ignore dirty &&
 942        git config --add submodule.subname.path sm &&
 943        git status >output &&
 944        test_i18ncmp expect output &&
 945        git config --remove-section submodule.subname &&
 946        git config -f .gitmodules  --remove-section submodule.subname
 947'
 948
 949cat > expect << EOF
 950# On branch master
 951# Changes to be committed:
 952#   (use "git reset HEAD <file>..." to unstage)
 953#
 954#       modified:   sm
 955#
 956# Changes not staged for commit:
 957#   (use "git add <file>..." to update what will be committed)
 958#   (use "git checkout -- <file>..." to discard changes in working directory)
 959#   (commit or discard the untracked or modified content in submodules)
 960#
 961#       modified:   dir1/modified
 962#       modified:   sm (modified content)
 963#
 964# Submodule changes to be committed:
 965#
 966# * sm $head...$new_head (1):
 967#   > Add bar
 968#
 969# Untracked files:
 970#   (use "git add <file>..." to include in what will be committed)
 971#
 972#       .gitmodules
 973#       dir1/untracked
 974#       dir2/modified
 975#       dir2/untracked
 976#       expect
 977#       output
 978#       untracked
 979EOF
 980
 981test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
 982        git status --ignore-submodules=untracked > output &&
 983        test_i18ncmp expect output
 984'
 985
 986test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
 987        git config --add -f .gitmodules submodule.subname.ignore untracked &&
 988        git config --add -f .gitmodules submodule.subname.path sm &&
 989        git status >output &&
 990        test_i18ncmp expect output &&
 991        git config -f .gitmodules  --remove-section submodule.subname
 992'
 993
 994test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
 995        git config --add -f .gitmodules submodule.subname.ignore none &&
 996        git config --add -f .gitmodules submodule.subname.path sm &&
 997        git config --add submodule.subname.ignore untracked &&
 998        git config --add submodule.subname.path sm &&
 999        git status >output &&
1000        test_i18ncmp expect output &&
1001        git config --remove-section submodule.subname &&
1002        git config -f .gitmodules  --remove-section submodule.subname
1003'
1004
1005head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1006
1007cat > expect << EOF
1008# On branch master
1009# Changes to be committed:
1010#   (use "git reset HEAD <file>..." to unstage)
1011#
1012#       modified:   sm
1013#
1014# Changes not staged for commit:
1015#   (use "git add <file>..." to update what will be committed)
1016#   (use "git checkout -- <file>..." to discard changes in working directory)
1017#
1018#       modified:   dir1/modified
1019#       modified:   sm (new commits)
1020#
1021# Submodule changes to be committed:
1022#
1023# * sm $head...$new_head (1):
1024#   > Add bar
1025#
1026# Submodules changed but not updated:
1027#
1028# * sm $new_head...$head2 (1):
1029#   > 2nd commit
1030#
1031# Untracked files:
1032#   (use "git add <file>..." to include in what will be committed)
1033#
1034#       .gitmodules
1035#       dir1/untracked
1036#       dir2/modified
1037#       dir2/untracked
1038#       expect
1039#       output
1040#       untracked
1041EOF
1042
1043test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1044        git status --ignore-submodules=untracked > output &&
1045        test_i18ncmp expect output
1046'
1047
1048test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1049        git config --add -f .gitmodules submodule.subname.ignore untracked &&
1050        git config --add -f .gitmodules submodule.subname.path sm &&
1051        git status >output &&
1052        test_i18ncmp expect output &&
1053        git config -f .gitmodules  --remove-section submodule.subname
1054'
1055
1056test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1057        git config --add -f .gitmodules submodule.subname.ignore none &&
1058        git config --add -f .gitmodules submodule.subname.path sm &&
1059        git config --add submodule.subname.ignore untracked &&
1060        git config --add submodule.subname.path sm &&
1061        git status >output &&
1062        test_i18ncmp expect output &&
1063        git config --remove-section submodule.subname &&
1064        git config -f .gitmodules  --remove-section submodule.subname
1065'
1066
1067test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1068        git status --ignore-submodules=dirty > output &&
1069        test_i18ncmp expect output
1070'
1071test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1072        git config --add -f .gitmodules submodule.subname.ignore dirty &&
1073        git config --add -f .gitmodules submodule.subname.path sm &&
1074        git status >output &&
1075        test_i18ncmp expect output &&
1076        git config -f .gitmodules  --remove-section submodule.subname
1077'
1078
1079test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1080        git config --add -f .gitmodules submodule.subname.ignore none &&
1081        git config --add -f .gitmodules submodule.subname.path sm &&
1082        git config --add submodule.subname.ignore dirty &&
1083        git config --add submodule.subname.path sm &&
1084        git status >output &&
1085        test_i18ncmp expect output &&
1086        git config --remove-section submodule.subname &&
1087        git config -f .gitmodules  --remove-section submodule.subname
1088'
1089
1090cat > expect << EOF
1091# On branch master
1092# Changes not staged for commit:
1093#   (use "git add <file>..." to update what will be committed)
1094#   (use "git checkout -- <file>..." to discard changes in working directory)
1095#
1096#       modified:   dir1/modified
1097#
1098# Untracked files:
1099#   (use "git add <file>..." to include in what will be committed)
1100#
1101#       .gitmodules
1102#       dir1/untracked
1103#       dir2/modified
1104#       dir2/untracked
1105#       expect
1106#       output
1107#       untracked
1108no changes added to commit (use "git add" and/or "git commit -a")
1109EOF
1110
1111test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1112        git status --ignore-submodules=all > output &&
1113        test_i18ncmp expect output
1114'
1115
1116test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1117        git config --add -f .gitmodules submodule.subname.ignore all &&
1118        git config --add -f .gitmodules submodule.subname.path sm &&
1119        git status > output &&
1120        test_cmp expect output &&
1121        git config -f .gitmodules  --remove-section submodule.subname
1122'
1123
1124test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1125        git config --add -f .gitmodules submodule.subname.ignore none &&
1126        git config --add -f .gitmodules submodule.subname.path sm &&
1127        git config --add submodule.subname.ignore all &&
1128        git config --add submodule.subname.path sm &&
1129        git status > output &&
1130        test_cmp expect output &&
1131        git config --remove-section submodule.subname &&
1132        git config -f .gitmodules  --remove-section submodule.subname
1133'
1134
1135test_done