Skip to content

Commit 01ce122

Browse files
hvoigtgitster
authored andcommitted
fetch: add test to make sure we stay backwards compatible
The current implementation of submodules supports on-demand fetch if there is no .gitmodules entry for a submodule. Let's add a test to document this behavior. Signed-off-by: Heiko Voigt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d35688d commit 01ce122

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

t/t5526-fetch-submodules.sh

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,47 @@ test_expect_success "don't fetch submodule when newly recorded commits are alrea
478478
git fetch >../actual.out 2>../actual.err
479479
) &&
480480
! test -s actual.out &&
481-
test_i18ncmp expect.err actual.err
481+
test_i18ncmp expect.err actual.err &&
482+
(
483+
cd submodule &&
484+
git checkout -q master
485+
)
486+
'
487+
488+
test_expect_success "'fetch.recurseSubmodules=on-demand' works also without .gitmodule entry" '
489+
(
490+
cd downstream &&
491+
git fetch --recurse-submodules
492+
) &&
493+
add_upstream_commit &&
494+
head1=$(git rev-parse --short HEAD) &&
495+
git add submodule &&
496+
git rm .gitmodules &&
497+
git commit -m "new submodule without .gitmodules" &&
498+
printf "" >expect.out &&
499+
head2=$(git rev-parse --short HEAD) &&
500+
echo "From $pwd/." >expect.err.2 &&
501+
echo " $head1..$head2 master -> origin/master" >>expect.err.2 &&
502+
head -3 expect.err >>expect.err.2 &&
503+
(
504+
cd downstream &&
505+
rm .gitmodules &&
506+
git config fetch.recurseSubmodules on-demand &&
507+
# fake submodule configuration to avoid skipping submodule handling
508+
git config -f .gitmodules submodule.fake.path fake &&
509+
git config -f .gitmodules submodule.fake.url fakeurl &&
510+
git add .gitmodules &&
511+
git config --unset submodule.submodule.url &&
512+
git fetch >../actual.out 2>../actual.err &&
513+
# cleanup
514+
git config --unset fetch.recurseSubmodules &&
515+
git reset --hard
516+
) &&
517+
test_i18ncmp expect.out actual.out &&
518+
test_i18ncmp expect.err.2 actual.err &&
519+
git checkout HEAD^ -- .gitmodules &&
520+
git add .gitmodules &&
521+
git commit -m "new submodule restored .gitmodules"
482522
'
483523

484524
test_expect_success 'fetching submodules respects parallel settings' '

0 commit comments

Comments
 (0)