Merge branch 'rs/fsck-obj-leakfix' into maint
[gitweb.git] / t / t5526-fetch-submodules.sh
index 954d0e43f52375b1ed86a4edb9d274714d3b596d..162baf101f340885619e0a1e67b0b14cf37a2347 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 &&
        (
@@ -485,4 +495,39 @@ test_expect_success 'fetching submodules respects parallel settings' '
        )
 '
 
+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