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