3 test_description
='test fetching bundles with --bundle-uri'
7 test_expect_success
'fail to clone from non-existent file' '
8 test_when_finished rm -rf test &&
9 git clone --bundle-uri="$(pwd)/does-not-exist" . test 2>err &&
10 grep "failed to download bundle from URI" err
13 test_expect_success
'fail to clone from non-bundle file' '
14 test_when_finished rm -rf test &&
16 git clone --bundle-uri="$(pwd)/bogus" . test 2>err &&
17 grep "is not a bundle" err
20 test_expect_success
'create bundle' '
21 git init clone-from &&
22 git -C clone-from checkout -b topic &&
23 test_commit -C clone-from A &&
24 test_commit -C clone-from B &&
25 git -C clone-from bundle create B.bundle topic
28 test_expect_success
'clone with path bundle' '
29 git clone --bundle-uri="clone-from/B.bundle" \
30 clone-from clone-path &&
31 git -C clone-path rev-parse refs/bundles/topic >actual &&
32 git -C clone-from rev-parse topic >expect &&
33 test_cmp expect actual
36 test_expect_success
'clone with file:// bundle' '
37 git clone --bundle-uri="file://$(pwd)/clone-from/B.bundle" \
38 clone-from clone-file &&
39 git -C clone-file rev-parse refs/bundles/topic >actual &&
40 git -C clone-from rev-parse topic >expect &&
41 test_cmp expect actual
44 # To get interesting tests for bundle lists, we need to construct a
45 # somewhat-interesting commit history.
47 # ---------------- bundle-4
51 # ----|---|------- bundle-3
55 # ----|---|------- bundle-2
59 # ----|---|------- bundle-1
64 test_expect_success
'construct incremental bundle list' '
67 git checkout -b base &&
69 git checkout -b left &&
71 git checkout -b right base &&
73 git checkout -b merge left &&
74 git merge right -m "4" &&
76 git bundle create bundle-1.bundle base &&
77 git bundle create bundle-2.bundle base..left &&
78 git bundle create bundle-3.bundle base..right &&
79 git bundle create bundle-4.bundle merge --not left right
83 test_expect_success
'clone bundle list (file, no heuristic)' '
84 cat >bundle-list <<-EOF &&
90 uri = file://$(pwd)/clone-from/bundle-1.bundle
93 uri = file://$(pwd)/clone-from/bundle-2.bundle
96 uri = file://$(pwd)/clone-from/bundle-3.bundle
99 uri = file://$(pwd)/clone-from/bundle-4.bundle
102 git clone --bundle-uri="file://$(pwd)/bundle-list" \
103 clone-from clone-list-file 2>err &&
104 ! grep "Repository lacks these prerequisite commits" err &&
106 git -C clone-from for-each-ref --format="%(objectname)" >oids &&
107 git -C clone-list-file cat-file --batch-check <oids &&
109 git -C clone-list-file for-each-ref --format="%(refname)" >refs &&
110 grep "refs/bundles/" refs >actual &&
111 cat >expect <<-\EOF &&
117 test_cmp expect actual
120 test_expect_success
'clone bundle list (file, all mode, some failures)' '
121 cat >bundle-list <<-EOF &&
126 # Does not exist. Should be skipped.
128 uri = file://$(pwd)/clone-from/bundle-0.bundle
131 uri = file://$(pwd)/clone-from/bundle-1.bundle
134 uri = file://$(pwd)/clone-from/bundle-2.bundle
136 # No bundle-3 means bundle-4 will not apply.
139 uri = file://$(pwd)/clone-from/bundle-4.bundle
141 # Does not exist. Should be skipped.
143 uri = file://$(pwd)/clone-from/bundle-5.bundle
147 git clone --bundle-uri="file://$(pwd)/bundle-list" \
148 clone-from clone-all-some 2>err &&
149 ! grep "Repository lacks these prerequisite commits" err &&
150 ! grep "fatal" err &&
151 grep "warning: failed to download bundle from URI" err &&
153 git -C clone-from for-each-ref --format="%(objectname)" >oids &&
154 git -C clone-all-some cat-file --batch-check <oids &&
156 git -C clone-all-some for-each-ref --format="%(refname)" >refs &&
157 grep "refs/bundles/" refs >actual &&
158 cat >expect <<-\EOF &&
162 test_cmp expect actual
165 test_expect_success
'clone bundle list (file, all mode, all failures)' '
166 cat >bundle-list <<-EOF &&
171 # Does not exist. Should be skipped.
173 uri = file://$(pwd)/clone-from/bundle-0.bundle
175 # Does not exist. Should be skipped.
177 uri = file://$(pwd)/clone-from/bundle-5.bundle
180 git clone --bundle-uri="file://$(pwd)/bundle-list" \
181 clone-from clone-all-fail 2>err &&
182 ! grep "Repository lacks these prerequisite commits" err &&
183 ! grep "fatal" err &&
184 grep "warning: failed to download bundle from URI" err &&
186 git -C clone-from for-each-ref --format="%(objectname)" >oids &&
187 git -C clone-all-fail cat-file --batch-check <oids &&
189 git -C clone-all-fail for-each-ref --format="%(refname)" >refs &&
190 ! grep "refs/bundles/" refs
193 test_expect_success
'clone bundle list (file, any mode)' '
194 cat >bundle-list <<-EOF &&
199 # Does not exist. Should be skipped.
201 uri = file://$(pwd)/clone-from/bundle-0.bundle
204 uri = file://$(pwd)/clone-from/bundle-1.bundle
206 # Does not exist. Should be skipped.
208 uri = file://$(pwd)/clone-from/bundle-5.bundle
211 git clone --bundle-uri="file://$(pwd)/bundle-list" \
212 clone-from clone-any-file 2>err &&
213 ! grep "Repository lacks these prerequisite commits" err &&
215 git -C clone-from for-each-ref --format="%(objectname)" >oids &&
216 git -C clone-any-file cat-file --batch-check <oids &&
218 git -C clone-any-file for-each-ref --format="%(refname)" >refs &&
219 grep "refs/bundles/" refs >actual &&
220 cat >expect <<-\EOF &&
223 test_cmp expect actual
226 test_expect_success
'clone bundle list (file, any mode, all failures)' '
227 cat >bundle-list <<-EOF &&
232 # Does not exist. Should be skipped.
234 uri = $HTTPD_URL/bundle-0.bundle
236 # Does not exist. Should be skipped.
238 uri = $HTTPD_URL/bundle-5.bundle
241 git clone --bundle-uri="file://$(pwd)/bundle-list" \
242 clone-from clone-any-fail 2>err &&
243 ! grep "fatal" err &&
244 grep "warning: failed to download bundle from URI" err &&
246 git -C clone-from for-each-ref --format="%(objectname)" >oids &&
247 git -C clone-any-fail cat-file --batch-check <oids &&
249 git -C clone-any-fail for-each-ref --format="%(refname)" >refs &&
250 ! grep "refs/bundles/" refs
253 #########################################################################
254 # HTTP tests begin here
256 .
"$TEST_DIRECTORY"/lib-httpd.sh
259 test_expect_success
'fail to fetch from non-existent HTTP URL' '
260 test_when_finished rm -rf test &&
261 git clone --bundle-uri="$HTTPD_URL/does-not-exist" . test 2>err &&
262 grep "failed to download bundle from URI" err
265 test_expect_success
'fail to fetch from non-bundle HTTP URL' '
266 test_when_finished rm -rf test &&
267 echo bogus >"$HTTPD_DOCUMENT_ROOT_PATH/bogus" &&
268 git clone --bundle-uri="$HTTPD_URL/bogus" . test 2>err &&
269 grep "is not a bundle" err
272 test_expect_success
'clone HTTP bundle' '
273 cp clone-from/B.bundle "$HTTPD_DOCUMENT_ROOT_PATH/B.bundle" &&
275 git clone --no-local --mirror clone-from \
276 "$HTTPD_DOCUMENT_ROOT_PATH/fetch.git" &&
278 git clone --bundle-uri="$HTTPD_URL/B.bundle" \
279 "$HTTPD_URL/smart/fetch.git" clone-http &&
280 git -C clone-http rev-parse refs/bundles/topic >actual &&
281 git -C clone-from rev-parse topic >expect &&
282 test_cmp expect actual &&
284 test_config -C clone-http log.excludedecoration refs/bundle/
287 test_expect_success
'clone bundle list (HTTP, no heuristic)' '
288 test_when_finished rm -f trace*.txt &&
290 cp clone-from/bundle-*.bundle "$HTTPD_DOCUMENT_ROOT_PATH/" &&
291 cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
297 uri = $HTTPD_URL/bundle-1.bundle
300 uri = $HTTPD_URL/bundle-2.bundle
303 uri = $HTTPD_URL/bundle-3.bundle
306 uri = $HTTPD_URL/bundle-4.bundle
309 GIT_TRACE2_EVENT="$(pwd)/trace-clone.txt" \
310 git clone --bundle-uri="$HTTPD_URL/bundle-list" \
311 clone-from clone-list-http 2>err &&
312 ! grep "Repository lacks these prerequisite commits" err &&
314 git -C clone-from for-each-ref --format="%(objectname)" >oids &&
315 git -C clone-list-http cat-file --batch-check <oids &&
317 cat >expect <<-EOF &&
318 $HTTPD_URL/bundle-1.bundle
319 $HTTPD_URL/bundle-2.bundle
320 $HTTPD_URL/bundle-3.bundle
321 $HTTPD_URL/bundle-4.bundle
322 $HTTPD_URL/bundle-list
325 # Sort the list, since the order is not well-defined
326 # without a heuristic.
327 test_remote_https_urls <trace-clone.txt | sort >actual &&
328 test_cmp expect actual
331 test_expect_success
'clone bundle list (HTTP, any mode)' '
332 cp clone-from/bundle-*.bundle "$HTTPD_DOCUMENT_ROOT_PATH/" &&
333 cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
338 # Does not exist. Should be skipped.
340 uri = $HTTPD_URL/bundle-0.bundle
343 uri = $HTTPD_URL/bundle-1.bundle
345 # Does not exist. Should be skipped.
347 uri = $HTTPD_URL/bundle-5.bundle
350 git clone --bundle-uri="$HTTPD_URL/bundle-list" \
351 clone-from clone-any-http 2>err &&
352 ! grep "fatal" err &&
353 grep "warning: failed to download bundle from URI" err &&
355 git -C clone-from for-each-ref --format="%(objectname)" >oids &&
356 git -C clone-any-http cat-file --batch-check <oids &&
358 git -C clone-list-file for-each-ref --format="%(refname)" >refs &&
359 grep "refs/bundles/" refs >actual &&
360 cat >expect <<-\EOF &&
366 test_cmp expect actual
369 test_expect_success
'clone bundle list (http, creationToken)' '
370 test_when_finished rm -f trace*.txt &&
372 cp clone-from/bundle-*.bundle "$HTTPD_DOCUMENT_ROOT_PATH/" &&
373 cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
377 heuristic = creationToken
380 uri = bundle-1.bundle
384 uri = bundle-2.bundle
388 uri = bundle-3.bundle
392 uri = bundle-4.bundle
396 GIT_TRACE2_EVENT="$(pwd)/trace-clone.txt" git \
397 clone --bundle-uri="$HTTPD_URL/bundle-list" \
398 "$HTTPD_URL/smart/fetch.git" clone-list-http-2 &&
400 git -C clone-from for-each-ref --format="%(objectname)" >oids &&
401 git -C clone-list-http-2 cat-file --batch-check <oids &&
403 cat >expect <<-EOF &&
404 $HTTPD_URL/bundle-list
405 $HTTPD_URL/bundle-4.bundle
406 $HTTPD_URL/bundle-3.bundle
407 $HTTPD_URL/bundle-2.bundle
408 $HTTPD_URL/bundle-1.bundle
411 test_remote_https_urls <trace-clone.txt >actual &&
412 test_cmp expect actual
415 test_expect_success
'clone incomplete bundle list (http, creationToken)' '
416 test_when_finished rm -f trace*.txt &&
418 cp clone-from/bundle-*.bundle "$HTTPD_DOCUMENT_ROOT_PATH/" &&
419 cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
423 heuristic = creationToken
426 uri = bundle-1.bundle
430 GIT_TRACE2_EVENT=$(pwd)/trace-clone.txt \
431 git clone --bundle-uri="$HTTPD_URL/bundle-list" \
432 --single-branch --branch=base --no-tags \
433 "$HTTPD_URL/smart/fetch.git" clone-token-http &&
435 test_cmp_config -C clone-token-http "$HTTPD_URL/bundle-list" fetch.bundleuri &&
436 test_cmp_config -C clone-token-http 1 fetch.bundlecreationtoken &&
438 cat >expect <<-EOF &&
439 $HTTPD_URL/bundle-list
440 $HTTPD_URL/bundle-1.bundle
443 test_remote_https_urls <trace-clone.txt >actual &&
444 test_cmp expect actual &&
446 # We now have only one bundle ref.
447 git -C clone-token-http for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
448 cat >expect <<-\EOF &&
451 test_cmp expect refs &&
453 # Add remaining bundles, exercising the "deepening" strategy
454 # for downloading via the creationToken heurisitc.
455 cat >>"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
457 uri = bundle-2.bundle
461 uri = bundle-3.bundle
465 uri = bundle-4.bundle
469 GIT_TRACE2_EVENT="$(pwd)/trace1.txt" \
470 git -C clone-token-http fetch origin --no-tags \
471 refs/heads/merge:refs/heads/merge &&
472 test_cmp_config -C clone-token-http 4 fetch.bundlecreationtoken &&
474 cat >expect <<-EOF &&
475 $HTTPD_URL/bundle-list
476 $HTTPD_URL/bundle-4.bundle
477 $HTTPD_URL/bundle-3.bundle
478 $HTTPD_URL/bundle-2.bundle
481 test_remote_https_urls <trace1.txt >actual &&
482 test_cmp expect actual &&
484 # We now have all bundle refs.
485 git -C clone-token-http for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
487 cat >expect <<-\EOF &&
496 test_expect_success
'http clone with bundle.heuristic creates fetch.bundleURI' '
497 test_when_finished rm -rf fetch-http-4 trace*.txt &&
499 cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
503 heuristic = creationToken
506 uri = bundle-1.bundle
510 GIT_TRACE2_EVENT="$(pwd)/trace-clone.txt" \
511 git clone --single-branch --branch=base \
512 --bundle-uri="$HTTPD_URL/bundle-list" \
513 "$HTTPD_URL/smart/fetch.git" fetch-http-4 &&
515 test_cmp_config -C fetch-http-4 "$HTTPD_URL/bundle-list" fetch.bundleuri &&
516 test_cmp_config -C fetch-http-4 1 fetch.bundlecreationtoken &&
518 cat >expect <<-EOF &&
519 $HTTPD_URL/bundle-list
520 $HTTPD_URL/bundle-1.bundle
523 test_remote_https_urls <trace-clone.txt >actual &&
524 test_cmp expect actual &&
526 # only received base ref from bundle-1
527 git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
528 cat >expect <<-\EOF &&
531 test_cmp expect refs &&
533 cat >>"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
535 uri = bundle-2.bundle
539 # Fetch the objects for bundle-2 _and_ bundle-3.
540 GIT_TRACE2_EVENT="$(pwd)/trace1.txt" \
541 git -C fetch-http-4 fetch origin --no-tags \
542 refs/heads/left:refs/heads/left \
543 refs/heads/right:refs/heads/right &&
544 test_cmp_config -C fetch-http-4 2 fetch.bundlecreationtoken &&
546 cat >expect <<-EOF &&
547 $HTTPD_URL/bundle-list
548 $HTTPD_URL/bundle-2.bundle
551 test_remote_https_urls <trace1.txt >actual &&
552 test_cmp expect actual &&
554 # received left from bundle-2
555 git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
556 cat >expect <<-\EOF &&
560 test_cmp expect refs &&
563 GIT_TRACE2_EVENT="$(pwd)/trace1b.txt" \
564 git -C fetch-http-4 fetch origin --no-tags \
565 refs/heads/left:refs/heads/left \
566 refs/heads/right:refs/heads/right &&
568 cat >expect <<-EOF &&
569 $HTTPD_URL/bundle-list
571 test_remote_https_urls <trace1b.txt >actual &&
572 test_cmp expect actual &&
574 cat >>"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
576 uri = bundle-3.bundle
580 uri = bundle-4.bundle
584 # This fetch should skip bundle-3.bundle, since its objects are
585 # already local (we have the requisite commits for bundle-4.bundle).
586 GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
587 git -C fetch-http-4 fetch origin --no-tags \
588 refs/heads/merge:refs/heads/merge &&
589 test_cmp_config -C fetch-http-4 4 fetch.bundlecreationtoken &&
591 cat >expect <<-EOF &&
592 $HTTPD_URL/bundle-list
593 $HTTPD_URL/bundle-4.bundle
596 test_remote_https_urls <trace2.txt >actual &&
597 test_cmp expect actual &&
599 # received merge ref from bundle-4, but right is missing
600 # because we did not download bundle-3.
601 git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
603 cat >expect <<-\EOF &&
608 test_cmp expect refs &&
611 GIT_TRACE2_EVENT="$(pwd)/trace2b.txt" \
612 git -C fetch-http-4 fetch origin &&
614 cat >expect <<-EOF &&
615 $HTTPD_URL/bundle-list
617 test_remote_https_urls <trace2b.txt >actual &&
618 test_cmp expect actual
621 test_expect_success
'creationToken heuristic with failed downloads (clone)' '
622 test_when_finished rm -rf download-* trace*.txt &&
624 # Case 1: base bundle does not exist, nothing can unbundle
625 cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
629 heuristic = creationToken
636 uri = bundle-2.bundle
640 uri = bundle-3.bundle
644 uri = bundle-4.bundle
648 GIT_TRACE2_EVENT="$(pwd)/trace-clone-1.txt" \
649 git clone --single-branch --branch=base \
650 --bundle-uri="$HTTPD_URL/bundle-list" \
651 "$HTTPD_URL/smart/fetch.git" download-1 &&
653 # Bundle failure does not set these configs.
654 test_must_fail git -C download-1 config fetch.bundleuri &&
655 test_must_fail git -C download-1 config fetch.bundlecreationtoken &&
657 cat >expect <<-EOF &&
658 $HTTPD_URL/bundle-list
659 $HTTPD_URL/bundle-4.bundle
660 $HTTPD_URL/bundle-3.bundle
661 $HTTPD_URL/bundle-2.bundle
662 $HTTPD_URL/fake.bundle
664 test_remote_https_urls <trace-clone-1.txt >actual &&
665 test_cmp expect actual &&
667 # All bundles failed to unbundle
668 git -C download-1 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
669 test_must_be_empty refs &&
671 # Case 2: middle bundle does not exist, only two bundles can unbundle
672 cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
676 heuristic = creationToken
679 uri = bundle-1.bundle
687 uri = bundle-3.bundle
691 uri = bundle-4.bundle
695 GIT_TRACE2_EVENT="$(pwd)/trace-clone-2.txt" \
696 git clone --single-branch --branch=base \
697 --bundle-uri="$HTTPD_URL/bundle-list" \
698 "$HTTPD_URL/smart/fetch.git" download-2 &&
700 # Bundle failure does not set these configs.
701 test_must_fail git -C download-2 config fetch.bundleuri &&
702 test_must_fail git -C download-2 config fetch.bundlecreationtoken &&
704 cat >expect <<-EOF &&
705 $HTTPD_URL/bundle-list
706 $HTTPD_URL/bundle-4.bundle
707 $HTTPD_URL/bundle-3.bundle
708 $HTTPD_URL/fake.bundle
709 $HTTPD_URL/bundle-1.bundle
711 test_remote_https_urls <trace-clone-2.txt >actual &&
712 test_cmp expect actual &&
714 # bundle-1 and bundle-3 could unbundle, but bundle-4 could not
715 git -C download-2 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
716 cat >expect <<-EOF &&
720 test_cmp expect refs &&
722 # Case 3: top bundle does not exist, rest unbundle fine.
723 cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
727 heuristic = creationToken
730 uri = bundle-1.bundle
734 uri = bundle-2.bundle
738 uri = bundle-3.bundle
746 GIT_TRACE2_EVENT="$(pwd)/trace-clone-3.txt" \
747 git clone --single-branch --branch=base \
748 --bundle-uri="$HTTPD_URL/bundle-list" \
749 "$HTTPD_URL/smart/fetch.git" download-3 &&
751 # As long as we have continguous successful downloads,
752 # we _do_ set these configs.
753 test_cmp_config -C download-3 "$HTTPD_URL/bundle-list" fetch.bundleuri &&
754 test_cmp_config -C download-3 3 fetch.bundlecreationtoken &&
756 cat >expect <<-EOF &&
757 $HTTPD_URL/bundle-list
758 $HTTPD_URL/fake.bundle
759 $HTTPD_URL/bundle-3.bundle
760 $HTTPD_URL/bundle-2.bundle
761 $HTTPD_URL/bundle-1.bundle
763 test_remote_https_urls <trace-clone-3.txt >actual &&
764 test_cmp expect actual &&
766 # fake.bundle did not unbundle, but the others did.
767 git -C download-3 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
768 cat >expect <<-EOF &&
776 # Expand the bundle list to include other interesting shapes, specifically
777 # interesting for use when fetching from a previous state.
779 # ---------------- bundle-7
782 # ---/--|--\------ bundle-6
784 # --|---|---|----- bundle-4
787 # --|-|---|/------ bundle-3 (the client will be caught up to this point.)
789 # ---\|---|------- bundle-2
791 # ----|---|------- bundle-1
796 test_expect_success
'expand incremental bundle list' '
799 git checkout -b lefter left &&
801 git checkout -b righter right &&
803 git checkout -b top lefter &&
804 git merge -m "7" merge righter &&
806 git bundle create bundle-6.bundle lefter righter --not left right &&
807 git bundle create bundle-7.bundle top --not lefter merge righter &&
809 cp bundle-*.bundle "$HTTPD_DOCUMENT_ROOT_PATH/"
811 git -C "$HTTPD_DOCUMENT_ROOT_PATH/fetch.git" fetch origin +refs/heads/*:refs/heads/*
814 test_expect_success
'creationToken heuristic with failed downloads (fetch)' '
815 test_when_finished rm -rf download-* trace*.txt &&
817 cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
821 heuristic = creationToken
824 uri = bundle-1.bundle
828 uri = bundle-2.bundle
832 uri = bundle-3.bundle
836 git clone --single-branch --branch=left \
837 --bundle-uri="$HTTPD_URL/bundle-list" \
838 "$HTTPD_URL/smart/fetch.git" fetch-base &&
839 test_cmp_config -C fetch-base "$HTTPD_URL/bundle-list" fetch.bundleURI &&
840 test_cmp_config -C fetch-base 3 fetch.bundleCreationToken &&
842 # Case 1: all bundles exist: successful unbundling of all bundles
843 cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
847 heuristic = creationToken
850 uri = bundle-1.bundle
854 uri = bundle-2.bundle
858 uri = bundle-3.bundle
862 uri = bundle-4.bundle
866 uri = bundle-6.bundle
870 uri = bundle-7.bundle
874 cp -r fetch-base fetch-1 &&
875 GIT_TRACE2_EVENT="$(pwd)/trace-fetch-1.txt" \
876 git -C fetch-1 fetch origin &&
877 test_cmp_config -C fetch-1 7 fetch.bundlecreationtoken &&
879 cat >expect <<-EOF &&
880 $HTTPD_URL/bundle-list
881 $HTTPD_URL/bundle-7.bundle
882 $HTTPD_URL/bundle-6.bundle
883 $HTTPD_URL/bundle-4.bundle
885 test_remote_https_urls <trace-fetch-1.txt >actual &&
886 test_cmp expect actual &&
888 # Check which bundles have unbundled by refs
889 git -C fetch-1 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
890 cat >expect <<-EOF &&
899 test_cmp expect refs &&
901 # Case 2: middle bundle does not exist, only bundle-4 can unbundle
902 cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
906 heuristic = creationToken
909 uri = bundle-1.bundle
913 uri = bundle-2.bundle
917 uri = bundle-3.bundle
921 uri = bundle-4.bundle
929 uri = bundle-7.bundle
933 cp -r fetch-base fetch-2 &&
934 GIT_TRACE2_EVENT="$(pwd)/trace-fetch-2.txt" \
935 git -C fetch-2 fetch origin &&
937 # Since bundle-7 fails to unbundle, do not update creation token.
938 test_cmp_config -C fetch-2 3 fetch.bundlecreationtoken &&
940 cat >expect <<-EOF &&
941 $HTTPD_URL/bundle-list
942 $HTTPD_URL/bundle-7.bundle
943 $HTTPD_URL/fake.bundle
944 $HTTPD_URL/bundle-4.bundle
946 test_remote_https_urls <trace-fetch-2.txt >actual &&
947 test_cmp expect actual &&
949 # Check which bundles have unbundled by refs
950 git -C fetch-2 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
951 cat >expect <<-EOF &&
957 test_cmp expect refs &&
959 # Case 3: top bundle does not exist, rest unbundle fine.
960 cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
964 heuristic = creationToken
967 uri = bundle-1.bundle
971 uri = bundle-2.bundle
975 uri = bundle-3.bundle
979 uri = bundle-4.bundle
983 uri = bundle-6.bundle
991 cp -r fetch-base fetch-3 &&
992 GIT_TRACE2_EVENT="$(pwd)/trace-fetch-3.txt" \
993 git -C fetch-3 fetch origin &&
995 # As long as we have continguous successful downloads,
996 # we _do_ set the maximum creation token.
997 test_cmp_config -C fetch-3 6 fetch.bundlecreationtoken &&
999 # NOTE: the fetch skips bundle-4 since bundle-6 successfully
1000 # unbundles itself and bundle-7 failed to download.
1001 cat >expect <<-EOF &&
1002 $HTTPD_URL/bundle-list
1003 $HTTPD_URL/fake.bundle
1004 $HTTPD_URL/bundle-6.bundle
1006 test_remote_https_urls <trace-fetch-3.txt >actual &&
1007 test_cmp expect actual &&
1009 # Check which bundles have unbundled by refs
1010 git -C fetch-3 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
1011 cat >expect <<-EOF &&
1016 refs/bundles/righter
1018 test_cmp expect refs
1021 # Do not add tests here unless they use the HTTP server, as they will
1022 # not run unless the HTTP dependencies exist.