@@ -137,6 +137,89 @@ test_expect_success 'clone bundle list (file, creationToken)' '
137
137
done
138
138
'
139
139
140
+ test_expect_success ' clone with bundle.flag=forFetch creates fetch.bundleURI' '
141
+ test_when_finished rm -rf fetch-file-3 trace1.txt trace2.txt &&
142
+ cat >bundle-list <<-EOF &&
143
+ [bundle]
144
+ version = 1
145
+ mode = all
146
+ heuristic = creationToken
147
+ flag = forFetch
148
+
149
+ [bundle "bundle-1"]
150
+ uri = clone-from/bundle-1.bundle
151
+ creationToken = 1
152
+ EOF
153
+
154
+ git clone --no-local --single-branch --branch=base \
155
+ --bundle-uri="file://$(pwd)/bundle-list" \
156
+ clone-from fetch-file-3 &&
157
+
158
+ test_cmp_config -C fetch-file-3 "file://$(pwd)/bundle-list" fetch.bundleuri &&
159
+
160
+ # only received base ref from bundle-1
161
+ git -C fetch-file-3 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
162
+ cat >expect <<-\EOF &&
163
+ refs/bundles/base
164
+ EOF
165
+ test_cmp expect refs &&
166
+
167
+ cat >>bundle-list <<-EOF &&
168
+ [bundle "bundle-2"]
169
+ uri = clone-from/bundle-2.bundle
170
+ creationToken = 2
171
+ EOF
172
+
173
+ GIT_TRACE2_EVENT="$(pwd)/trace1.txt" \
174
+ git -C fetch-file-3 fetch origin --no-tags \
175
+ refs/heads/left:refs/heads/left &&
176
+
177
+ # This fetch should copy two files: the list and bundle-2.
178
+ grep "region_enter.*bundle-uri.*copy_file" trace1.txt >copies &&
179
+
180
+ # NEEDSWORK: This should only copy two files, not three.
181
+ test_line_count = 3 copies &&
182
+
183
+ # received left from bundle-2
184
+ git -C fetch-file-3 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
185
+ cat >expect <<-\EOF &&
186
+ refs/bundles/base
187
+ refs/bundles/left
188
+ EOF
189
+ test_cmp expect refs &&
190
+
191
+ cat >>bundle-list <<-EOF &&
192
+ [bundle "bundle-3"]
193
+ uri = clone-from/bundle-3.bundle
194
+ creationToken = 3
195
+
196
+ [bundle "bundle-4"]
197
+ uri = clone-from/bundle-4.bundle
198
+ creationToken = 4
199
+ EOF
200
+
201
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
202
+ git -C fetch-file-3 fetch origin --no-tags \
203
+ refs/heads/right:refs/heads/right &&
204
+
205
+ # This fetch should copy three files: the list, bundle-4, and bundle-3.
206
+ grep "region_enter.*bundle-uri.*copy_file" trace2.txt >copies &&
207
+
208
+ # NEEDSWORK: this is re-downloading all the bundles!
209
+ test_line_count = 5 copies &&
210
+
211
+ # received right and merge from bundle-3 and bundle-4.
212
+ git -C fetch-file-3 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
213
+
214
+ # NEEDS WORK: why not refs/bundle/merge ???
215
+ cat >expect <<-\EOF &&
216
+ refs/bundles/base
217
+ refs/bundles/left
218
+ refs/bundles/right
219
+ EOF
220
+ test_cmp expect refs
221
+ '
222
+
140
223
# ########################################################################
141
224
# HTTP tests begin here
142
225
@@ -248,6 +331,89 @@ test_expect_success 'fetch bundle list (http, creationToken, incremental)' '
248
331
test_cmp expect refs
249
332
'
250
333
334
+ test_expect_success ' http clone with bundle.flag=forFetch creates fetch.bundleURI' '
335
+ test_when_finished rm -rf fetch-http-4 trace1.txt trace2.txt &&
336
+ cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
337
+ [bundle]
338
+ version = 1
339
+ mode = all
340
+ heuristic = creationToken
341
+ flag = forFetch
342
+
343
+ [bundle "bundle-1"]
344
+ uri = bundle-1.bundle
345
+ creationToken = 1
346
+ EOF
347
+
348
+ git clone --single-branch --branch=base \
349
+ --bundle-uri="$HTTPD_URL/bundle-list" \
350
+ "$HTTPD_URL/smart/fetch.git" fetch-http-4 &&
351
+
352
+ test_cmp_config -C fetch-http-4 "$HTTPD_URL/bundle-list" fetch.bundleuri &&
353
+
354
+ # only received base ref from bundle-1
355
+ git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
356
+ cat >expect <<-\EOF &&
357
+ refs/bundles/base
358
+ EOF
359
+ test_cmp expect refs &&
360
+
361
+ cat >>"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
362
+ [bundle "bundle-2"]
363
+ uri = bundle-2.bundle
364
+ creationToken = 2
365
+ EOF
366
+
367
+ GIT_TRACE2_EVENT="$(pwd)/trace1.txt" \
368
+ git -C fetch-http-4 fetch origin --no-tags \
369
+ refs/heads/left:refs/heads/left &&
370
+
371
+ # This fetch should copy two files: the list and bundle-2.
372
+ grep "region_enter.*bundle-uri.*download_https_uri_to_file" trace1.txt >copies &&
373
+
374
+ # NEEDSWORK: Currently downloading three copies instead of two!
375
+ test_line_count = 3 copies &&
376
+
377
+ # received left from bundle-2
378
+ git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
379
+ cat >expect <<-\EOF &&
380
+ refs/bundles/base
381
+ refs/bundles/left
382
+ EOF
383
+ test_cmp expect refs &&
384
+
385
+ cat >>"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
386
+ [bundle "bundle-3"]
387
+ uri = bundle-3.bundle
388
+ creationToken = 3
389
+
390
+ [bundle "bundle-4"]
391
+ uri = bundle-4.bundle
392
+ creationToken = 4
393
+ EOF
394
+
395
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
396
+ git -C fetch-http-4 fetch origin --no-tags \
397
+ refs/heads/right:refs/heads/right &&
398
+
399
+ # This fetch should copy three files: the list, bundle-4, and bundle-3.
400
+ grep "region_enter.*bundle-uri.*download_https_uri_to_file" trace2.txt >copies &&
401
+
402
+ # NEEDSWORK: this is re-downloading everything!
403
+ test_line_count = 5 copies &&
404
+
405
+ # received right and merge from bundle-3 and bundle-4.
406
+ git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/*" >refs &&
407
+
408
+ # NEEDSWORK: Why not refs/bundles/merge?
409
+ cat >expect <<-\EOF &&
410
+ refs/bundles/base
411
+ refs/bundles/left
412
+ refs/bundles/right
413
+ EOF
414
+ test_cmp expect refs
415
+ '
416
+
251
417
# Do not add tests here unless they use the HTTP server, as they will
252
418
# not run unless the HTTP dependencies exist.
253
419
0 commit comments