fetch: Also fetch submodules in subdirectories in on-demand mode

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>

Jens Lehmann committed Jun 20, 2011 at 20:18 UTC ea2d325b88562a074337a8bd30c37d3405c24fae
2 files changed +9 -8
submodule.c
+1
@@ -362,6 +362,7 @@ void check_for_new_submodule_commits(unsigned char new_sha1[20])
362 while (parent) {
363 struct diff_options diff_opts;
364 diff_setup(&diff_opts);
365 + DIFF_OPT_SET(&diff_opts, RECURSIVE);
366 diff_opts.output_format |= DIFF_FORMAT_CALLBACK;
367 diff_opts.format_callback = submodule_collect_changed_cb;
368 if (diff_setup_done(&diff_opts) < 0)
t/t5526-fetch-submodules.sh
+8 -8
@@ -47,7 +47,7 @@ test_expect_success setup '
47 git init &&
48 echo subcontent > subfile &&
49 git add subfile &&
50 - git submodule add "$pwd/deepsubmodule" deepsubmodule &&
50 + git submodule add "$pwd/deepsubmodule" subdir/deepsubmodule &&
51 git commit -a -m new
52 ) &&
53 git submodule add "$pwd/submodule" submodule &&
@@ -58,7 +58,7 @@ test_expect_success setup '
58 git submodule update --init --recursive
59 ) &&
60 echo "Fetching submodule submodule" > expect.out &&
61 - echo "Fetching submodule submodule/deepsubmodule" >> expect.out
61 + echo "Fetching submodule submodule/subdir/deepsubmodule" >> expect.out
62 '
63
64 test_expect_success "fetch --recurse-submodules recurses into submodules" '
@@ -277,12 +277,12 @@ test_expect_success "Recursion picks up all submodules when necessary" '
277 (
278 cd submodule &&
279 (
280 - cd deepsubmodule &&
280 + cd subdir/deepsubmodule &&
281 git fetch &&
282 git checkout -q FETCH_HEAD
283 ) &&
284 head1=$(git rev-parse --short HEAD^) &&
285 - git add deepsubmodule &&
285 + git add subdir/deepsubmodule &&
286 git commit -m "new deepsubmodule"
287 head2=$(git rev-parse --short HEAD) &&
288 echo "From $pwd/submodule" > ../expect.err.sub &&
@@ -309,12 +309,12 @@ test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no ne
309 (
310 cd submodule &&
311 (
312 - cd deepsubmodule &&
312 + cd subdir/deepsubmodule &&
313 git fetch &&
314 git checkout -q FETCH_HEAD
315 ) &&
316 head1=$(git rev-parse --short HEAD^) &&
317 - git add deepsubmodule &&
317 + git add subdir/deepsubmodule &&
318 git commit -m "new deepsubmodule"
319 head2=$(git rev-parse --short HEAD) &&
320 echo "From $pwd/submodule" > ../expect.err.sub &&
@@ -345,13 +345,13 @@ test_expect_success "'--recurse-submodules=on-demand' recurses as deep as necess
345 git config fetch.recurseSubmodules false &&
346 (
347 cd submodule &&
348 - git config -f .gitmodules submodule.deepsubmodule.fetchRecursive false
348 + git config -f .gitmodules submodule.subdir/deepsubmodule.fetchRecursive false
349 ) &&
350 git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err &&
351 git config --unset fetch.recurseSubmodules
352 (
353 cd submodule &&
354 - git config --unset -f .gitmodules submodule.deepsubmodule.fetchRecursive
354 + git config --unset -f .gitmodules submodule.subdir/deepsubmodule.fetchRecursive
355 )
356 ) &&
357 test_i18ncmp expect.out actual.out &&