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

[PATCH 15/20] t5530: compute results based on object length

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Dec 21, 2019, 19:49 UTC
Message-ID
<20191221194936.1346664-16-sandals@crustytoothpaste.net>
In-Reply-To
<20191221194936.1346664-1-sandals@crustytoothpaste.net>

Compute the various pkt-line values based on the length of the object IDs in use.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t5530-upload-pack-error.sh | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/t/t5530-upload-pack-error.sh b/t/t5530-upload-pack-error.sh
index a1d3031d40..4ce9a9f704 100755
--- a/t/t5530-upload-pack-error.sh
+++ b/t/t5530-upload-pack-error.sh
@@ -14,7 +14,7 @@ corrupt_repo () {
 }
 
 test_expect_success 'setup and corrupt repository' '
-
+	test_oid_init &&
 	echo file >file &&
 	git add file &&
 	git rev-parse :file &&
@@ -31,9 +31,10 @@ test_expect_success 'fsck fails' '
 '
 
 test_expect_success 'upload-pack fails due to error in pack-objects packing' '
-
-	printf "0032want %s\n00000009done\n0000" \
-		$(git rev-parse HEAD) >input &&
+	head=$(git rev-parse HEAD) &&
+	hexsz=$(test_oid hexsz) &&
+	printf "%04xwant %s\n00000009done\n0000" \
+		$(($hexsz + 10)) $head >input &&
 	test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
 	test_i18ngrep "unable to read" output.err &&
 	test_i18ngrep "pack-objects died" output.err
@@ -51,16 +52,17 @@ test_expect_success 'fsck fails' '
 '
 test_expect_success 'upload-pack fails due to error in rev-list' '
 
-	printf "0032want %s\n0034shallow %s00000009done\n0000" \
-		$(git rev-parse HEAD) $(git rev-parse HEAD^) >input &&
+	printf "%04xwant %s\n%04xshallow %s00000009done\n0000" \
+		$(($hexsz + 10)) $(git rev-parse HEAD) \
+		$(($hexsz + 12)) $(git rev-parse HEAD^) >input &&
 	test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
 	grep "bad tree object" output.err
 '
 
 test_expect_success 'upload-pack fails due to bad want (no object)' '
 
-	printf "0045want %s multi_ack_detailed\n00000009done\n0000" \
-		"deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" >input &&
+	printf "%04xwant %s multi_ack_detailed\n00000009done\n0000" \
+		$(($hexsz + 29)) $(test_oid deadbeef) >input &&
 	test_must_fail git upload-pack . <input >output 2>output.err &&
 	grep "not our ref" output.err &&
 	grep "ERR" output &&
@@ -70,8 +72,8 @@ test_expect_success 'upload-pack fails due to bad want (no object)' '
 test_expect_success 'upload-pack fails due to bad want (not tip)' '
 
 	oid=$(echo an object we have | git hash-object -w --stdin) &&
-	printf "0045want %s multi_ack_detailed\n00000009done\n0000" \
-		"$oid" >input &&
+	printf "%04xwant %s multi_ack_detailed\n00000009done\n0000" \
+		$(($hexsz + 29)) "$oid" >input &&
 	test_must_fail git upload-pack . <input >output 2>output.err &&
 	grep "not our ref" output.err &&
 	grep "ERR" output &&
@@ -80,8 +82,8 @@ test_expect_success 'upload-pack fails due to bad want (not tip)' '
 
 test_expect_success 'upload-pack fails due to error in pack-objects enumeration' '
 
-	printf "0032want %s\n00000009done\n0000" \
-		$(git rev-parse HEAD) >input &&
+	printf "%04xwant %s\n00000009done\n0000" \
+		$((hexsz + 10)) $(git rev-parse HEAD) >input &&
 	test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
 	grep "bad tree object" output.err &&
 	grep "pack-objects died" output.err
Previous: brian m. carlsonNext: brian m. carlson
Message 22 of 28 in “SHA-256 test fixes, part 7”
  1. 00/20 SHA-256 test fixes, part 7brian m. carlson, Dec 21, 2019
  2. 01/20 t4054: make hash-size independentbrian m. carlson, Dec 21, 2019
  3. 03/20 t4134: compute appropriate length constantbrian m. carlson, Dec 21, 2019
  4. 02/20 t4066: compute index line in diffsbrian m. carlson, Dec 21, 2019
  5. 04/20 t4200: make hash size independentbrian m. carlson, Dec 21, 2019
  6. 06/20 t4204: make hash size independentbrian m. carlson, Dec 21, 2019
  7. 08/20 t5318: update for SHA-256brian m. carlson, Dec 21, 2019
  8. 09/20 t5319: change invalid offset for SHA-256 compatibilitybrian m. carlson, Dec 21, 2019
  9. Derrick StoleeDec 26, 2019
  10. 07/20 t4300: abstract away SHA-1-specific constantsbrian m. carlson, Dec 21, 2019
  11. 11/20 t5324: make hash size independentbrian m. carlson, Dec 21, 2019
  12. 10/20 t5319: make test work with SHA-256brian m. carlson, Dec 21, 2019
  13. Eric SunshineDec 22, 2019
  14. brian m. carlsonDec 22, 2019
  15. Michael ClarkDec 23, 2019
  16. Derrick StoleeDec 26, 2019
  17. brian m. carlsonDec 27, 2019
  18. 13/20 t5510: make hash size independentbrian m. carlson, Dec 21, 2019
  19. 14/20 t5512: abstract away SHA-1-specific constantsbrian m. carlson, Dec 21, 2019
  20. 17/20 t5540: make hash size independentbrian m. carlson, Dec 21, 2019
  21. 12/20 t5504: make hash algorithm independentbrian m. carlson, Dec 21, 2019
  22. 15/20 t5530: compute results based on object lengthbrian m. carlson, Dec 21, 2019
  23. 19/20 t5601: switch into repository to hash objectbrian m. carlson, Dec 21, 2019
  24. 18/20 t5562: use $ZERO_OIDbrian m. carlson, Dec 21, 2019
  25. 20/20 t5604: make hash independentbrian m. carlson, Dec 21, 2019
  26. 16/20 t5537: make hash size independentbrian m. carlson, Dec 21, 2019
  27. 05/20 t4202: abstract away SHA-1-specific constantsbrian m. carlson, Dec 21, 2019
  28. Derrick StoleeDec 26, 2019

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.