Skip to content

Commit ea2d325

Browse files
jlehmanngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent daab4ee commit ea2d325

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

submodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ void check_for_new_submodule_commits(unsigned char new_sha1[20])
362362
while (parent) {
363363
struct diff_options diff_opts;
364364
diff_setup(&diff_opts);
365+
DIFF_OPT_SET(&diff_opts, RECURSIVE);
365366
diff_opts.output_format |= DIFF_FORMAT_CALLBACK;
366367
diff_opts.format_callback = submodule_collect_changed_cb;
367368
if (diff_setup_done(&diff_opts) < 0)

t/t5526-fetch-submodules.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test_expect_success setup '
4747
git init &&
4848
echo subcontent > subfile &&
4949
git add subfile &&
50-
git submodule add "$pwd/deepsubmodule" deepsubmodule &&
50+
git submodule add "$pwd/deepsubmodule" subdir/deepsubmodule &&
5151
git commit -a -m new
5252
) &&
5353
git submodule add "$pwd/submodule" submodule &&
@@ -58,7 +58,7 @@ test_expect_success setup '
5858
git submodule update --init --recursive
5959
) &&
6060
echo "Fetching submodule submodule" > expect.out &&
61-
echo "Fetching submodule submodule/deepsubmodule" >> expect.out
61+
echo "Fetching submodule submodule/subdir/deepsubmodule" >> expect.out
6262
'
6363

6464
test_expect_success "fetch --recurse-submodules recurses into submodules" '
@@ -277,12 +277,12 @@ test_expect_success "Recursion picks up all submodules when necessary" '
277277
(
278278
cd submodule &&
279279
(
280-
cd deepsubmodule &&
280+
cd subdir/deepsubmodule &&
281281
git fetch &&
282282
git checkout -q FETCH_HEAD
283283
) &&
284284
head1=$(git rev-parse --short HEAD^) &&
285-
git add deepsubmodule &&
285+
git add subdir/deepsubmodule &&
286286
git commit -m "new deepsubmodule"
287287
head2=$(git rev-parse --short HEAD) &&
288288
echo "From $pwd/submodule" > ../expect.err.sub &&
@@ -309,12 +309,12 @@ test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no ne
309309
(
310310
cd submodule &&
311311
(
312-
cd deepsubmodule &&
312+
cd subdir/deepsubmodule &&
313313
git fetch &&
314314
git checkout -q FETCH_HEAD
315315
) &&
316316
head1=$(git rev-parse --short HEAD^) &&
317-
git add deepsubmodule &&
317+
git add subdir/deepsubmodule &&
318318
git commit -m "new deepsubmodule"
319319
head2=$(git rev-parse --short HEAD) &&
320320
echo "From $pwd/submodule" > ../expect.err.sub &&
@@ -345,13 +345,13 @@ test_expect_success "'--recurse-submodules=on-demand' recurses as deep as necess
345345
git config fetch.recurseSubmodules false &&
346346
(
347347
cd submodule &&
348-
git config -f .gitmodules submodule.deepsubmodule.fetchRecursive false
348+
git config -f .gitmodules submodule.subdir/deepsubmodule.fetchRecursive false
349349
) &&
350350
git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err &&
351351
git config --unset fetch.recurseSubmodules
352352
(
353353
cd submodule &&
354-
git config --unset -f .gitmodules submodule.deepsubmodule.fetchRecursive
354+
git config --unset -f .gitmodules submodule.subdir/deepsubmodule.fetchRecursive
355355
)
356356
) &&
357357
test_i18ncmp expect.out actual.out &&

0 commit comments

Comments
 (0)