t5300: check that we produced expected number of deltas
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
May 1, 2021 at 10:03 UTC
95356789ee5e65abbdf3f354b8be4c79b196e8a1
1 file changed
+20
-3
t/t5300-pack-object.sh
+20
-3
@@ -34,8 +34,22 @@ test_expect_success 'setup' '
34
} >expect
35
'
36
37
+# usage: check_deltas <stderr_from_pack_objects> <cmp_op> <nr_deltas>
38
+# e.g.: check_deltas stderr -gt 0
39
+check_deltas() {
40
+ deltas=$(perl -lne '/delta (\d+)/ and print $1' "$1") &&
41
+ shift &&
42
+ if ! test "$deltas" "$@"
43
+ then
44
+ echo >&2 "unexpected number of deltas (compared $delta $*)"
45
+ return 1
46
+ fi
47
+}
48
+
49
test_expect_success 'pack without delta' '
38
- packname_1=$(git pack-objects --window=0 test-1 <obj-list)
50
+ packname_1=$(git pack-objects --progress --window=0 test-1 \
51
+ <obj-list 2>stderr) &&
52
+ check_deltas stderr = 0
53
'
54
55
test_expect_success 'pack-objects with bogus arguments' '
@@ -62,7 +76,8 @@ test_expect_success 'unpack without delta' '
76
'
77
78
test_expect_success 'pack with REF_DELTA' '
65
- packname_2=$(git pack-objects test-2 <obj-list)
79
+ packname_2=$(git pack-objects --progress test-2 <obj-list 2>stderr) &&
80
+ check_deltas stderr -gt 0
81
'
82
83
test_expect_success 'unpack with REF_DELTA' '
@@ -70,7 +85,9 @@ test_expect_success 'unpack with REF_DELTA' '
85
'
86
87
test_expect_success 'pack with OFS_DELTA' '
73
- packname_3=$(git pack-objects --delta-base-offset test-3 <obj-list)
88
+ packname_3=$(git pack-objects --progress --delta-base-offset test-3 \
89
+ <obj-list 2>stderr) &&
90
+ check_deltas stderr -gt 0
91
'
92
93
test_expect_success 'unpack with OFS_DELTA' '