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 <hvoigt@hvoigt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Heiko Voigt committed Oct 7, 2017 at 00:30 UTC 01ce12252c959ed0f4b4b021adffa7a84a2d64a6
1 file changed +41 -1
t/t5526-fetch-submodules.sh
+41 -1
@@ -478,7 +478,47 @@ test_expect_success "don't fetch submodule when newly recorded commits are alrea
478 git fetch >../actual.out 2>../actual.err
479 ) &&
480 ! 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"
522 '
523
524 test_expect_success 'fetching submodules respects parallel settings' '