Skip to content

Commit 62607e4

Browse files
committed
Merge branch 'jl/maint-fetch-recursive-fix' into maint
* jl/maint-fetch-recursive-fix: fetch: Also fetch submodules in subdirectories in on-demand mode
2 parents 6124690 + ea2d325 commit 62607e4

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
@@ -388,6 +388,7 @@ void check_for_new_submodule_commits(unsigned char new_sha1[20])
388388
while (parent) {
389389
struct diff_options diff_opts;
390390
diff_setup(&diff_opts);
391+
DIFF_OPT_SET(&diff_opts, RECURSIVE);
391392
diff_opts.output_format |= DIFF_FORMAT_CALLBACK;
392393
diff_opts.format_callback = submodule_collect_changed_cb;
393394
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)