Code

fetch: Also fetch submodules in subdirectories in on-demand mode
authorJens Lehmann <Jens.Lehmann@web.de>
Mon, 20 Jun 2011 18:18:03 +0000 (20:18 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Jun 2011 20:04:49 +0000 (13:04 -0700)
When on-demand mode was active examining the new commits just fetched in
the superproject (to check if they record commits for submodules which are
not downloaded yet) wasn't done recursively. Because of that fetch did not
recursively fetch submodules living in subdirectories even when it should
have.

Fix that by adding the RECURSIVE flag to the diff_options used to check
the new commits and avoid future regressions in this area by moving a
submodule in t5526 into a subdirectory.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
submodule.c
t/t5526-fetch-submodules.sh

index 5294cef641ef74ec525d8d747c82faf0bef7352a..e43f221af2d1f3a6c6611d8dc37e349e63bc4bf2 100644 (file)
@@ -362,6 +362,7 @@ void check_for_new_submodule_commits(unsigned char new_sha1[20])
                while (parent) {
                        struct diff_options diff_opts;
                        diff_setup(&diff_opts);
+                       DIFF_OPT_SET(&diff_opts, RECURSIVE);
                        diff_opts.output_format |= DIFF_FORMAT_CALLBACK;
                        diff_opts.format_callback = submodule_collect_changed_cb;
                        if (diff_setup_done(&diff_opts) < 0)
index a1fddd4d15fb2c3cb5d0ab6e09a461314fb4b1f1..ca5b027c557014cff85ca4ba7d118db578a57256 100755 (executable)
@@ -47,7 +47,7 @@ test_expect_success setup '
                git init &&
                echo subcontent > subfile &&
                git add subfile &&
-               git submodule add "$pwd/deepsubmodule" deepsubmodule &&
+               git submodule add "$pwd/deepsubmodule" subdir/deepsubmodule &&
                git commit -a -m new
        ) &&
        git submodule add "$pwd/submodule" submodule &&
@@ -58,7 +58,7 @@ test_expect_success setup '
                git submodule update --init --recursive
        ) &&
        echo "Fetching submodule submodule" > expect.out &&
-       echo "Fetching submodule submodule/deepsubmodule" >> expect.out
+       echo "Fetching submodule submodule/subdir/deepsubmodule" >> expect.out
 '
 
 test_expect_success "fetch --recurse-submodules recurses into submodules" '
@@ -277,12 +277,12 @@ test_expect_success "Recursion picks up all submodules when necessary" '
        (
                cd submodule &&
                (
-                       cd deepsubmodule &&
+                       cd subdir/deepsubmodule &&
                        git fetch &&
                        git checkout -q FETCH_HEAD
                ) &&
                head1=$(git rev-parse --short HEAD^) &&
-               git add deepsubmodule &&
+               git add subdir/deepsubmodule &&
                git commit -m "new deepsubmodule"
                head2=$(git rev-parse --short HEAD) &&
                echo "From $pwd/submodule" > ../expect.err.sub &&
@@ -309,12 +309,12 @@ test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no ne
        (
                cd submodule &&
                (
-                       cd deepsubmodule &&
+                       cd subdir/deepsubmodule &&
                        git fetch &&
                        git checkout -q FETCH_HEAD
                ) &&
                head1=$(git rev-parse --short HEAD^) &&
-               git add deepsubmodule &&
+               git add subdir/deepsubmodule &&
                git commit -m "new deepsubmodule"
                head2=$(git rev-parse --short HEAD) &&
                echo "From $pwd/submodule" > ../expect.err.sub &&
@@ -345,13 +345,13 @@ test_expect_success "'--recurse-submodules=on-demand' recurses as deep as necess
                git config fetch.recurseSubmodules false &&
                (
                        cd submodule &&
-                       git config -f .gitmodules submodule.deepsubmodule.fetchRecursive false
+                       git config -f .gitmodules submodule.subdir/deepsubmodule.fetchRecursive false
                ) &&
                git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err &&
                git config --unset fetch.recurseSubmodules
                (
                        cd submodule &&
-                       git config --unset -f .gitmodules submodule.deepsubmodule.fetchRecursive
+                       git config --unset -f .gitmodules submodule.subdir/deepsubmodule.fetchRecursive
                )
        ) &&
        test_i18ncmp expect.out actual.out &&