257
git -C backfill-revs rev-list --quiet --objects --missing=print HEAD >missing &&
258
test_line_count = 48 missing &&
259
260
- git -C backfill-revs backfill HEAD~2..HEAD &&
260
+ GIT_TRACE2_EVENT="$(pwd)/backfill-trace" git -C backfill-revs backfill HEAD~2..HEAD &&
261
262
- # 30 objects downloaded.
262
+ # 36 objects downloaded, 12 still missing
263
+ test_trace2_data promisor fetch_count 36 <backfill-trace &&
264
git -C backfill-revs rev-list --quiet --objects --missing=print HEAD >missing &&
264
- test_line_count = 18 missing
265
+ test_line_count = 12 missing
266
'
267
268
test_expect_success 'backfill with revisions over stdin' '
280
^HEAD~2
281
EOF
282
282
- git -C backfill-revs backfill --stdin <in &&
283
+ GIT_TRACE2_EVENT="$(pwd)/backfill-trace" git -C backfill-revs backfill --stdin <in &&
284
284
- # 30 objects downloaded.
285
+ # 36 objects downloaded, 12 still missing
286
+ test_trace2_data promisor fetch_count 36 <backfill-trace &&
287
git -C backfill-revs rev-list --quiet --objects --missing=print HEAD >missing &&
286
- test_line_count = 18 missing
288
+ test_line_count = 12 missing
289
'
290
291
test_expect_success 'backfill with prefix pathspec' '
400
test_line_count = 6 missing
401
'
402
403
+test_expect_success 'backfill range with include-edges enables fetch-free git-log' '
404
+ git clone --no-checkout --filter=blob:none \
405
+ --single-branch --branch=main \
406
+ "file://$(pwd)/srv.bare" backfill-log &&
407
+
408
+ # Backfill the range with default include edges.
409
+ git -C backfill-log backfill HEAD~2..HEAD &&
410
+
411
+ # git log -p needs edge blobs for the "before" side of
412
+ # diffs. With edge inclusion, all needed blobs are local.
413
+ GIT_TRACE2_EVENT="$(pwd)/log-trace" git \
414
+ -C backfill-log log -p HEAD~2..HEAD >log-output &&
415
+
416
+ # No promisor fetches should have been needed.
417
+ ! grep "fetch_count" log-trace
418
+'
419
+
420
+test_expect_success 'backfill range without include edges causes on-demand fetches in git-log' '
421
+ git clone --no-checkout --filter=blob:none \
422
+ --single-branch --branch=main \
423
+ "file://$(pwd)/srv.bare" backfill-log-no-bdy &&
424
+
425
+ # Backfill WITHOUT include edges -- file.3 v1 blobs are missing.
426
+ git -C backfill-log-no-bdy backfill --no-include-edges HEAD~2..HEAD &&
427
+
428
+ # git log -p HEAD~2..HEAD computes diff of commit 7 against
429
+ # commit 6. It needs file.3 v1 (the "before" side), which was
430
+ # not backfilled. This triggers on-demand promisor fetches.
431
+ GIT_TRACE2_EVENT="$(pwd)/log-no-bdy-trace" git \
432
+ -C backfill-log-no-bdy log -p HEAD~2..HEAD >log-output &&
433
+
434
+ grep "fetch_count" log-no-bdy-trace
435
+'
436
+
437
+test_expect_success 'backfill range enables fetch-free replay' '
438
+ # Create a repo with a branch to replay.
439
+ git init replay-src &&
440
+ (
441
+ cd replay-src &&
442
+ git config uploadpack.allowfilter 1 &&
443
+ git config uploadpack.allowanysha1inwant 1 &&
444
+ test_commit base &&
445
+ git checkout -b topic &&
446
+ test_commit topic-change &&
447
+ git checkout main &&
448
+ test_commit main-change
449
+ ) &&
450
+ git clone --bare --filter=blob:none \
451
+ "file://$(pwd)/replay-src" replay-dest.git &&
452
+
453
+ # Backfill the replay range: --onto main, replaying topic~1..topic.
454
+ # For replay, we need TARGET^! plus the range.
455
+ main_oid=$(git -C replay-dest.git rev-parse main) &&
456
+ topic_oid=$(git -C replay-dest.git rev-parse topic) &&
457
+ base_oid=$(git -C replay-dest.git rev-parse topic~1) &&
458
+ git -C replay-dest.git backfill \
459
+ "$main_oid^!" "$base_oid..$topic_oid" &&
460
+
461
+ # Now replay should complete without any promisor fetches.
462
+ GIT_TRACE2_EVENT="$(pwd)/replay-trace" git -C replay-dest.git \
463
+ replay --onto main topic~1..topic >replay-out &&
464
+
465
+ ! grep "fetch_count" replay-trace
466
+'
467
+
468
+test_expect_success 'backfill enables fetch-free merge' '
469
+ # Create a repo with two branches to merge.
470
+ git init merge-src &&
471
+ (
472
+ cd merge-src &&
473
+ git config uploadpack.allowfilter 1 &&
474
+ git config uploadpack.allowanysha1inwant 1 &&
475
+ test_commit merge-base &&
476
+ git checkout -b side &&
477
+ test_commit side-change &&
478
+ git checkout main &&
479
+ test_commit main-side-change
480
+ ) &&
481
+ git clone --filter=blob:none \
482
+ "file://$(pwd)/merge-src" merge-dest &&
483
+
484
+ # The clone checked out main, fetching its blobs.
485
+ # Backfill the three endpoint commits needed for merge.
486
+ main_oid=$(git -C merge-dest rev-parse origin/main) &&
487
+ side_oid=$(git -C merge-dest rev-parse origin/side) &&
488
+ mbase=$(git -C merge-dest merge-base origin/main origin/side) &&
489
+ git -C merge-dest backfill --no-include-edges \
490
+ "$main_oid^!" "$side_oid^!" "$mbase^!" &&
491
+
492
+ # Merge should complete without promisor fetches.
493
+ GIT_TRACE2_EVENT="$(pwd)/merge-trace" git -C merge-dest \
494
+ merge origin/side -m "test merge" &&
495
+
496
+ ! grep "fetch_count" merge-trace
497
+'
498
+
499
. "$TEST_DIRECTORY"/lib-httpd.sh
500
start_httpd
501