Merge branch 'ma/ts-cleanups'
[gitweb.git] / t / t5526-fetch-submodules.sh
index 1241146227aead97022ade343152347bc911444c..42251f7f3af0865a31fd38722fbf7433d81fe3f0 100755 (executable)
@@ -71,6 +71,16 @@ test_expect_success "fetch --recurse-submodules recurses into submodules" '
        test_i18ncmp expect.err actual.err
 '
 
+test_expect_success "submodule.recurse option triggers recursive fetch" '
+       add_upstream_commit &&
+       (
+               cd downstream &&
+               git -c submodule.recurse fetch >../actual.out 2>../actual.err
+       ) &&
+       test_must_be_empty actual.out &&
+       test_i18ncmp expect.err actual.err
+'
+
 test_expect_success "fetch --recurse-submodules -j2 has the same output behaviour" '
        add_upstream_commit &&
        (
@@ -183,7 +193,7 @@ test_expect_success "recurseSubmodules=true propagates into submodules" '
        add_upstream_commit &&
        (
                cd downstream &&
-               git config fetch.recurseSubmodules true
+               git config fetch.recurseSubmodules true &&
                git fetch >../actual.out 2>../actual.err
        ) &&
        test_must_be_empty actual.out &&
@@ -208,7 +218,7 @@ test_expect_success "--no-recurse-submodules overrides config setting" '
        add_upstream_commit &&
        (
                cd downstream &&
-               git config fetch.recurseSubmodules true
+               git config fetch.recurseSubmodules true &&
                git fetch --no-recurse-submodules >../actual.out 2>../actual.err
        ) &&
        ! test -s actual.out &&
@@ -222,7 +232,7 @@ test_expect_success "Recursion doesn't happen when no new commits are fetched in
                        cd submodule &&
                        git config --unset fetch.recurseSubmodules
                ) &&
-               git config --unset fetch.recurseSubmodules
+               git config --unset fetch.recurseSubmodules &&
                git fetch >../actual.out 2>../actual.err
        ) &&
        ! test -s actual.out &&
@@ -302,7 +312,7 @@ test_expect_success "Recursion picks up all submodules when necessary" '
                ) &&
                head1=$(git rev-parse --short HEAD^) &&
                git add subdir/deepsubmodule &&
-               git commit -m "new deepsubmodule"
+               git commit -m "new deepsubmodule" &&
                head2=$(git rev-parse --short HEAD) &&
                echo "Fetching submodule submodule" > ../expect.err.sub &&
                echo "From $pwd/submodule" >> ../expect.err.sub &&
@@ -471,4 +481,53 @@ test_expect_success "don't fetch submodule when newly recorded commits are alrea
        test_i18ncmp expect.err actual.err
 '
 
+test_expect_success 'fetching submodules respects parallel settings' '
+       git config fetch.recurseSubmodules true &&
+       (
+               cd downstream &&
+               GIT_TRACE=$(pwd)/trace.out git fetch --jobs 7 &&
+               grep "7 tasks" trace.out &&
+               git config submodule.fetchJobs 8 &&
+               GIT_TRACE=$(pwd)/trace.out git fetch &&
+               grep "8 tasks" trace.out &&
+               GIT_TRACE=$(pwd)/trace.out git fetch --jobs 9 &&
+               grep "9 tasks" trace.out
+       )
+'
+
+test_expect_success 'fetching submodule into a broken repository' '
+       # Prepare src and src/sub nested in it
+       git init src &&
+       (
+               cd src &&
+               git init sub &&
+               git -C sub commit --allow-empty -m "initial in sub" &&
+               git submodule add -- ./sub sub &&
+               git commit -m "initial in top"
+       ) &&
+
+       # Clone the old-fashoned way
+       git clone src dst &&
+       git -C dst clone ../src/sub sub &&
+
+       # Make sure that old-fashoned layout is still supported
+       git -C dst status &&
+
+       # "diff" would find no change
+       git -C dst diff --exit-code &&
+
+       # Recursive-fetch works fine
+       git -C dst fetch --recurse-submodules &&
+
+       # Break the receiving submodule
+       rm -f dst/sub/.git/HEAD &&
+
+       # NOTE: without the fix the following tests will recurse forever!
+       # They should terminate with an error.
+
+       test_must_fail git -C dst status &&
+       test_must_fail git -C dst diff &&
+       test_must_fail git -C dst fetch --recurse-submodules
+'
+
 test_done