Skip to content

Commit 9535678

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5489899 commit 9535678

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

t/t5300-pack-object.sh

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,22 @@ test_expect_success 'setup' '
3434
} >expect
3535
'
3636

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+
3749
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
3953
'
4054

4155
test_expect_success 'pack-objects with bogus arguments' '
@@ -62,15 +76,18 @@ test_expect_success 'unpack without delta' '
6276
'
6377

6478
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
6681
'
6782

6883
test_expect_success 'unpack with REF_DELTA' '
6984
check_unpack test-2-${packname_2}
7085
'
7186

7287
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
7491
'
7592

7693
test_expect_success 'unpack with OFS_DELTA' '

0 commit comments

Comments
 (0)