2 # Copyright (c) 2010, Jens Lehmann
4 test_description
='Recursive "git fetch" for submodules'
6 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=master
7 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
13 add_upstream_commit
() {
16 head1
=$
(git rev-parse
--short HEAD
) &&
17 echo new
>> subfile
&&
20 git commit
-m new subfile
&&
21 head2
=$
(git rev-parse
--short HEAD
) &&
22 echo "Fetching submodule submodule" > ..
/expect.err
&&
23 echo "From $pwd/submodule" >> ..
/expect.err
&&
24 echo " $head1..$head2 sub -> origin/sub" >> ..
/expect.err
28 head1
=$
(git rev-parse
--short HEAD
) &&
29 echo new
>> deepsubfile
&&
31 git add deepsubfile
&&
32 git commit
-m new deepsubfile
&&
33 head2
=$
(git rev-parse
--short HEAD
) &&
34 echo "Fetching submodule submodule/subdir/deepsubmodule" >> ..
/expect.err
35 echo "From $pwd/deepsubmodule" >> ..
/expect.err
&&
36 echo " $head1..$head2 deep -> origin/deep" >> ..
/expect.err
40 test_expect_success setup
'
41 git config --global protocol.file.allow always &&
42 mkdir deepsubmodule &&
46 echo deepsubcontent > deepsubfile &&
47 git add deepsubfile &&
48 git commit -m new deepsubfile &&
55 echo subcontent > subfile &&
57 git submodule add "$pwd/deepsubmodule" subdir/deepsubmodule &&
58 git commit -a -m new &&
61 git submodule add "$pwd/submodule" submodule &&
62 git commit -am initial &&
63 git branch -M super &&
64 git clone . downstream &&
67 git submodule update --init --recursive
71 test_expect_success
"fetch --recurse-submodules recurses into submodules" '
72 add_upstream_commit &&
75 git fetch --recurse-submodules >../actual.out 2>../actual.err
77 test_must_be_empty actual.out &&
78 test_cmp expect.err actual.err
81 test_expect_success
"submodule.recurse option triggers recursive fetch" '
82 add_upstream_commit &&
85 git -c submodule.recurse fetch >../actual.out 2>../actual.err
87 test_must_be_empty actual.out &&
88 test_cmp expect.err actual.err
91 test_expect_success
"fetch --recurse-submodules -j2 has the same output behaviour" '
92 add_upstream_commit &&
95 GIT_TRACE="$TRASH_DIRECTORY/trace.out" git fetch --recurse-submodules -j2 2>../actual.err
97 test_must_be_empty actual.out &&
98 test_cmp expect.err actual.err &&
99 grep "2 tasks" trace.out
102 test_expect_success
"fetch alone only fetches superproject" '
103 add_upstream_commit &&
106 git fetch >../actual.out 2>../actual.err
108 test_must_be_empty actual.out &&
109 test_must_be_empty actual.err
112 test_expect_success
"fetch --no-recurse-submodules only fetches superproject" '
115 git fetch --no-recurse-submodules >../actual.out 2>../actual.err
117 test_must_be_empty actual.out &&
118 test_must_be_empty actual.err
121 test_expect_success
"using fetchRecurseSubmodules=true in .gitmodules recurses into submodules" '
124 git config -f .gitmodules submodule.submodule.fetchRecurseSubmodules true &&
125 git fetch >../actual.out 2>../actual.err
127 test_must_be_empty actual.out &&
128 test_cmp expect.err actual.err
131 test_expect_success
"--no-recurse-submodules overrides .gitmodules config" '
132 add_upstream_commit &&
135 git fetch --no-recurse-submodules >../actual.out 2>../actual.err
137 test_must_be_empty actual.out &&
138 test_must_be_empty actual.err
141 test_expect_success
"using fetchRecurseSubmodules=false in .git/config overrides setting in .gitmodules" '
144 git config submodule.submodule.fetchRecurseSubmodules false &&
145 git fetch >../actual.out 2>../actual.err
147 test_must_be_empty actual.out &&
148 test_must_be_empty actual.err
151 test_expect_success
"--recurse-submodules overrides fetchRecurseSubmodules setting from .git/config" '
154 git fetch --recurse-submodules >../actual.out 2>../actual.err &&
155 git config --unset -f .gitmodules submodule.submodule.fetchRecurseSubmodules &&
156 git config --unset submodule.submodule.fetchRecurseSubmodules
158 test_must_be_empty actual.out &&
159 test_cmp expect.err actual.err
162 test_expect_success
"--quiet propagates to submodules" '
165 git fetch --recurse-submodules --quiet >../actual.out 2>../actual.err
167 test_must_be_empty actual.out &&
168 test_must_be_empty actual.err
171 test_expect_success
"--quiet propagates to parallel submodules" '
174 git fetch --recurse-submodules -j 2 --quiet >../actual.out 2>../actual.err
176 test_must_be_empty actual.out &&
177 test_must_be_empty actual.err
180 test_expect_success
"--dry-run propagates to submodules" '
181 add_upstream_commit &&
184 git fetch --recurse-submodules --dry-run >../actual.out 2>../actual.err
186 test_must_be_empty actual.out &&
187 test_cmp expect.err actual.err
190 test_expect_success
"Without --dry-run propagates to submodules" '
193 git fetch --recurse-submodules >../actual.out 2>../actual.err
195 test_must_be_empty actual.out &&
196 test_cmp expect.err actual.err
199 test_expect_success
"recurseSubmodules=true propagates into submodules" '
200 add_upstream_commit &&
203 git config fetch.recurseSubmodules true &&
204 git fetch >../actual.out 2>../actual.err
206 test_must_be_empty actual.out &&
207 test_cmp expect.err actual.err
210 test_expect_success
"--recurse-submodules overrides config in submodule" '
211 add_upstream_commit &&
216 git config fetch.recurseSubmodules false
218 git fetch --recurse-submodules >../actual.out 2>../actual.err
220 test_must_be_empty actual.out &&
221 test_cmp expect.err actual.err
224 test_expect_success
"--no-recurse-submodules overrides config setting" '
225 add_upstream_commit &&
228 git config fetch.recurseSubmodules true &&
229 git fetch --no-recurse-submodules >../actual.out 2>../actual.err
231 test_must_be_empty actual.out &&
232 test_must_be_empty actual.err
235 test_expect_success
"Recursion doesn't happen when no new commits are fetched in the superproject" '
240 git config --unset fetch.recurseSubmodules
242 git config --unset fetch.recurseSubmodules &&
243 git fetch >../actual.out 2>../actual.err
245 test_must_be_empty actual.out &&
246 test_must_be_empty actual.err
249 test_expect_success
"Recursion stops when no new submodule commits are fetched" '
250 head1=$(git rev-parse --short HEAD) &&
252 git commit -m "new submodule" &&
253 head2=$(git rev-parse --short HEAD) &&
254 echo "From $pwd/." > expect.err.sub &&
255 echo " $head1..$head2 super -> origin/super" >>expect.err.sub &&
256 head -3 expect.err >> expect.err.sub &&
259 git fetch >../actual.out 2>../actual.err
261 test_cmp expect.err.sub actual.err &&
262 test_must_be_empty actual.out
265 test_expect_success
"Recursion doesn't happen when new superproject commits don't change any submodules" '
266 add_upstream_commit &&
267 head1=$(git rev-parse --short HEAD) &&
270 git commit -m "new file" &&
271 head2=$(git rev-parse --short HEAD) &&
272 echo "From $pwd/." > expect.err.file &&
273 echo " $head1..$head2 super -> origin/super" >> expect.err.file &&
276 git fetch >../actual.out 2>../actual.err
278 test_must_be_empty actual.out &&
279 test_cmp expect.err.file actual.err
282 test_expect_success
"Recursion picks up config in submodule" '
285 git fetch --recurse-submodules &&
288 git config fetch.recurseSubmodules true
291 add_upstream_commit &&
292 head1=$(git rev-parse --short HEAD) &&
294 git commit -m "new submodule" &&
295 head2=$(git rev-parse --short HEAD) &&
296 echo "From $pwd/." > expect.err.sub &&
297 echo " $head1..$head2 super -> origin/super" >> expect.err.sub &&
298 cat expect.err >> expect.err.sub &&
301 git fetch >../actual.out 2>../actual.err &&
304 git config --unset fetch.recurseSubmodules
307 test_cmp expect.err.sub actual.err &&
308 test_must_be_empty actual.out
311 test_expect_success
"Recursion picks up all submodules when necessary" '
312 add_upstream_commit &&
316 cd subdir/deepsubmodule &&
318 git checkout -q FETCH_HEAD
320 head1=$(git rev-parse --short HEAD^) &&
321 git add subdir/deepsubmodule &&
322 git commit -m "new deepsubmodule" &&
323 head2=$(git rev-parse --short HEAD) &&
324 echo "Fetching submodule submodule" > ../expect.err.sub &&
325 echo "From $pwd/submodule" >> ../expect.err.sub &&
326 echo " $head1..$head2 sub -> origin/sub" >> ../expect.err.sub
328 head1=$(git rev-parse --short HEAD) &&
330 git commit -m "new submodule" &&
331 head2=$(git rev-parse --short HEAD) &&
332 echo "From $pwd/." > expect.err.2 &&
333 echo " $head1..$head2 super -> origin/super" >> expect.err.2 &&
334 cat expect.err.sub >> expect.err.2 &&
335 tail -3 expect.err >> expect.err.2 &&
338 git fetch >../actual.out 2>../actual.err
340 test_cmp expect.err.2 actual.err &&
341 test_must_be_empty actual.out
344 test_expect_success
"'--recurse-submodules=on-demand' doesn't recurse when no new commits are fetched in the superproject (and ignores config)" '
345 add_upstream_commit &&
349 cd subdir/deepsubmodule &&
351 git checkout -q FETCH_HEAD
353 head1=$(git rev-parse --short HEAD^) &&
354 git add subdir/deepsubmodule &&
355 git commit -m "new deepsubmodule" &&
356 head2=$(git rev-parse --short HEAD) &&
357 echo Fetching submodule submodule > ../expect.err.sub &&
358 echo "From $pwd/submodule" >> ../expect.err.sub &&
359 echo " $head1..$head2 sub -> origin/sub" >> ../expect.err.sub
363 git config fetch.recurseSubmodules true &&
364 git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err &&
365 git config --unset fetch.recurseSubmodules
367 test_must_be_empty actual.out &&
368 test_must_be_empty actual.err
371 test_expect_success
"'--recurse-submodules=on-demand' recurses as deep as necessary (and ignores config)" '
372 head1=$(git rev-parse --short HEAD) &&
374 git commit -m "new submodule" &&
375 head2=$(git rev-parse --short HEAD) &&
376 tail -3 expect.err > expect.err.deepsub &&
377 echo "From $pwd/." > expect.err &&
378 echo " $head1..$head2 super -> origin/super" >>expect.err &&
379 cat expect.err.sub >> expect.err &&
380 cat expect.err.deepsub >> expect.err &&
383 git config fetch.recurseSubmodules false &&
386 git config -f .gitmodules submodule.subdir/deepsubmodule.fetchRecursive false
388 git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err &&
389 git config --unset fetch.recurseSubmodules &&
392 git config --unset -f .gitmodules submodule.subdir/deepsubmodule.fetchRecursive
395 test_must_be_empty actual.out &&
396 test_cmp expect.err actual.err
399 test_expect_success
"'--recurse-submodules=on-demand' stops when no new submodule commits are found in the superproject (and ignores config)" '
400 add_upstream_commit &&
401 head1=$(git rev-parse --short HEAD) &&
404 git commit -m "new file" &&
405 head2=$(git rev-parse --short HEAD) &&
406 echo "From $pwd/." > expect.err.file &&
407 echo " $head1..$head2 super -> origin/super" >> expect.err.file &&
410 git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err
412 test_must_be_empty actual.out &&
413 test_cmp expect.err.file actual.err
416 test_expect_success
"'fetch.recurseSubmodules=on-demand' overrides global config" '
419 git fetch --recurse-submodules
421 add_upstream_commit &&
422 git config --global fetch.recurseSubmodules false &&
423 head1=$(git rev-parse --short HEAD) &&
425 git commit -m "new submodule" &&
426 head2=$(git rev-parse --short HEAD) &&
427 echo "From $pwd/." > expect.err.2 &&
428 echo " $head1..$head2 super -> origin/super" >>expect.err.2 &&
429 head -3 expect.err >> expect.err.2 &&
432 git config fetch.recurseSubmodules on-demand &&
433 git fetch >../actual.out 2>../actual.err
435 git config --global --unset fetch.recurseSubmodules &&
438 git config --unset fetch.recurseSubmodules
440 test_must_be_empty actual.out &&
441 test_cmp expect.err.2 actual.err
444 test_expect_success
"'submodule.<sub>.fetchRecurseSubmodules=on-demand' overrides fetch.recurseSubmodules" '
447 git fetch --recurse-submodules
449 add_upstream_commit &&
450 git config fetch.recurseSubmodules false &&
451 head1=$(git rev-parse --short HEAD) &&
453 git commit -m "new submodule" &&
454 head2=$(git rev-parse --short HEAD) &&
455 echo "From $pwd/." > expect.err.2 &&
456 echo " $head1..$head2 super -> origin/super" >>expect.err.2 &&
457 head -3 expect.err >> expect.err.2 &&
460 git config submodule.submodule.fetchRecurseSubmodules on-demand &&
461 git fetch >../actual.out 2>../actual.err
463 git config --unset fetch.recurseSubmodules &&
466 git config --unset submodule.submodule.fetchRecurseSubmodules
468 test_must_be_empty actual.out &&
469 test_cmp expect.err.2 actual.err
472 test_expect_success
"don't fetch submodule when newly recorded commits are already present" '
475 git checkout -q HEAD^^
477 head1=$(git rev-parse --short HEAD) &&
479 git commit -m "submodule rewound" &&
480 head2=$(git rev-parse --short HEAD) &&
481 echo "From $pwd/." > expect.err &&
482 echo " $head1..$head2 super -> origin/super" >> expect.err &&
485 git fetch >../actual.out 2>../actual.err
487 test_must_be_empty actual.out &&
488 test_cmp expect.err actual.err &&
495 test_expect_success
"'fetch.recurseSubmodules=on-demand' works also without .gitmodules entry" '
498 git fetch --recurse-submodules
500 add_upstream_commit &&
501 head1=$(git rev-parse --short HEAD) &&
503 git rm .gitmodules &&
504 git commit -m "new submodule without .gitmodules" &&
505 head2=$(git rev-parse --short HEAD) &&
506 echo "From $pwd/." >expect.err.2 &&
507 echo " $head1..$head2 super -> origin/super" >>expect.err.2 &&
508 head -3 expect.err >>expect.err.2 &&
512 git config fetch.recurseSubmodules on-demand &&
513 # fake submodule configuration to avoid skipping submodule handling
514 git config -f .gitmodules submodule.fake.path fake &&
515 git config -f .gitmodules submodule.fake.url fakeurl &&
516 git add .gitmodules &&
517 git config --unset submodule.submodule.url &&
518 git fetch >../actual.out 2>../actual.err &&
520 git config --unset fetch.recurseSubmodules &&
523 test_must_be_empty actual.out &&
524 test_cmp expect.err.2 actual.err &&
525 git checkout HEAD^ -- .gitmodules &&
526 git add .gitmodules &&
527 git commit -m "new submodule restored .gitmodules"
530 test_expect_success
'fetching submodules respects parallel settings' '
531 git config fetch.recurseSubmodules true &&
534 GIT_TRACE=$(pwd)/trace.out git fetch &&
535 grep "1 tasks" trace.out &&
536 GIT_TRACE=$(pwd)/trace.out git fetch --jobs 7 &&
537 grep "7 tasks" trace.out &&
538 git config submodule.fetchJobs 8 &&
539 GIT_TRACE=$(pwd)/trace.out git fetch &&
540 grep "8 tasks" trace.out &&
541 GIT_TRACE=$(pwd)/trace.out git fetch --jobs 9 &&
542 grep "9 tasks" trace.out
546 test_expect_success
'fetching submodule into a broken repository' '
547 # Prepare src and src/sub nested in it
552 git -C sub commit --allow-empty -m "initial in sub" &&
553 git submodule add -- ./sub sub &&
554 git commit -m "initial in top"
557 # Clone the old-fashoned way
559 git -C dst clone ../src/sub sub &&
561 # Make sure that old-fashoned layout is still supported
564 # "diff" would find no change
565 git -C dst diff --exit-code &&
567 # Recursive-fetch works fine
568 git -C dst fetch --recurse-submodules &&
570 # Break the receiving submodule
571 rm -f dst/sub/.git/HEAD &&
573 # NOTE: without the fix the following tests will recurse forever!
574 # They should terminate with an error.
576 test_must_fail git -C dst status &&
577 test_must_fail git -C dst diff &&
578 test_must_fail git -C dst fetch --recurse-submodules
581 test_expect_success
"fetch new commits when submodule got renamed" '
582 git clone . downstream_rename &&
584 cd downstream_rename &&
585 git submodule update --init --recursive &&
586 git checkout -b rename &&
587 git mv submodule submodule_renamed &&
589 cd submodule_renamed &&
590 git checkout -b rename_sub &&
594 git push origin rename_sub &&
595 git rev-parse HEAD >../../expect
597 git add submodule_renamed &&
598 git commit -m "update renamed submodule" &&
599 git push origin rename
603 git fetch --recurse-submodules=on-demand &&
606 git rev-parse origin/rename_sub >../../actual
609 test_cmp expect actual
612 test_expect_success
"fetch new submodule commits on-demand outside standard refspec" '
613 # add a second submodule and ensure it is around in downstream first
614 git clone submodule sub1 &&
615 git submodule add ./sub1 &&
616 git commit -m "adding a second submodule" &&
617 git -C downstream pull &&
618 git -C downstream submodule update --init --recursive &&
620 git checkout --detach &&
622 C=$(git -C submodule commit-tree -m "new change outside refs/heads" HEAD^{tree}) &&
623 git -C submodule update-ref refs/changes/1 $C &&
624 git update-index --cacheinfo 160000 $C submodule &&
627 D=$(git -C sub1 commit-tree -m "new change outside refs/heads" HEAD^{tree}) &&
628 git -C sub1 update-ref refs/changes/2 $D &&
629 git update-index --cacheinfo 160000 $D sub1 &&
631 git commit -m "updated submodules outside of refs/heads" &&
632 E=$(git rev-parse HEAD) &&
633 git update-ref refs/changes/3 $E &&
636 git fetch --recurse-submodules origin refs/changes/3:refs/heads/my_branch &&
637 git -C submodule cat-file -t $C &&
638 git -C sub1 cat-file -t $D &&
639 git checkout --recurse-submodules FETCH_HEAD
643 test_expect_success
'fetch new submodule commit on-demand in FETCH_HEAD' '
644 # depends on the previous test for setup
646 C=$(git -C submodule commit-tree -m "another change outside refs/heads" HEAD^{tree}) &&
647 git -C submodule update-ref refs/changes/4 $C &&
648 git update-index --cacheinfo 160000 $C submodule &&
651 D=$(git -C sub1 commit-tree -m "another change outside refs/heads" HEAD^{tree}) &&
652 git -C sub1 update-ref refs/changes/5 $D &&
653 git update-index --cacheinfo 160000 $D sub1 &&
655 git commit -m "updated submodules outside of refs/heads" &&
656 E=$(git rev-parse HEAD) &&
657 git update-ref refs/changes/6 $E &&
660 git fetch --recurse-submodules origin refs/changes/6 &&
661 git -C submodule cat-file -t $C &&
662 git -C sub1 cat-file -t $D &&
663 git checkout --recurse-submodules FETCH_HEAD
667 test_expect_success
'fetch new submodule commits on-demand without .gitmodules entry' '
668 # depends on the previous test for setup
670 git config -f .gitmodules --remove-section submodule.sub1 &&
671 git add .gitmodules &&
672 git commit -m "delete gitmodules file" &&
673 git checkout -B super &&
674 git -C downstream fetch &&
675 git -C downstream checkout origin/super &&
677 C=$(git -C submodule commit-tree -m "yet another change outside refs/heads" HEAD^{tree}) &&
678 git -C submodule update-ref refs/changes/7 $C &&
679 git update-index --cacheinfo 160000 $C submodule &&
682 D=$(git -C sub1 commit-tree -m "yet another change outside refs/heads" HEAD^{tree}) &&
683 git -C sub1 update-ref refs/changes/8 $D &&
684 git update-index --cacheinfo 160000 $D sub1 &&
686 git commit -m "updated submodules outside of refs/heads" &&
687 E=$(git rev-parse HEAD) &&
688 git update-ref refs/changes/9 $E &&
691 git fetch --recurse-submodules origin refs/changes/9 &&
692 git -C submodule cat-file -t $C &&
693 git -C sub1 cat-file -t $D &&
694 git checkout --recurse-submodules FETCH_HEAD
698 test_expect_success
'fetch new submodule commit intermittently referenced by superproject' '
699 # depends on the previous test for setup
701 D=$(git -C sub1 commit-tree -m "change 10 outside refs/heads" HEAD^{tree}) &&
702 E=$(git -C sub1 commit-tree -m "change 11 outside refs/heads" HEAD^{tree}) &&
703 F=$(git -C sub1 commit-tree -m "change 12 outside refs/heads" HEAD^{tree}) &&
705 git -C sub1 update-ref refs/changes/10 $D &&
706 git update-index --cacheinfo 160000 $D sub1 &&
707 git commit -m "updated submodules outside of refs/heads" &&
709 git -C sub1 update-ref refs/changes/11 $E &&
710 git update-index --cacheinfo 160000 $E sub1 &&
711 git commit -m "updated submodules outside of refs/heads" &&
713 git -C sub1 update-ref refs/changes/12 $F &&
714 git update-index --cacheinfo 160000 $F sub1 &&
715 git commit -m "updated submodules outside of refs/heads" &&
717 G=$(git rev-parse HEAD) &&
718 git update-ref refs/changes/13 $G &&
721 git fetch --recurse-submodules origin refs/changes/13 &&
723 git -C sub1 cat-file -t $D &&
724 git -C sub1 cat-file -t $E &&
725 git -C sub1 cat-file -t $F
733 git
-C "$dir" add
"$@" &&
734 git
-C "$dir" commit
-a -m "$msg" &&
738 compare_refs_in_dir
() {
745 git
-C "$1" rev-parse
--verify "$2" >expect
&&
746 git
-C "$3" rev-parse
--verify "$4" >actual
&&
747 eval $fail test_cmp expect actual
751 test_expect_success
'setup nested submodule fetch test' '
752 # does not depend on any previous test setups
754 for repo in outer middle inner
756 git init --bare $repo &&
757 git clone $repo ${repo}_content &&
758 echo "$repo" >"${repo}_content/file" &&
759 add_commit_push ${repo}_content "initial" file ||
764 git -C A submodule add "$pwd/middle" &&
765 git -C A/middle/ submodule add "$pwd/inner" &&
766 add_commit_push A/middle/ "adding inner sub" .gitmodules inner &&
767 add_commit_push A/ "adding middle sub" .gitmodules middle &&
770 git -C B/ submodule update --init middle &&
772 compare_refs_in_dir A HEAD B HEAD &&
773 compare_refs_in_dir A/middle HEAD B/middle HEAD &&
774 test_path_is_file B/file &&
775 test_path_is_file B/middle/file &&
776 test_path_is_missing B/middle/inner/file &&
778 echo "change on inner repo of A" >"A/middle/inner/file" &&
779 add_commit_push A/middle/inner "change on inner" file &&
780 add_commit_push A/middle "change on inner" inner &&
781 add_commit_push A "change on inner" middle
784 test_expect_success
'fetching a superproject containing an uninitialized sub/sub project' '
785 # depends on previous test for setup
788 compare_refs_in_dir A origin/HEAD B origin/HEAD
791 fetch_with_recursion_abort
() {
792 # In a regression the following git call will run into infinite recursion.
793 # To handle that, we connect the sed command to the git call by a pipe
794 # so that sed can kill the infinite recursion when detected.
795 # The recursion creates git output like:
796 # Fetching submodule sub
797 # Fetching submodule sub/sub <-- [1]
798 # Fetching submodule sub/sub/sub
800 # [1] sed will stop reading and cause git to eventually stop and die
802 git
-C "$1" fetch
--recurse-submodules 2>&1 |
803 sed "/Fetching submodule $2[^$]/q" >out
&&
804 ! grep "Fetching submodule $2[^$]" out
807 test_expect_success
'setup recursive fetch with uninit submodule' '
808 # does not depend on any previous test setups
810 test_create_repo super &&
811 test_commit -C super initial &&
812 test_create_repo sub &&
813 test_commit -C sub initial &&
814 git -C sub rev-parse HEAD >expect &&
816 git -C super submodule add ../sub &&
817 git -C super commit -m "add sub" &&
819 git clone super superclone &&
820 git -C superclone submodule status >out &&
821 sed -e "s/^-//" -e "s/ sub.*$//" out >actual &&
822 test_cmp expect actual
825 test_expect_success
'recursive fetch with uninit submodule' '
826 # depends on previous test for setup
828 fetch_with_recursion_abort superclone sub &&
829 git -C superclone submodule status >out &&
830 sed -e "s/^-//" -e "s/ sub$//" out >actual &&
831 test_cmp expect actual
834 test_expect_success
'recursive fetch after deinit a submodule' '
835 # depends on previous test for setup
837 git -C superclone submodule update --init sub &&
838 git -C superclone submodule deinit -f sub &&
840 fetch_with_recursion_abort superclone sub &&
841 git -C superclone submodule status >out &&
842 sed -e "s/^-//" -e "s/ sub$//" out >actual &&
843 test_cmp expect actual