Merge branch 'ew/daemon-socket-keepalive' into maint
[git/git-svn.git] / t / t7406-submodule-update.sh
blob5f278799d5a0ceed90b9297ace552b653026e596
1 #!/bin/sh
3 # Copyright (c) 2009 Red Hat, Inc.
6 test_description='Test updating submodules
8 This test verifies that "git submodule update" detaches the HEAD of the
9 submodule and "git submodule update --rebase/--merge" does not detach the HEAD.
12 . ./test-lib.sh
15 compare_head()
17 sha_master=$(git rev-list --max-count=1 master)
18 sha_head=$(git rev-list --max-count=1 HEAD)
20 test "$sha_master" = "$sha_head"
24 test_expect_success 'setup a submodule tree' '
25 echo file > file &&
26 git add file &&
27 test_tick &&
28 git commit -m upstream &&
29 git clone . super &&
30 git clone super submodule &&
31 git clone super rebasing &&
32 git clone super merging &&
33 git clone super none &&
34 (cd super &&
35 git submodule add ../submodule submodule &&
36 test_tick &&
37 git commit -m "submodule" &&
38 git submodule init submodule
39 ) &&
40 (cd submodule &&
41 echo "line2" > file &&
42 git add file &&
43 git commit -m "Commit 2"
44 ) &&
45 (cd super &&
46 (cd submodule &&
47 git pull --rebase origin
48 ) &&
49 git add submodule &&
50 git commit -m "submodule update"
51 ) &&
52 (cd super &&
53 git submodule add ../rebasing rebasing &&
54 test_tick &&
55 git commit -m "rebasing"
56 ) &&
57 (cd super &&
58 git submodule add ../merging merging &&
59 test_tick &&
60 git commit -m "rebasing"
61 ) &&
62 (cd super &&
63 git submodule add ../none none &&
64 test_tick &&
65 git commit -m "none"
66 ) &&
67 git clone . recursivesuper &&
68 ( cd recursivesuper
69 git submodule add ../super super
73 test_expect_success 'submodule update detaching the HEAD ' '
74 (cd super/submodule &&
75 git reset --hard HEAD~1
76 ) &&
77 (cd super &&
78 (cd submodule &&
79 compare_head
80 ) &&
81 git submodule update submodule &&
82 cd submodule &&
83 ! compare_head
87 test_expect_success 'submodule update from subdirectory' '
88 (cd super/submodule &&
89 git reset --hard HEAD~1
90 ) &&
91 mkdir super/sub &&
92 (cd super/sub &&
93 (cd ../submodule &&
94 compare_head
95 ) &&
96 git submodule update ../submodule &&
97 cd ../submodule &&
98 ! compare_head
102 supersha1=$(git -C super rev-parse HEAD)
103 mergingsha1=$(git -C super/merging rev-parse HEAD)
104 nonesha1=$(git -C super/none rev-parse HEAD)
105 rebasingsha1=$(git -C super/rebasing rev-parse HEAD)
106 submodulesha1=$(git -C super/submodule rev-parse HEAD)
107 pwd=$(pwd)
109 cat <<EOF >expect
110 Submodule path '../super': checked out '$supersha1'
111 Submodule path '../super/merging': checked out '$mergingsha1'
112 Submodule path '../super/none': checked out '$nonesha1'
113 Submodule path '../super/rebasing': checked out '$rebasingsha1'
114 Submodule path '../super/submodule': checked out '$submodulesha1'
117 cat <<EOF >expect2
118 Submodule 'merging' ($pwd/merging) registered for path '../super/merging'
119 Submodule 'none' ($pwd/none) registered for path '../super/none'
120 Submodule 'rebasing' ($pwd/rebasing) registered for path '../super/rebasing'
121 Submodule 'submodule' ($pwd/submodule) registered for path '../super/submodule'
122 Cloning into '$pwd/recursivesuper/super/merging'...
123 done.
124 Cloning into '$pwd/recursivesuper/super/none'...
125 done.
126 Cloning into '$pwd/recursivesuper/super/rebasing'...
127 done.
128 Cloning into '$pwd/recursivesuper/super/submodule'...
129 done.
132 test_expect_success 'submodule update --init --recursive from subdirectory' '
133 git -C recursivesuper/super reset --hard HEAD^ &&
134 (cd recursivesuper &&
135 mkdir tmp &&
136 cd tmp &&
137 git submodule update --init --recursive ../super >../../actual 2>../../actual2
138 ) &&
139 test_cmp expect actual &&
140 test_cmp expect2 actual2
143 apos="'";
144 test_expect_success 'submodule update does not fetch already present commits' '
145 (cd submodule &&
146 echo line3 >> file &&
147 git add file &&
148 test_tick &&
149 git commit -m "upstream line3"
150 ) &&
151 (cd super/submodule &&
152 head=$(git rev-parse --verify HEAD) &&
153 echo "Submodule path ${apos}submodule$apos: checked out $apos$head$apos" > ../../expected &&
154 git reset --hard HEAD~1
155 ) &&
156 (cd super &&
157 git submodule update > ../actual 2> ../actual.err
158 ) &&
159 test_i18ncmp expected actual &&
160 ! test -s actual.err
163 test_expect_success 'submodule update should fail due to local changes' '
164 (cd super/submodule &&
165 git reset --hard HEAD~1 &&
166 echo "local change" > file
167 ) &&
168 (cd super &&
169 (cd submodule &&
170 compare_head
171 ) &&
172 test_must_fail git submodule update submodule
175 test_expect_success 'submodule update should throw away changes with --force ' '
176 (cd super &&
177 (cd submodule &&
178 compare_head
179 ) &&
180 git submodule update --force submodule &&
181 cd submodule &&
182 ! compare_head
186 test_expect_success 'submodule update --force forcibly checks out submodules' '
187 (cd super &&
188 (cd submodule &&
189 rm -f file
190 ) &&
191 git submodule update --force submodule &&
192 (cd submodule &&
193 test "$(git status -s file)" = ""
198 test_expect_success 'submodule update --remote should fetch upstream changes' '
199 (cd submodule &&
200 echo line4 >> file &&
201 git add file &&
202 test_tick &&
203 git commit -m "upstream line4"
204 ) &&
205 (cd super &&
206 git submodule update --remote --force submodule &&
207 cd submodule &&
208 test "$(git log -1 --oneline)" = "$(GIT_DIR=../../submodule/.git git log -1 --oneline)"
212 test_expect_success 'local config should override .gitmodules branch' '
213 (cd submodule &&
214 git checkout -b test-branch &&
215 echo line5 >> file &&
216 git add file &&
217 test_tick &&
218 git commit -m "upstream line5" &&
219 git checkout master
220 ) &&
221 (cd super &&
222 git config submodule.submodule.branch test-branch &&
223 git submodule update --remote --force submodule &&
224 cd submodule &&
225 test "$(git log -1 --oneline)" = "$(GIT_DIR=../../submodule/.git git log -1 --oneline test-branch)"
229 test_expect_success 'submodule update --rebase staying on master' '
230 (cd super/submodule &&
231 git checkout master
232 ) &&
233 (cd super &&
234 (cd submodule &&
235 compare_head
236 ) &&
237 git submodule update --rebase submodule &&
238 cd submodule &&
239 compare_head
243 test_expect_success 'submodule update --merge staying on master' '
244 (cd super/submodule &&
245 git reset --hard HEAD~1
246 ) &&
247 (cd super &&
248 (cd submodule &&
249 compare_head
250 ) &&
251 git submodule update --merge submodule &&
252 cd submodule &&
253 compare_head
257 test_expect_success 'submodule update - rebase in .git/config' '
258 (cd super &&
259 git config submodule.submodule.update rebase
260 ) &&
261 (cd super/submodule &&
262 git reset --hard HEAD~1
263 ) &&
264 (cd super &&
265 (cd submodule &&
266 compare_head
267 ) &&
268 git submodule update submodule &&
269 cd submodule &&
270 compare_head
274 test_expect_success 'submodule update - checkout in .git/config but --rebase given' '
275 (cd super &&
276 git config submodule.submodule.update checkout
277 ) &&
278 (cd super/submodule &&
279 git reset --hard HEAD~1
280 ) &&
281 (cd super &&
282 (cd submodule &&
283 compare_head
284 ) &&
285 git submodule update --rebase submodule &&
286 cd submodule &&
287 compare_head
291 test_expect_success 'submodule update - merge in .git/config' '
292 (cd super &&
293 git config submodule.submodule.update merge
294 ) &&
295 (cd super/submodule &&
296 git reset --hard HEAD~1
297 ) &&
298 (cd super &&
299 (cd submodule &&
300 compare_head
301 ) &&
302 git submodule update submodule &&
303 cd submodule &&
304 compare_head
308 test_expect_success 'submodule update - checkout in .git/config but --merge given' '
309 (cd super &&
310 git config submodule.submodule.update checkout
311 ) &&
312 (cd super/submodule &&
313 git reset --hard HEAD~1
314 ) &&
315 (cd super &&
316 (cd submodule &&
317 compare_head
318 ) &&
319 git submodule update --merge submodule &&
320 cd submodule &&
321 compare_head
325 test_expect_success 'submodule update - checkout in .git/config' '
326 (cd super &&
327 git config submodule.submodule.update checkout
328 ) &&
329 (cd super/submodule &&
330 git reset --hard HEAD^
331 ) &&
332 (cd super &&
333 (cd submodule &&
334 compare_head
335 ) &&
336 git submodule update submodule &&
337 cd submodule &&
338 ! compare_head
342 test_expect_success 'submodule update - command in .git/config' '
343 (cd super &&
344 git config submodule.submodule.update "!git checkout"
345 ) &&
346 (cd super/submodule &&
347 git reset --hard HEAD^
348 ) &&
349 (cd super &&
350 (cd submodule &&
351 compare_head
352 ) &&
353 git submodule update submodule &&
354 cd submodule &&
355 ! compare_head
359 cat << EOF >expect
360 Execution of 'false $submodulesha1' failed in submodule path 'submodule'
363 test_expect_success 'submodule update - command in .git/config catches failure' '
364 (cd super &&
365 git config submodule.submodule.update "!false"
366 ) &&
367 (cd super/submodule &&
368 git reset --hard $submodulesha1^
369 ) &&
370 (cd super &&
371 test_must_fail git submodule update submodule 2>../actual
372 ) &&
373 test_cmp actual expect
376 cat << EOF >expect
377 Execution of 'false $submodulesha1' failed in submodule path '../submodule'
380 test_expect_success 'submodule update - command in .git/config catches failure -- subdirectory' '
381 (cd super &&
382 git config submodule.submodule.update "!false"
383 ) &&
384 (cd super/submodule &&
385 git reset --hard $submodulesha1^
386 ) &&
387 (cd super &&
388 mkdir tmp && cd tmp &&
389 test_must_fail git submodule update ../submodule 2>../../actual
390 ) &&
391 test_cmp actual expect
394 cat << EOF >expect
395 Execution of 'false $submodulesha1' failed in submodule path '../super/submodule'
396 Failed to recurse into submodule path '../super'
399 test_expect_success 'recursive submodule update - command in .git/config catches failure -- subdirectory' '
400 (cd recursivesuper &&
401 git submodule update --remote super &&
402 git add super &&
403 git commit -m "update to latest to have more than one commit in submodules"
404 ) &&
405 git -C recursivesuper/super config submodule.submodule.update "!false" &&
406 git -C recursivesuper/super/submodule reset --hard $submodulesha1^ &&
407 (cd recursivesuper &&
408 mkdir -p tmp && cd tmp &&
409 test_must_fail git submodule update --recursive ../super 2>../../actual
410 ) &&
411 test_cmp actual expect
414 test_expect_success 'submodule init does not copy command into .git/config' '
415 (cd super &&
416 H=$(git ls-files -s submodule | cut -d" " -f2) &&
417 mkdir submodule1 &&
418 git update-index --add --cacheinfo 160000 $H submodule1 &&
419 git config -f .gitmodules submodule.submodule1.path submodule1 &&
420 git config -f .gitmodules submodule.submodule1.url ../submodule &&
421 git config -f .gitmodules submodule.submodule1.update !false &&
422 git submodule init submodule1 &&
423 echo "none" >expect &&
424 git config submodule.submodule1.update >actual &&
425 test_cmp expect actual
429 test_expect_success 'submodule init picks up rebase' '
430 (cd super &&
431 git config -f .gitmodules submodule.rebasing.update rebase &&
432 git submodule init rebasing &&
433 test "rebase" = "$(git config submodule.rebasing.update)"
437 test_expect_success 'submodule init picks up merge' '
438 (cd super &&
439 git config -f .gitmodules submodule.merging.update merge &&
440 git submodule init merging &&
441 test "merge" = "$(git config submodule.merging.update)"
445 test_expect_success 'submodule update --merge - ignores --merge for new submodules' '
446 (cd super &&
447 rm -rf submodule &&
448 git submodule update submodule &&
449 git status -s submodule >expect &&
450 rm -rf submodule &&
451 git submodule update --merge submodule &&
452 git status -s submodule >actual &&
453 test_cmp expect actual
457 test_expect_success 'submodule update --rebase - ignores --rebase for new submodules' '
458 (cd super &&
459 rm -rf submodule &&
460 git submodule update submodule &&
461 git status -s submodule >expect &&
462 rm -rf submodule &&
463 git submodule update --rebase submodule &&
464 git status -s submodule >actual &&
465 test_cmp expect actual
469 test_expect_success 'submodule update ignores update=merge config for new submodules' '
470 (cd super &&
471 rm -rf submodule &&
472 git submodule update submodule &&
473 git status -s submodule >expect &&
474 rm -rf submodule &&
475 git config submodule.submodule.update merge &&
476 git submodule update submodule &&
477 git status -s submodule >actual &&
478 git config --unset submodule.submodule.update &&
479 test_cmp expect actual
483 test_expect_success 'submodule update ignores update=rebase config for new submodules' '
484 (cd super &&
485 rm -rf submodule &&
486 git submodule update submodule &&
487 git status -s submodule >expect &&
488 rm -rf submodule &&
489 git config submodule.submodule.update rebase &&
490 git submodule update submodule &&
491 git status -s submodule >actual &&
492 git config --unset submodule.submodule.update &&
493 test_cmp expect actual
497 test_expect_success 'submodule init picks up update=none' '
498 (cd super &&
499 git config -f .gitmodules submodule.none.update none &&
500 git submodule init none &&
501 test "none" = "$(git config submodule.none.update)"
505 test_expect_success 'submodule update - update=none in .git/config' '
506 (cd super &&
507 git config submodule.submodule.update none &&
508 (cd submodule &&
509 git checkout master &&
510 compare_head
511 ) &&
512 git diff --raw | grep " submodule" &&
513 git submodule update &&
514 git diff --raw | grep " submodule" &&
515 (cd submodule &&
516 compare_head
517 ) &&
518 git config --unset submodule.submodule.update &&
519 git submodule update submodule
523 test_expect_success 'submodule update - update=none in .git/config but --checkout given' '
524 (cd super &&
525 git config submodule.submodule.update none &&
526 (cd submodule &&
527 git checkout master &&
528 compare_head
529 ) &&
530 git diff --raw | grep " submodule" &&
531 git submodule update --checkout &&
532 test_must_fail git diff --raw \| grep " submodule" &&
533 (cd submodule &&
534 test_must_fail compare_head
535 ) &&
536 git config --unset submodule.submodule.update
540 test_expect_success 'submodule update --init skips submodule with update=none' '
541 (cd super &&
542 git add .gitmodules &&
543 git commit -m ".gitmodules"
544 ) &&
545 git clone super cloned &&
546 (cd cloned &&
547 git submodule update --init &&
548 test -e submodule/.git &&
549 test_must_fail test -e none/.git
553 test_expect_success 'submodule update continues after checkout error' '
554 (cd super &&
555 git reset --hard HEAD &&
556 git submodule add ../submodule submodule2 &&
557 git submodule init &&
558 git commit -am "new_submodule" &&
559 (cd submodule2 &&
560 git rev-parse --verify HEAD >../expect
561 ) &&
562 (cd submodule &&
563 test_commit "update_submodule" file
564 ) &&
565 (cd submodule2 &&
566 test_commit "update_submodule2" file
567 ) &&
568 git add submodule &&
569 git add submodule2 &&
570 git commit -m "two_new_submodule_commits" &&
571 (cd submodule &&
572 echo "" > file
573 ) &&
574 git checkout HEAD^ &&
575 test_must_fail git submodule update &&
576 (cd submodule2 &&
577 git rev-parse --verify HEAD >../actual
578 ) &&
579 test_cmp expect actual
582 test_expect_success 'submodule update continues after recursive checkout error' '
583 (cd super &&
584 git reset --hard HEAD &&
585 git checkout master &&
586 git submodule update &&
587 (cd submodule &&
588 git submodule add ../submodule subsubmodule &&
589 git submodule init &&
590 git commit -m "new_subsubmodule"
591 ) &&
592 git add submodule &&
593 git commit -m "update_submodule" &&
594 (cd submodule &&
595 (cd subsubmodule &&
596 test_commit "update_subsubmodule" file
597 ) &&
598 git add subsubmodule &&
599 test_commit "update_submodule_again" file &&
600 (cd subsubmodule &&
601 test_commit "update_subsubmodule_again" file
602 ) &&
603 test_commit "update_submodule_again_again" file
604 ) &&
605 (cd submodule2 &&
606 git rev-parse --verify HEAD >../expect &&
607 test_commit "update_submodule2_again" file
608 ) &&
609 git add submodule &&
610 git add submodule2 &&
611 git commit -m "new_commits" &&
612 git checkout HEAD^ &&
613 (cd submodule &&
614 git checkout HEAD^ &&
615 (cd subsubmodule &&
616 echo "" > file
618 ) &&
619 test_must_fail git submodule update --recursive &&
620 (cd submodule2 &&
621 git rev-parse --verify HEAD >../actual
622 ) &&
623 test_cmp expect actual
627 test_expect_success 'submodule update exit immediately in case of merge conflict' '
628 (cd super &&
629 git checkout master &&
630 git reset --hard HEAD &&
631 (cd submodule &&
632 (cd subsubmodule &&
633 git reset --hard HEAD
635 ) &&
636 git submodule update --recursive &&
637 (cd submodule &&
638 test_commit "update_submodule_2" file
639 ) &&
640 (cd submodule2 &&
641 test_commit "update_submodule2_2" file
642 ) &&
643 git add submodule &&
644 git add submodule2 &&
645 git commit -m "two_new_submodule_commits" &&
646 (cd submodule &&
647 git checkout master &&
648 test_commit "conflict" file &&
649 echo "conflict" > file
650 ) &&
651 git checkout HEAD^ &&
652 (cd submodule2 &&
653 git rev-parse --verify HEAD >../expect
654 ) &&
655 git config submodule.submodule.update merge &&
656 test_must_fail git submodule update &&
657 (cd submodule2 &&
658 git rev-parse --verify HEAD >../actual
659 ) &&
660 test_cmp expect actual
664 test_expect_success 'submodule update exit immediately after recursive rebase error' '
665 (cd super &&
666 git checkout master &&
667 git reset --hard HEAD &&
668 (cd submodule &&
669 git reset --hard HEAD &&
670 git submodule update --recursive
671 ) &&
672 (cd submodule &&
673 test_commit "update_submodule_3" file
674 ) &&
675 (cd submodule2 &&
676 test_commit "update_submodule2_3" file
677 ) &&
678 git add submodule &&
679 git add submodule2 &&
680 git commit -m "two_new_submodule_commits" &&
681 (cd submodule &&
682 git checkout master &&
683 test_commit "conflict2" file &&
684 echo "conflict" > file
685 ) &&
686 git checkout HEAD^ &&
687 (cd submodule2 &&
688 git rev-parse --verify HEAD >../expect
689 ) &&
690 git config submodule.submodule.update rebase &&
691 test_must_fail git submodule update &&
692 (cd submodule2 &&
693 git rev-parse --verify HEAD >../actual
694 ) &&
695 test_cmp expect actual
699 test_expect_success 'add different submodules to the same path' '
700 (cd super &&
701 git submodule add ../submodule s1 &&
702 test_must_fail git submodule add ../merging s1
706 test_expect_success 'submodule add places git-dir in superprojects git-dir' '
707 (cd super &&
708 mkdir deeper &&
709 git submodule add ../submodule deeper/submodule &&
710 (cd deeper/submodule &&
711 git log > ../../expected
712 ) &&
713 (cd .git/modules/deeper/submodule &&
714 git log > ../../../../actual
715 ) &&
716 test_cmp actual expected
720 test_expect_success 'submodule update places git-dir in superprojects git-dir' '
721 (cd super &&
722 git commit -m "added submodule"
723 ) &&
724 git clone super super2 &&
725 (cd super2 &&
726 git submodule init deeper/submodule &&
727 git submodule update &&
728 (cd deeper/submodule &&
729 git log > ../../expected
730 ) &&
731 (cd .git/modules/deeper/submodule &&
732 git log > ../../../../actual
733 ) &&
734 test_cmp actual expected
738 test_expect_success 'submodule add places git-dir in superprojects git-dir recursive' '
739 (cd super2 &&
740 (cd deeper/submodule &&
741 git submodule add ../submodule subsubmodule &&
742 (cd subsubmodule &&
743 git log > ../../../expected
744 ) &&
745 git commit -m "added subsubmodule" &&
746 git push origin :
747 ) &&
748 (cd .git/modules/deeper/submodule/modules/subsubmodule &&
749 git log > ../../../../../actual
750 ) &&
751 git add deeper/submodule &&
752 git commit -m "update submodule" &&
753 git push origin : &&
754 test_cmp actual expected
758 test_expect_success 'submodule update places git-dir in superprojects git-dir recursive' '
759 mkdir super_update_r &&
760 (cd super_update_r &&
761 git init --bare
762 ) &&
763 mkdir subsuper_update_r &&
764 (cd subsuper_update_r &&
765 git init --bare
766 ) &&
767 mkdir subsubsuper_update_r &&
768 (cd subsubsuper_update_r &&
769 git init --bare
770 ) &&
771 git clone subsubsuper_update_r subsubsuper_update_r2 &&
772 (cd subsubsuper_update_r2 &&
773 test_commit "update_subsubsuper" file &&
774 git push origin master
775 ) &&
776 git clone subsuper_update_r subsuper_update_r2 &&
777 (cd subsuper_update_r2 &&
778 test_commit "update_subsuper" file &&
779 git submodule add ../subsubsuper_update_r subsubmodule &&
780 git commit -am "subsubmodule" &&
781 git push origin master
782 ) &&
783 git clone super_update_r super_update_r2 &&
784 (cd super_update_r2 &&
785 test_commit "update_super" file &&
786 git submodule add ../subsuper_update_r submodule &&
787 git commit -am "submodule" &&
788 git push origin master
789 ) &&
790 rm -rf super_update_r2 &&
791 git clone super_update_r super_update_r2 &&
792 (cd super_update_r2 &&
793 git submodule update --init --recursive >actual &&
794 test_i18ngrep "Submodule path .submodule/subsubmodule.: checked out" actual &&
795 (cd submodule/subsubmodule &&
796 git log > ../../expected
797 ) &&
798 (cd .git/modules/submodule/modules/subsubmodule
799 git log > ../../../../../actual
801 test_cmp actual expected
805 test_expect_success 'submodule add properly re-creates deeper level submodules' '
806 (cd super &&
807 git reset --hard master &&
808 rm -rf deeper/ &&
809 git submodule add --force ../submodule deeper/submodule
813 test_expect_success 'submodule update properly revives a moved submodule' '
814 (cd super &&
815 H=$(git rev-parse --short HEAD) &&
816 git commit -am "pre move" &&
817 H2=$(git rev-parse --short HEAD) &&
818 git status | sed "s/$H/XXX/" >expect &&
819 H=$(cd submodule2; git rev-parse HEAD) &&
820 git rm --cached submodule2 &&
821 rm -rf submodule2 &&
822 mkdir -p "moved/sub module" &&
823 git update-index --add --cacheinfo 160000 $H "moved/sub module" &&
824 git config -f .gitmodules submodule.submodule2.path "moved/sub module"
825 git commit -am "post move" &&
826 git submodule update &&
827 git status | sed "s/$H2/XXX/" >actual &&
828 test_cmp expect actual
832 test_expect_success SYMLINKS 'submodule update can handle symbolic links in pwd' '
833 mkdir -p linked/dir &&
834 ln -s linked/dir linkto &&
835 (cd linkto &&
836 git clone "$TRASH_DIRECTORY"/super_update_r2 super &&
837 (cd super &&
838 git submodule update --init --recursive
843 test_expect_success 'submodule update clone shallow submodule' '
844 git clone cloned super3 &&
845 pwd=$(pwd) &&
846 (cd super3 &&
847 sed -e "s#url = ../#url = file://$pwd/#" <.gitmodules >.gitmodules.tmp &&
848 mv -f .gitmodules.tmp .gitmodules &&
849 git submodule update --init --depth=3
850 (cd submodule &&
851 test 1 = $(git log --oneline | wc -l)
856 test_expect_success 'submodule update --recursive drops module name before recursing' '
857 (cd super2 &&
858 (cd deeper/submodule/subsubmodule &&
859 git checkout HEAD^
860 ) &&
861 git submodule update --recursive deeper/submodule >actual &&
862 test_i18ngrep "Submodule path .deeper/submodule/subsubmodule.: checked out" actual
866 test_expect_success 'submodule update can be run in parallel' '
867 (cd super2 &&
868 GIT_TRACE=$(pwd)/trace.out git submodule update --jobs 7 &&
869 grep "7 tasks" trace.out &&
870 git config submodule.fetchJobs 8 &&
871 GIT_TRACE=$(pwd)/trace.out git submodule update &&
872 grep "8 tasks" trace.out &&
873 GIT_TRACE=$(pwd)/trace.out git submodule update --jobs 9 &&
874 grep "9 tasks" trace.out
878 test_expect_success 'git clone passes the parallel jobs config on to submodules' '
879 test_when_finished "rm -rf super4" &&
880 GIT_TRACE=$(pwd)/trace.out git clone --recurse-submodules --jobs 7 . super4 &&
881 grep "7 tasks" trace.out &&
882 rm -rf super4 &&
883 git config --global submodule.fetchJobs 8 &&
884 GIT_TRACE=$(pwd)/trace.out git clone --recurse-submodules . super4 &&
885 grep "8 tasks" trace.out &&
886 rm -rf super4 &&
887 GIT_TRACE=$(pwd)/trace.out git clone --recurse-submodules --jobs 9 . super4 &&
888 grep "9 tasks" trace.out &&
889 rm -rf super4
892 test_done