t / t7406-submodule-update.shon commit submodule update --init: correct path handling in recursive submodules (c1ab00f)
   1#!/bin/sh
   2#
   3# Copyright (c) 2009 Red Hat, Inc.
   4#
   5
   6test_description='Test updating submodules
   7
   8This test verifies that "git submodule update" detaches the HEAD of the
   9submodule and "git submodule update --rebase/--merge" does not detach the HEAD.
  10'
  11
  12. ./test-lib.sh
  13
  14
  15compare_head()
  16{
  17    sha_master=$(git rev-list --max-count=1 master)
  18    sha_head=$(git rev-list --max-count=1 HEAD)
  19
  20    test "$sha_master" = "$sha_head"
  21}
  22
  23
  24test_expect_success 'setup a submodule tree' '
  25        echo file > file &&
  26        git add file &&
  27        test_tick &&
  28        git commit -m upstream &&
  29        git clone . super &&
  30        git clone super submodule &&
  31        git clone super rebasing &&
  32        git clone super merging &&
  33        git clone super none &&
  34        (cd super &&
  35         git submodule add ../submodule submodule &&
  36         test_tick &&
  37         git commit -m "submodule" &&
  38         git submodule init submodule
  39        ) &&
  40        (cd submodule &&
  41        echo "line2" > file &&
  42        git add file &&
  43        git commit -m "Commit 2"
  44        ) &&
  45        (cd super &&
  46         (cd submodule &&
  47          git pull --rebase origin
  48         ) &&
  49         git add submodule &&
  50         git commit -m "submodule update"
  51        ) &&
  52        (cd super &&
  53         git submodule add ../rebasing rebasing &&
  54         test_tick &&
  55         git commit -m "rebasing"
  56        ) &&
  57        (cd super &&
  58         git submodule add ../merging merging &&
  59         test_tick &&
  60         git commit -m "rebasing"
  61        ) &&
  62        (cd super &&
  63         git submodule add ../none none &&
  64         test_tick &&
  65         git commit -m "none"
  66        ) &&
  67        git clone . recursivesuper &&
  68        ( cd recursivesuper
  69         git submodule add ../super super
  70        )
  71'
  72
  73test_expect_success 'submodule update detaching the HEAD ' '
  74        (cd super/submodule &&
  75         git reset --hard HEAD~1
  76        ) &&
  77        (cd super &&
  78         (cd submodule &&
  79          compare_head
  80         ) &&
  81         git submodule update submodule &&
  82         cd submodule &&
  83         ! compare_head
  84        )
  85'
  86
  87test_expect_success 'submodule update from subdirectory' '
  88        (cd super/submodule &&
  89         git reset --hard HEAD~1
  90        ) &&
  91        mkdir super/sub &&
  92        (cd super/sub &&
  93         (cd ../submodule &&
  94          compare_head
  95         ) &&
  96         git submodule update ../submodule &&
  97         cd ../submodule &&
  98         ! compare_head
  99        )
 100'
 101
 102supersha1=$(git -C super rev-parse HEAD)
 103mergingsha1=$(git -C super/merging rev-parse HEAD)
 104nonesha1=$(git -C super/none rev-parse HEAD)
 105rebasingsha1=$(git -C super/rebasing rev-parse HEAD)
 106submodulesha1=$(git -C super/submodule rev-parse HEAD)
 107pwd=$(pwd)
 108
 109cat <<EOF >expect
 110Submodule path '../super': checked out '$supersha1'
 111Submodule 'merging' ($pwd/merging) registered for path '../super/merging'
 112Submodule 'none' ($pwd/none) registered for path '../super/none'
 113Submodule 'rebasing' ($pwd/rebasing) registered for path '../super/rebasing'
 114Submodule 'submodule' ($pwd/submodule) registered for path '../super/submodule'
 115Submodule path '../super/merging': checked out '$mergingsha1'
 116Submodule path '../super/none': checked out '$nonesha1'
 117Submodule path '../super/rebasing': checked out '$rebasingsha1'
 118Submodule path '../super/submodule': checked out '$submodulesha1'
 119EOF
 120
 121test_expect_success 'submodule update --init --recursive from subdirectory' '
 122        git -C recursivesuper/super reset --hard HEAD^ &&
 123        (cd recursivesuper &&
 124         mkdir tmp &&
 125         cd tmp &&
 126         git submodule update --init --recursive ../super >../../actual
 127        ) &&
 128        test_cmp expect actual
 129'
 130
 131apos="'";
 132test_expect_success 'submodule update does not fetch already present commits' '
 133        (cd submodule &&
 134          echo line3 >> file &&
 135          git add file &&
 136          test_tick &&
 137          git commit -m "upstream line3"
 138        ) &&
 139        (cd super/submodule &&
 140          head=$(git rev-parse --verify HEAD) &&
 141          echo "Submodule path ${apos}submodule$apos: checked out $apos$head$apos" > ../../expected &&
 142          git reset --hard HEAD~1
 143        ) &&
 144        (cd super &&
 145          git submodule update > ../actual 2> ../actual.err
 146        ) &&
 147        test_i18ncmp expected actual &&
 148        ! test -s actual.err
 149'
 150
 151test_expect_success 'submodule update should fail due to local changes' '
 152        (cd super/submodule &&
 153         git reset --hard HEAD~1 &&
 154         echo "local change" > file
 155        ) &&
 156        (cd super &&
 157         (cd submodule &&
 158          compare_head
 159         ) &&
 160         test_must_fail git submodule update submodule
 161        )
 162'
 163test_expect_success 'submodule update should throw away changes with --force ' '
 164        (cd super &&
 165         (cd submodule &&
 166          compare_head
 167         ) &&
 168         git submodule update --force submodule &&
 169         cd submodule &&
 170         ! compare_head
 171        )
 172'
 173
 174test_expect_success 'submodule update --force forcibly checks out submodules' '
 175        (cd super &&
 176         (cd submodule &&
 177          rm -f file
 178         ) &&
 179         git submodule update --force submodule &&
 180         (cd submodule &&
 181          test "$(git status -s file)" = ""
 182         )
 183        )
 184'
 185
 186test_expect_success 'submodule update --remote should fetch upstream changes' '
 187        (cd submodule &&
 188         echo line4 >> file &&
 189         git add file &&
 190         test_tick &&
 191         git commit -m "upstream line4"
 192        ) &&
 193        (cd super &&
 194         git submodule update --remote --force submodule &&
 195         cd submodule &&
 196         test "$(git log -1 --oneline)" = "$(GIT_DIR=../../submodule/.git git log -1 --oneline)"
 197        )
 198'
 199
 200test_expect_success 'local config should override .gitmodules branch' '
 201        (cd submodule &&
 202         git checkout -b test-branch &&
 203         echo line5 >> file &&
 204         git add file &&
 205         test_tick &&
 206         git commit -m "upstream line5" &&
 207         git checkout master
 208        ) &&
 209        (cd super &&
 210         git config submodule.submodule.branch test-branch &&
 211         git submodule update --remote --force submodule &&
 212         cd submodule &&
 213         test "$(git log -1 --oneline)" = "$(GIT_DIR=../../submodule/.git git log -1 --oneline test-branch)"
 214        )
 215'
 216
 217test_expect_success 'submodule update --rebase staying on master' '
 218        (cd super/submodule &&
 219          git checkout master
 220        ) &&
 221        (cd super &&
 222         (cd submodule &&
 223          compare_head
 224         ) &&
 225         git submodule update --rebase submodule &&
 226         cd submodule &&
 227         compare_head
 228        )
 229'
 230
 231test_expect_success 'submodule update --merge staying on master' '
 232        (cd super/submodule &&
 233          git reset --hard HEAD~1
 234        ) &&
 235        (cd super &&
 236         (cd submodule &&
 237          compare_head
 238         ) &&
 239         git submodule update --merge submodule &&
 240         cd submodule &&
 241         compare_head
 242        )
 243'
 244
 245test_expect_success 'submodule update - rebase in .git/config' '
 246        (cd super &&
 247         git config submodule.submodule.update rebase
 248        ) &&
 249        (cd super/submodule &&
 250          git reset --hard HEAD~1
 251        ) &&
 252        (cd super &&
 253         (cd submodule &&
 254          compare_head
 255         ) &&
 256         git submodule update submodule &&
 257         cd submodule &&
 258         compare_head
 259        )
 260'
 261
 262test_expect_success 'submodule update - checkout in .git/config but --rebase given' '
 263        (cd super &&
 264         git config submodule.submodule.update checkout
 265        ) &&
 266        (cd super/submodule &&
 267          git reset --hard HEAD~1
 268        ) &&
 269        (cd super &&
 270         (cd submodule &&
 271          compare_head
 272         ) &&
 273         git submodule update --rebase submodule &&
 274         cd submodule &&
 275         compare_head
 276        )
 277'
 278
 279test_expect_success 'submodule update - merge in .git/config' '
 280        (cd super &&
 281         git config submodule.submodule.update merge
 282        ) &&
 283        (cd super/submodule &&
 284          git reset --hard HEAD~1
 285        ) &&
 286        (cd super &&
 287         (cd submodule &&
 288          compare_head
 289         ) &&
 290         git submodule update submodule &&
 291         cd submodule &&
 292         compare_head
 293        )
 294'
 295
 296test_expect_success 'submodule update - checkout in .git/config but --merge given' '
 297        (cd super &&
 298         git config submodule.submodule.update checkout
 299        ) &&
 300        (cd super/submodule &&
 301          git reset --hard HEAD~1
 302        ) &&
 303        (cd super &&
 304         (cd submodule &&
 305          compare_head
 306         ) &&
 307         git submodule update --merge submodule &&
 308         cd submodule &&
 309         compare_head
 310        )
 311'
 312
 313test_expect_success 'submodule update - checkout in .git/config' '
 314        (cd super &&
 315         git config submodule.submodule.update checkout
 316        ) &&
 317        (cd super/submodule &&
 318          git reset --hard HEAD^
 319        ) &&
 320        (cd super &&
 321         (cd submodule &&
 322          compare_head
 323         ) &&
 324         git submodule update submodule &&
 325         cd submodule &&
 326         ! compare_head
 327        )
 328'
 329
 330test_expect_success 'submodule update - command in .git/config' '
 331        (cd super &&
 332         git config submodule.submodule.update "!git checkout"
 333        ) &&
 334        (cd super/submodule &&
 335          git reset --hard HEAD^
 336        ) &&
 337        (cd super &&
 338         (cd submodule &&
 339          compare_head
 340         ) &&
 341         git submodule update submodule &&
 342         cd submodule &&
 343         ! compare_head
 344        )
 345'
 346
 347test_expect_success 'submodule update - command in .git/config catches failure' '
 348        (cd super &&
 349         git config submodule.submodule.update "!false"
 350        ) &&
 351        (cd super/submodule &&
 352          git reset --hard HEAD^
 353        ) &&
 354        (cd super &&
 355         test_must_fail git submodule update submodule
 356        )
 357'
 358
 359test_expect_success 'submodule init does not copy command into .git/config' '
 360        (cd super &&
 361         H=$(git ls-files -s submodule | cut -d" " -f2) &&
 362         mkdir submodule1 &&
 363         git update-index --add --cacheinfo 160000 $H submodule1 &&
 364         git config -f .gitmodules submodule.submodule1.path submodule1 &&
 365         git config -f .gitmodules submodule.submodule1.url ../submodule &&
 366         git config -f .gitmodules submodule.submodule1.update !false &&
 367         git submodule init submodule1 &&
 368         echo "none" >expect &&
 369         git config submodule.submodule1.update >actual &&
 370         test_cmp expect actual
 371        )
 372'
 373
 374test_expect_success 'submodule init picks up rebase' '
 375        (cd super &&
 376         git config -f .gitmodules submodule.rebasing.update rebase &&
 377         git submodule init rebasing &&
 378         test "rebase" = "$(git config submodule.rebasing.update)"
 379        )
 380'
 381
 382test_expect_success 'submodule init picks up merge' '
 383        (cd super &&
 384         git config -f .gitmodules submodule.merging.update merge &&
 385         git submodule init merging &&
 386         test "merge" = "$(git config submodule.merging.update)"
 387        )
 388'
 389
 390test_expect_success 'submodule update --merge  - ignores --merge  for new submodules' '
 391        (cd super &&
 392         rm -rf submodule &&
 393         git submodule update submodule &&
 394         git status -s submodule >expect &&
 395         rm -rf submodule &&
 396         git submodule update --merge submodule &&
 397         git status -s submodule >actual &&
 398         test_cmp expect actual
 399        )
 400'
 401
 402test_expect_success 'submodule update --rebase - ignores --rebase for new submodules' '
 403        (cd super &&
 404         rm -rf submodule &&
 405         git submodule update submodule &&
 406         git status -s submodule >expect &&
 407         rm -rf submodule &&
 408         git submodule update --rebase submodule &&
 409         git status -s submodule >actual &&
 410         test_cmp expect actual
 411        )
 412'
 413
 414test_expect_success 'submodule update ignores update=merge config for new submodules' '
 415        (cd super &&
 416         rm -rf submodule &&
 417         git submodule update submodule &&
 418         git status -s submodule >expect &&
 419         rm -rf submodule &&
 420         git config submodule.submodule.update merge &&
 421         git submodule update submodule &&
 422         git status -s submodule >actual &&
 423         git config --unset submodule.submodule.update &&
 424         test_cmp expect actual
 425        )
 426'
 427
 428test_expect_success 'submodule update ignores update=rebase config for new submodules' '
 429        (cd super &&
 430         rm -rf submodule &&
 431         git submodule update submodule &&
 432         git status -s submodule >expect &&
 433         rm -rf submodule &&
 434         git config submodule.submodule.update rebase &&
 435         git submodule update submodule &&
 436         git status -s submodule >actual &&
 437         git config --unset submodule.submodule.update &&
 438         test_cmp expect actual
 439        )
 440'
 441
 442test_expect_success 'submodule init picks up update=none' '
 443        (cd super &&
 444         git config -f .gitmodules submodule.none.update none &&
 445         git submodule init none &&
 446         test "none" = "$(git config submodule.none.update)"
 447        )
 448'
 449
 450test_expect_success 'submodule update - update=none in .git/config' '
 451        (cd super &&
 452         git config submodule.submodule.update none &&
 453         (cd submodule &&
 454          git checkout master &&
 455          compare_head
 456         ) &&
 457         git diff --raw | grep "        submodule" &&
 458         git submodule update &&
 459         git diff --raw | grep "        submodule" &&
 460         (cd submodule &&
 461          compare_head
 462         ) &&
 463         git config --unset submodule.submodule.update &&
 464         git submodule update submodule
 465        )
 466'
 467
 468test_expect_success 'submodule update - update=none in .git/config but --checkout given' '
 469        (cd super &&
 470         git config submodule.submodule.update none &&
 471         (cd submodule &&
 472          git checkout master &&
 473          compare_head
 474         ) &&
 475         git diff --raw | grep "        submodule" &&
 476         git submodule update --checkout &&
 477         test_must_fail git diff --raw \| grep "        submodule" &&
 478         (cd submodule &&
 479          test_must_fail compare_head
 480         ) &&
 481         git config --unset submodule.submodule.update
 482        )
 483'
 484
 485test_expect_success 'submodule update --init skips submodule with update=none' '
 486        (cd super &&
 487         git add .gitmodules &&
 488         git commit -m ".gitmodules"
 489        ) &&
 490        git clone super cloned &&
 491        (cd cloned &&
 492         git submodule update --init &&
 493         test -e submodule/.git &&
 494         test_must_fail test -e none/.git
 495        )
 496'
 497
 498test_expect_success 'submodule update continues after checkout error' '
 499        (cd super &&
 500         git reset --hard HEAD &&
 501         git submodule add ../submodule submodule2 &&
 502         git submodule init &&
 503         git commit -am "new_submodule" &&
 504         (cd submodule2 &&
 505          git rev-parse --verify HEAD >../expect
 506         ) &&
 507         (cd submodule &&
 508          test_commit "update_submodule" file
 509         ) &&
 510         (cd submodule2 &&
 511          test_commit "update_submodule2" file
 512         ) &&
 513         git add submodule &&
 514         git add submodule2 &&
 515         git commit -m "two_new_submodule_commits" &&
 516         (cd submodule &&
 517          echo "" > file
 518         ) &&
 519         git checkout HEAD^ &&
 520         test_must_fail git submodule update &&
 521         (cd submodule2 &&
 522          git rev-parse --verify HEAD >../actual
 523         ) &&
 524         test_cmp expect actual
 525        )
 526'
 527test_expect_success 'submodule update continues after recursive checkout error' '
 528        (cd super &&
 529         git reset --hard HEAD &&
 530         git checkout master &&
 531         git submodule update &&
 532         (cd submodule &&
 533          git submodule add ../submodule subsubmodule &&
 534          git submodule init &&
 535          git commit -m "new_subsubmodule"
 536         ) &&
 537         git add submodule &&
 538         git commit -m "update_submodule" &&
 539         (cd submodule &&
 540          (cd subsubmodule &&
 541           test_commit "update_subsubmodule" file
 542          ) &&
 543          git add subsubmodule &&
 544          test_commit "update_submodule_again" file &&
 545          (cd subsubmodule &&
 546           test_commit "update_subsubmodule_again" file
 547          ) &&
 548          test_commit "update_submodule_again_again" file
 549         ) &&
 550         (cd submodule2 &&
 551          git rev-parse --verify HEAD >../expect &&
 552          test_commit "update_submodule2_again" file
 553         ) &&
 554         git add submodule &&
 555         git add submodule2 &&
 556         git commit -m "new_commits" &&
 557         git checkout HEAD^ &&
 558         (cd submodule &&
 559          git checkout HEAD^ &&
 560          (cd subsubmodule &&
 561           echo "" > file
 562          )
 563         ) &&
 564         test_must_fail git submodule update --recursive &&
 565         (cd submodule2 &&
 566          git rev-parse --verify HEAD >../actual
 567         ) &&
 568         test_cmp expect actual
 569        )
 570'
 571
 572test_expect_success 'submodule update exit immediately in case of merge conflict' '
 573        (cd super &&
 574         git checkout master &&
 575         git reset --hard HEAD &&
 576         (cd submodule &&
 577          (cd subsubmodule &&
 578           git reset --hard HEAD
 579          )
 580         ) &&
 581         git submodule update --recursive &&
 582         (cd submodule &&
 583          test_commit "update_submodule_2" file
 584         ) &&
 585         (cd submodule2 &&
 586          test_commit "update_submodule2_2" file
 587         ) &&
 588         git add submodule &&
 589         git add submodule2 &&
 590         git commit -m "two_new_submodule_commits" &&
 591         (cd submodule &&
 592          git checkout master &&
 593          test_commit "conflict" file &&
 594          echo "conflict" > file
 595         ) &&
 596         git checkout HEAD^ &&
 597         (cd submodule2 &&
 598          git rev-parse --verify HEAD >../expect
 599         ) &&
 600         git config submodule.submodule.update merge &&
 601         test_must_fail git submodule update &&
 602         (cd submodule2 &&
 603          git rev-parse --verify HEAD >../actual
 604         ) &&
 605         test_cmp expect actual
 606        )
 607'
 608
 609test_expect_success 'submodule update exit immediately after recursive rebase error' '
 610        (cd super &&
 611         git checkout master &&
 612         git reset --hard HEAD &&
 613         (cd submodule &&
 614          git reset --hard HEAD &&
 615          git submodule update --recursive
 616         ) &&
 617         (cd submodule &&
 618          test_commit "update_submodule_3" file
 619         ) &&
 620         (cd submodule2 &&
 621          test_commit "update_submodule2_3" file
 622         ) &&
 623         git add submodule &&
 624         git add submodule2 &&
 625         git commit -m "two_new_submodule_commits" &&
 626         (cd submodule &&
 627          git checkout master &&
 628          test_commit "conflict2" file &&
 629          echo "conflict" > file
 630         ) &&
 631         git checkout HEAD^ &&
 632         (cd submodule2 &&
 633          git rev-parse --verify HEAD >../expect
 634         ) &&
 635         git config submodule.submodule.update rebase &&
 636         test_must_fail git submodule update &&
 637         (cd submodule2 &&
 638          git rev-parse --verify HEAD >../actual
 639         ) &&
 640         test_cmp expect actual
 641        )
 642'
 643
 644test_expect_success 'add different submodules to the same path' '
 645        (cd super &&
 646         git submodule add ../submodule s1 &&
 647         test_must_fail git submodule add ../merging s1
 648        )
 649'
 650
 651test_expect_success 'submodule add places git-dir in superprojects git-dir' '
 652        (cd super &&
 653         mkdir deeper &&
 654         git submodule add ../submodule deeper/submodule &&
 655         (cd deeper/submodule &&
 656          git log > ../../expected
 657         ) &&
 658         (cd .git/modules/deeper/submodule &&
 659          git log > ../../../../actual
 660         ) &&
 661         test_cmp actual expected
 662        )
 663'
 664
 665test_expect_success 'submodule update places git-dir in superprojects git-dir' '
 666        (cd super &&
 667         git commit -m "added submodule"
 668        ) &&
 669        git clone super super2 &&
 670        (cd super2 &&
 671         git submodule init deeper/submodule &&
 672         git submodule update &&
 673         (cd deeper/submodule &&
 674          git log > ../../expected
 675         ) &&
 676         (cd .git/modules/deeper/submodule &&
 677          git log > ../../../../actual
 678         ) &&
 679         test_cmp actual expected
 680        )
 681'
 682
 683test_expect_success 'submodule add places git-dir in superprojects git-dir recursive' '
 684        (cd super2 &&
 685         (cd deeper/submodule &&
 686          git submodule add ../submodule subsubmodule &&
 687          (cd subsubmodule &&
 688           git log > ../../../expected
 689          ) &&
 690          git commit -m "added subsubmodule" &&
 691          git push origin :
 692         ) &&
 693         (cd .git/modules/deeper/submodule/modules/subsubmodule &&
 694          git log > ../../../../../actual
 695         ) &&
 696         git add deeper/submodule &&
 697         git commit -m "update submodule" &&
 698         git push origin : &&
 699         test_cmp actual expected
 700        )
 701'
 702
 703test_expect_success 'submodule update places git-dir in superprojects git-dir recursive' '
 704        mkdir super_update_r &&
 705        (cd super_update_r &&
 706         git init --bare
 707        ) &&
 708        mkdir subsuper_update_r &&
 709        (cd subsuper_update_r &&
 710         git init --bare
 711        ) &&
 712        mkdir subsubsuper_update_r &&
 713        (cd subsubsuper_update_r &&
 714         git init --bare
 715        ) &&
 716        git clone subsubsuper_update_r subsubsuper_update_r2 &&
 717        (cd subsubsuper_update_r2 &&
 718         test_commit "update_subsubsuper" file &&
 719         git push origin master
 720        ) &&
 721        git clone subsuper_update_r subsuper_update_r2 &&
 722        (cd subsuper_update_r2 &&
 723         test_commit "update_subsuper" file &&
 724         git submodule add ../subsubsuper_update_r subsubmodule &&
 725         git commit -am "subsubmodule" &&
 726         git push origin master
 727        ) &&
 728        git clone super_update_r super_update_r2 &&
 729        (cd super_update_r2 &&
 730         test_commit "update_super" file &&
 731         git submodule add ../subsuper_update_r submodule &&
 732         git commit -am "submodule" &&
 733         git push origin master
 734        ) &&
 735        rm -rf super_update_r2 &&
 736        git clone super_update_r super_update_r2 &&
 737        (cd super_update_r2 &&
 738         git submodule update --init --recursive >actual &&
 739         test_i18ngrep "Submodule path .submodule/subsubmodule.: checked out" actual &&
 740         (cd submodule/subsubmodule &&
 741          git log > ../../expected
 742         ) &&
 743         (cd .git/modules/submodule/modules/subsubmodule
 744          git log > ../../../../../actual
 745         )
 746         test_cmp actual expected
 747        )
 748'
 749
 750test_expect_success 'submodule add properly re-creates deeper level submodules' '
 751        (cd super &&
 752         git reset --hard master &&
 753         rm -rf deeper/ &&
 754         git submodule add --force ../submodule deeper/submodule
 755        )
 756'
 757
 758test_expect_success 'submodule update properly revives a moved submodule' '
 759        (cd super &&
 760         H=$(git rev-parse --short HEAD) &&
 761         git commit -am "pre move" &&
 762         H2=$(git rev-parse --short HEAD) &&
 763         git status | sed "s/$H/XXX/" >expect &&
 764         H=$(cd submodule2; git rev-parse HEAD) &&
 765         git rm --cached submodule2 &&
 766         rm -rf submodule2 &&
 767         mkdir -p "moved/sub module" &&
 768         git update-index --add --cacheinfo 160000 $H "moved/sub module" &&
 769         git config -f .gitmodules submodule.submodule2.path "moved/sub module"
 770         git commit -am "post move" &&
 771         git submodule update &&
 772         git status | sed "s/$H2/XXX/" >actual &&
 773         test_cmp expect actual
 774        )
 775'
 776
 777test_expect_success SYMLINKS 'submodule update can handle symbolic links in pwd' '
 778        mkdir -p linked/dir &&
 779        ln -s linked/dir linkto &&
 780        (cd linkto &&
 781         git clone "$TRASH_DIRECTORY"/super_update_r2 super &&
 782         (cd super &&
 783          git submodule update --init --recursive
 784         )
 785        )
 786'
 787
 788test_expect_success 'submodule update clone shallow submodule' '
 789        git clone cloned super3 &&
 790        pwd=$(pwd) &&
 791        (cd super3 &&
 792         sed -e "s#url = ../#url = file://$pwd/#" <.gitmodules >.gitmodules.tmp &&
 793         mv -f .gitmodules.tmp .gitmodules &&
 794         git submodule update --init --depth=3
 795         (cd submodule &&
 796          test 1 = $(git log --oneline | wc -l)
 797         )
 798)
 799'
 800
 801test_expect_success 'submodule update --recursive drops module name before recursing' '
 802        (cd super2 &&
 803         (cd deeper/submodule/subsubmodule &&
 804          git checkout HEAD^
 805         ) &&
 806         git submodule update --recursive deeper/submodule >actual &&
 807         test_i18ngrep "Submodule path .deeper/submodule/subsubmodule.: checked out" actual
 808        )
 809'
 810test_done