@matheusbsbs / matheus-bagliano / commits / b54128bb0b
Fork 0

t5616: make robust to delta base change

Commit 6462d5eb9a ("fetch: remove fetch_if_missing=0", 2019-11-08) contains a test that relies on having to lazily fetch the delta base of a blob, but assumes that the tree being fetched (as part of the test) is sent as a non-delta object. This assumption may not hold in the future; for example, a change in the length of the object hash might result in the tree being sent as a delta instead. Make the test more robust by relying on having to lazily fetch the delta base of the tree instead, and by making no assumptions on whether the blobs are sent as delta or non-delta. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Jan 13, 2020 at 12:28 UTC b54128bb0be630c96e90e48fb011dc81f52a8601
1 file changed +23 -13
t/t5616-partial-clone.sh
+23 -13
@@ -309,26 +309,36 @@ setup_triangle () {
309
310 printf "line %d\n" $(test_seq 1 100) >big-blob.txt &&
311
312 - # Create a server with 2 commits: a commit with a big blob and a child
312 + # Create a server with 2 commits: a commit with a big tree and a child
313 # commit with an incremental change. Also, create a partial clone
314 # client that only contains the first commit.
315 git init server &&
316 git -C server config --local uploadpack.allowfilter 1 &&
317 - cp big-blob.txt server &&
318 - git -C server add big-blob.txt &&
317 + for i in $(test_seq 1 100)
318 + do
319 + echo "make the tree big" >server/file$i &&
320 + git -C server add file$i
321 + done &&
322 git -C server commit -m "initial" &&
323 git clone --bare --filter=tree:0 "file://$(pwd)/server" client &&
321 - echo another line >>server/big-blob.txt &&
322 - git -C server commit -am "append line to big blob" &&
324 + echo another line >>server/file1 &&
325 + git -C server commit -am "incremental change" &&
326
324 - # Create a promisor remote that only contains the blob from the first
325 - # commit, and set it as the promisor remote of client. Thus, whenever
326 - # the client lazy fetches, the lazy fetch will succeed only if it is
327 - # for this blob.
327 + # Create a promisor remote that only contains the tree and blob from
328 + # the first commit.
329 git init promisor-remote &&
330 + git -C server config --local uploadpack.allowanysha1inwant 1 &&
331 + TREE_HASH=$(git -C server rev-parse HEAD~1^{tree}) &&
332 + git -C promisor-remote fetch --keep "file://$(pwd)/server" "$TREE_HASH" &&
333 + git -C promisor-remote count-objects -v >object-count &&
334 + test_i18ngrep "count: 0" object-count &&
335 + test_i18ngrep "in-pack: 2" object-count &&
336 +
337 + # Set it as the promisor remote of client. Thus, whenever
338 + # the client lazy fetches, the lazy fetch will succeed only if it is
339 + # for this tree or blob.
340 test_commit -C promisor-remote one && # so that ref advertisement is not empty
341 git -C promisor-remote config --local uploadpack.allowanysha1inwant 1 &&
331 - git -C promisor-remote hash-object -w --stdin <big-blob.txt &&
342 git -C client remote set-url origin "file://$(pwd)/promisor-remote"
343 }
344
@@ -341,14 +351,14 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas' '
351 setup_triangle &&
352
353 # Exercise to make sure it works. Git will not fetch anything from the
344 - # promisor remote other than for the big blob (because it needs to
354 + # promisor remote other than for the big tree (because it needs to
355 # resolve the delta).
356 GIT_TRACE_PACKET="$(pwd)/trace" git -C client \
357 fetch "file://$(pwd)/server" master &&
358
359 # Verify the assumption that the client needed to fetch the delta base
360 # to resolve the delta.
351 - git hash-object big-blob.txt >hash &&
361 + git -C server rev-parse HEAD~1^{tree} >hash &&
362 grep "want $(cat hash)" trace
363 '
364
@@ -370,7 +380,7 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas, protocol v2' '
380
381 # Verify the assumption that the client needed to fetch the delta base
382 # to resolve the delta.
373 - git hash-object big-blob.txt >hash &&
383 + git -C server rev-parse HEAD~1^{tree} >hash &&
384 grep "want $(cat hash)" trace
385 '
386