@@ -161,6 +161,89 @@ test_expect_success 'fetch bundle list (file, creationToken)' '
161
161
done
162
162
'
163
163
164
+ test_expect_success ' clone with bundle.flag=forFetch creates fetch.bundleURI' '
165
+ test_when_finished rm -rf fetch-file-3 trace1.txt trace2.txt &&
166
+ cat >bundle-list <<-EOF &&
167
+ [bundle]
168
+ version = 1
169
+ mode = all
170
+ heuristic = creationToken
171
+ flag = forFetch
172
+
173
+ [bundle "bundle-1"]
174
+ uri = fetch-from/bundle-1.bundle
175
+ creationToken = 1
176
+ EOF
177
+
178
+ git clone --no-local --single-branch --branch=base \
179
+ --bundle-uri="file://$(pwd)/bundle-list" \
180
+ fetch-from fetch-file-3 &&
181
+
182
+ test_cmp_config -C fetch-file-3 "file://$(pwd)/bundle-list" fetch.bundleuri &&
183
+
184
+ # only received base ref from bundle-1
185
+ git -C fetch-file-3 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
186
+ cat >expect <<-\EOF &&
187
+ refs/bundles/base
188
+ EOF
189
+ test_cmp expect refs &&
190
+
191
+ cat >>bundle-list <<-EOF &&
192
+ [bundle "bundle-2"]
193
+ uri = fetch-from/bundle-2.bundle
194
+ creationToken = 2
195
+ EOF
196
+
197
+ GIT_TRACE2_EVENT="$(pwd)/trace1.txt" \
198
+ git -C fetch-file-3 fetch origin --no-tags \
199
+ refs/heads/left:refs/heads/left &&
200
+
201
+ # This fetch should copy two files: the list and bundle-2.
202
+ grep "region_enter.*bundle-uri.*copy_file" trace1.txt >copies &&
203
+
204
+ # NEEDSWORK: This should only copy two files, not three.
205
+ test_line_count = 3 copies &&
206
+
207
+ # received left from bundle-2
208
+ git -C fetch-file-3 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
209
+ cat >expect <<-\EOF &&
210
+ refs/bundles/base
211
+ refs/bundles/left
212
+ EOF
213
+ test_cmp expect refs &&
214
+
215
+ cat >>bundle-list <<-EOF &&
216
+ [bundle "bundle-3"]
217
+ uri = fetch-from/bundle-3.bundle
218
+ creationToken = 3
219
+
220
+ [bundle "bundle-4"]
221
+ uri = fetch-from/bundle-4.bundle
222
+ creationToken = 4
223
+ EOF
224
+
225
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
226
+ git -C fetch-file-3 fetch origin --no-tags \
227
+ refs/heads/right:refs/heads/right &&
228
+
229
+ # This fetch should copy three files: the list, bundle-4, and bundle-3.
230
+ grep "region_enter.*bundle-uri.*copy_file" trace2.txt >copies &&
231
+
232
+ # NEEDSWORK: this is re-downloading all the bundles!
233
+ test_line_count = 5 copies &&
234
+
235
+ # received right and merge from bundle-3 and bundle-4.
236
+ git -C fetch-file-3 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
237
+
238
+ # NEEDS WORK: why not refs/bundle/merge ???
239
+ cat >expect <<-\EOF &&
240
+ refs/bundles/base
241
+ refs/bundles/left
242
+ refs/bundles/right
243
+ EOF
244
+ test_cmp expect refs
245
+ '
246
+
164
247
# ########################################################################
165
248
# HTTP tests begin here
166
249
@@ -285,6 +368,89 @@ test_expect_success 'fetch bundle list (http, creationToken, incremental)' '
285
368
test_cmp expect refs
286
369
'
287
370
371
+ test_expect_success ' http clone with bundle.flag=forFetch creates fetch.bundleURI' '
372
+ test_when_finished rm -rf fetch-http-4 trace1.txt trace2.txt &&
373
+ cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
374
+ [bundle]
375
+ version = 1
376
+ mode = all
377
+ heuristic = creationToken
378
+ flag = forFetch
379
+
380
+ [bundle "bundle-1"]
381
+ uri = bundle-1.bundle
382
+ creationToken = 1
383
+ EOF
384
+
385
+ git clone --single-branch --branch=base \
386
+ --bundle-uri="$HTTPD_URL/bundle-list" \
387
+ "$HTTPD_URL/smart/fetch.git" fetch-http-4 &&
388
+
389
+ test_cmp_config -C fetch-http-4 "$HTTPD_URL/bundle-list" fetch.bundleuri &&
390
+
391
+ # only received base ref from bundle-1
392
+ git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
393
+ cat >expect <<-\EOF &&
394
+ refs/bundles/base
395
+ EOF
396
+ test_cmp expect refs &&
397
+
398
+ cat >>"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
399
+ [bundle "bundle-2"]
400
+ uri = bundle-2.bundle
401
+ creationToken = 2
402
+ EOF
403
+
404
+ GIT_TRACE2_EVENT="$(pwd)/trace1.txt" \
405
+ git -C fetch-http-4 fetch origin --no-tags \
406
+ refs/heads/left:refs/heads/left &&
407
+
408
+ # This fetch should copy two files: the list and bundle-2.
409
+ grep "region_enter.*bundle-uri.*download_https_uri_to_file" trace1.txt >copies &&
410
+
411
+ # NEEDSWORK: Currently downloading three copies instead of two!
412
+ test_line_count = 3 copies &&
413
+
414
+ # received left from bundle-2
415
+ git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
416
+ cat >expect <<-\EOF &&
417
+ refs/bundles/base
418
+ refs/bundles/left
419
+ EOF
420
+ test_cmp expect refs &&
421
+
422
+ cat >>"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
423
+ [bundle "bundle-3"]
424
+ uri = bundle-3.bundle
425
+ creationToken = 3
426
+
427
+ [bundle "bundle-4"]
428
+ uri = bundle-4.bundle
429
+ creationToken = 4
430
+ EOF
431
+
432
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
433
+ git -C fetch-http-4 fetch origin --no-tags \
434
+ refs/heads/right:refs/heads/right &&
435
+
436
+ # This fetch should copy three files: the list, bundle-4, and bundle-3.
437
+ grep "region_enter.*bundle-uri.*download_https_uri_to_file" trace2.txt >copies &&
438
+
439
+ # NEEDSWORK: this is re-downloading everything!
440
+ test_line_count = 5 copies &&
441
+
442
+ # received right and merge from bundle-3 and bundle-4.
443
+ git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
444
+
445
+ # NEEDSWORK: Why not refs/bundles/merge?
446
+ cat >expect <<-\EOF &&
447
+ refs/bundles/base
448
+ refs/bundles/left
449
+ refs/bundles/right
450
+ EOF
451
+ test_cmp expect refs
452
+ '
453
+
288
454
# Do not add tests here unless they use the HTTP server, as they will
289
455
# not run unless the HTTP dependencies exist.
290
456
0 commit comments