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

[PATCH 2/5] t5300: check that we produced expected number of deltas

From
Jeff King <peff@peff.net>
Date
May 1, 2021, 14:03 UTC
Message-ID
<YI1frTcgfGb6GA3N@coredump.intra.peff.net>
In-Reply-To
<YI1fbERSuS7Y3LKh@coredump.intra.peff.net>

We pack a set of objects both with and without --window=0, assuming that the 0-length window will cause us not to produce any deltas. Let's confirm that this is the case.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t5300-pack-object.sh | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index 1e10c832a6..887e2d8d88 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -34,8 +34,22 @@ test_expect_success 'setup' '
 	} >expect
 '
 
+# usage: check_deltas <stderr_from_pack_objects> <cmp_op> <nr_deltas>
+# e.g.: check_deltas stderr -gt 0
+check_deltas() {
+	deltas=$(perl -lne '/delta (\d+)/ and print $1' "$1") &&
+	shift &&
+	if ! test "$deltas" "$@"
+	then
+		echo >&2 "unexpected number of deltas (compared $delta $*)"
+		return 1
+	fi
+}
+
 test_expect_success 'pack without delta' '
-	packname_1=$(git pack-objects --window=0 test-1 <obj-list)
+	packname_1=$(git pack-objects --progress --window=0 test-1 \
+			<obj-list 2>stderr) &&
+	check_deltas stderr = 0
 '
 
 test_expect_success 'pack-objects with bogus arguments' '
@@ -62,15 +76,18 @@ test_expect_success 'unpack without delta' '
 '
 
 test_expect_success 'pack with REF_DELTA' '
-	packname_2=$(git pack-objects test-2 <obj-list)
+	packname_2=$(git pack-objects --progress test-2 <obj-list 2>stderr) &&
+	check_deltas stderr -gt 0
 '
 
 test_expect_success 'unpack with REF_DELTA' '
 	check_unpack test-2-${packname_2}
 '
 
 test_expect_success 'pack with OFS_DELTA' '
-	packname_3=$(git pack-objects --delta-base-offset test-3 <obj-list)
+	packname_3=$(git pack-objects --progress --delta-base-offset test-3 \
+			<obj-list 2>stderr) &&
+	check_deltas stderr -gt 0
 '
 
 test_expect_success 'unpack with OFS_DELTA' '
-- 
2.31.1.875.g5dccece0aa
Previous: Jeff KingNext: Jeff King
Message 5 of 15 in “pack-objects: better handling of negative options”
  1. 0/5 pack-objects: better handling of negative optionsJeff King, May 1, 2021
  2. 1/5 t5300: modernize basic testsJeff King, May 1, 2021
  3. Junio C HamanoMay 3, 2021
  4. Jeff KingMay 3, 2021
  5. 2/5 t5300: check that we produced expected number of deltasJeff King, May 1, 2021
  6. 3/5 pack-objects: clamp negative window size to 0Jeff King, May 1, 2021
  7. Derrick StoleeMay 3, 2021
  8. Jeff KingMay 3, 2021
  9. René ScharfeMay 4, 2021
  10. Jeff KingMay 4, 2021
  11. Ævar Arnfjörð BjarmasonMay 5, 2021
  12. René ScharfeMay 5, 2021
  13. 4/5 t5316: check behavior of pack-objects --depth=0Jeff King, May 1, 2021
  14. 5/5 pack-objects: clamp negative depth to 0Jeff King, May 1, 2021
  15. Derrick StoleeMay 3, 2021

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.