Skip to content

Commit 8857657

Browse files
committed
Merge branch 'jt/t5616-robustify' into maint
Futureproofing a test not to depend on the current implementation detail. * jt/t5616-robustify: t5616: make robust to delta base change
2 parents 1f7609b + b54128b commit 8857657

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

t/t5616-partial-clone.sh

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -309,26 +309,36 @@ setup_triangle () {
309309

310310
printf "line %d\n" $(test_seq 1 100) >big-blob.txt &&
311311

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
313313
# commit with an incremental change. Also, create a partial clone
314314
# client that only contains the first commit.
315315
git init server &&
316316
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 &&
319322
git -C server commit -m "initial" &&
320323
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" &&
323326

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.
328329
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.
329340
test_commit -C promisor-remote one && # so that ref advertisement is not empty
330341
git -C promisor-remote config --local uploadpack.allowanysha1inwant 1 &&
331-
git -C promisor-remote hash-object -w --stdin <big-blob.txt &&
332342
git -C client remote set-url origin "file://$(pwd)/promisor-remote"
333343
}
334344

@@ -341,14 +351,14 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas' '
341351
setup_triangle &&
342352
343353
# 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
345355
# resolve the delta).
346356
GIT_TRACE_PACKET="$(pwd)/trace" git -C client \
347357
fetch "file://$(pwd)/server" master &&
348358
349359
# Verify the assumption that the client needed to fetch the delta base
350360
# to resolve the delta.
351-
git hash-object big-blob.txt >hash &&
361+
git -C server rev-parse HEAD~1^{tree} >hash &&
352362
grep "want $(cat hash)" trace
353363
'
354364

@@ -370,7 +380,7 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas, protocol v2' '
370380
371381
# Verify the assumption that the client needed to fetch the delta base
372382
# to resolve the delta.
373-
git hash-object big-blob.txt >hash &&
383+
git -C server rev-parse HEAD~1^{tree} >hash &&
374384
grep "want $(cat hash)" trace
375385
'
376386

0 commit comments

Comments
 (0)