git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] t5616: make robust to delta base change

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Jan 13, 2020, 20:28 UTC
Message-ID
<20200113202823.228062-1-jonathantanmy@google.com>
In-Reply-To
<20200113123857.3684632-19-sandals@crustytoothpaste.net>

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>
---
Thanks, brian, for bringing this to my attention. I think that the
change in the length of the object hash made the tree a delta and thus
require a lazy-fetch of its delta base. Can you see if this patch
eliminates the need for your t5616 patch?
In any case, this change passes at master and I think should go in
independent of brian's changes - if the delta base algorithm changes for
whatever reason, this is still needed to make the test more robust.
---
 t/t5616-partial-clone.sh | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index fea56cda6d..9a9178fd28 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -309,26 +309,36 @@ setup_triangle () {
 
 	printf "line %d\n" $(test_seq 1 100) >big-blob.txt &&
 
-	# Create a server with 2 commits: a commit with a big blob and a child
+	# Create a server with 2 commits: a commit with a big tree and a child
 	# commit with an incremental change. Also, create a partial clone
 	# client that only contains the first commit.
 	git init server &&
 	git -C server config --local uploadpack.allowfilter 1 &&
-	cp big-blob.txt server &&
-	git -C server add big-blob.txt &&
+	for i in $(test_seq 1 100)
+	do
+		echo "make the tree big" >server/file$i &&
+		git -C server add file$i
+	done &&
 	git -C server commit -m "initial" &&
 	git clone --bare --filter=tree:0 "file://$(pwd)/server" client &&
-	echo another line >>server/big-blob.txt &&
-	git -C server commit -am "append line to big blob" &&
+	echo another line >>server/file1 &&
+	git -C server commit -am "incremental change" &&
 
-	# Create a promisor remote that only contains the blob from the first
-	# commit, and set it as the promisor remote of client. Thus, whenever
-	# the client lazy fetches, the lazy fetch will succeed only if it is
-	# for this blob.
+	# Create a promisor remote that only contains the tree and blob from
+	# the first commit.
 	git init promisor-remote &&
+	git -C server config --local uploadpack.allowanysha1inwant 1 &&
+	TREE_HASH=$(git -C server rev-parse HEAD~1^{tree}) &&
+	git -C promisor-remote fetch --keep "file://$(pwd)/server" "$TREE_HASH" &&
+	git -C promisor-remote count-objects -v >object-count &&
+	test_i18ngrep "count: 0" object-count &&
+	test_i18ngrep "in-pack: 2" object-count &&
+
+	# Set it as the promisor remote of client. Thus, whenever
+	# the client lazy fetches, the lazy fetch will succeed only if it is
+	# for this tree or blob.
 	test_commit -C promisor-remote one && # so that ref advertisement is not empty
 	git -C promisor-remote config --local uploadpack.allowanysha1inwant 1 &&
-	git -C promisor-remote hash-object -w --stdin <big-blob.txt &&
 	git -C client remote set-url origin "file://$(pwd)/promisor-remote"
 }
 
@@ -341,14 +351,14 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas' '
 	setup_triangle &&
 
 	# Exercise to make sure it works. Git will not fetch anything from the
-	# promisor remote other than for the big blob (because it needs to
+	# promisor remote other than for the big tree (because it needs to
 	# resolve the delta).
 	GIT_TRACE_PACKET="$(pwd)/trace" git -C client \
 		fetch "file://$(pwd)/server" master &&
 
 	# Verify the assumption that the client needed to fetch the delta base
 	# to resolve the delta.
-	git hash-object big-blob.txt >hash &&
+	git -C server rev-parse HEAD~1^{tree} >hash &&
 	grep "want $(cat hash)" trace
 '
 
@@ -370,7 +380,7 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas, protocol v2' '
 
 	# Verify the assumption that the client needed to fetch the delta base
 	# to resolve the delta.
-	git hash-object big-blob.txt >hash &&
+	git -C server rev-parse HEAD~1^{tree} >hash &&
 	grep "want $(cat hash)" trace
 '
 
-- 
2.25.0.rc1.283.g88dfdc4193-goog
Previous: brian m. carlsonNext: brian m. carlson
Message 22 of 36 in “SHA-256 test fixes, part 8”
  1. 00/24 SHA-256 test fixes, part 8brian m. carlson, Jan 13, 2020
  2. 01/24 t/lib-pack: support SHA-256brian m. carlson, Jan 13, 2020
  3. 02/24 t3206: make hash size independentbrian m. carlson, Jan 13, 2020
  4. 08/24 t3404: remove SHA1 prerequisitebrian m. carlson, Jan 13, 2020
  5. 07/24 t3311: make test work with SHA-256brian m. carlson, Jan 13, 2020
  6. 11/24 t4211: make test hash independentbrian m. carlson, Jan 13, 2020
  7. 05/24 t3309: make test work with SHA-256brian m. carlson, Jan 13, 2020
  8. 12/24 t5302: make hash size independentbrian m. carlson, Jan 13, 2020
  9. 09/24 t4013: make test hash independentbrian m. carlson, Jan 13, 2020
  10. 03/24 t3305: annotate with SHA1 prerequisitebrian m. carlson, Jan 13, 2020
  11. 10/24 t4060: make test work with SHA-256brian m. carlson, Jan 13, 2020
  12. 06/24 t3310: make test work with SHA-256brian m. carlson, Jan 13, 2020
  13. 14/24 t5313: make test hash independentbrian m. carlson, Jan 13, 2020
  14. 21/24 t5703: switch tests to use test_oidbrian m. carlson, Jan 13, 2020
  15. 20/24 t5703: make test work with SHA-256brian m. carlson, Jan 13, 2020
  16. Eric SunshineJan 13, 2020
  17. brian m. carlsonJan 13, 2020
  18. 24/24 t6024: update for SHA-256brian m. carlson, Jan 13, 2020
  19. 23/24 t6006: make hash size independentbrian m. carlson, Jan 13, 2020
  20. 22/24 t6000: abstract away SHA-1-specific constantsbrian m. carlson, Jan 13, 2020
  21. 18/24 t5616: use correct filter syntaxbrian m. carlson, Jan 13, 2020
  22. t5616: make robust to delta base changeJonathan Tan, Jan 13, 2020
  23. brian m. carlsonJan 13, 2020
  24. brian m. carlsonJan 25, 2020
  25. 19/24 t5607: make hash size independentbrian m. carlson, Jan 13, 2020
  26. 16/24 t5515: make test hash independentbrian m. carlson, Jan 13, 2020
  27. 17/24 t5318: update for SHA-256brian m. carlson, Jan 13, 2020
  28. Eric SunshineJan 13, 2020
  29. brian m. carlsonJan 13, 2020
  30. 04/24 t3308: make test work with SHA-256brian m. carlson, Jan 13, 2020
  31. 15/24 t5321: make test hash independentbrian m. carlson, Jan 13, 2020
  32. 13/24 t5309: make test hash independentbrian m. carlson, Jan 13, 2020
  33. Eric SunshineJan 13, 2020
  34. brian m. carlsonJan 13, 2020
  35. Eric SunshineJan 13, 2020
  36. Johannes SchindelinJan 16, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.