Skip to content

Commit a30f93b

Browse files
bk2204gitster
authored andcommitted
t5313: make test hash independent
Make this test hash independent by computing the length of the object offsets and looking up values which will hash to object IDs with the right properties. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a79eec2 commit a30f93b

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

t/t5313-pack-bounds-checks.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,27 @@ munge () {
3838
# for the initial, and another ofs(4*nr) past that for the extended.
3939
#
4040
ofs_table () {
41-
echo $((4 + 4 + 4*256 + 20*$1 + 4*$1))
41+
echo $((4 + 4 + 4*256 + $(test_oid rawsz)*$1 + 4*$1))
4242
}
4343
extended_table () {
4444
echo $(($(ofs_table "$1") + 4*$1))
4545
}
4646

47+
test_expect_success 'setup' '
48+
test_oid_init &&
49+
test_oid_cache <<-EOF
50+
oid000 sha1:1485
51+
oid000 sha256:4222
52+
53+
oidfff sha1:74
54+
oidfff sha256:1350
55+
EOF
56+
'
57+
4758
test_expect_success 'set up base packfile and variables' '
4859
# the hash of this content starts with ff, which
4960
# makes some later computations much simpler
50-
echo 74 >file &&
61+
echo $(test_oid oidfff) >file &&
5162
git add file &&
5263
git commit -m base &&
5364
git repack -ad &&
@@ -140,10 +151,10 @@ test_expect_success 'bogus offset inside v2 extended table' '
140151
# an extended table (if the first object were larger than 2^31).
141152
#
142153
# Note that the value is important here. We want $object as
143-
# the second entry in sorted-sha1 order. The sha1 of 1485 starts
154+
# the second entry in sorted-hash order. The hash of this object starts
144155
# with "000", which sorts before that of $object (which starts
145156
# with "fff").
146-
second=$(echo 1485 | git hash-object -w --stdin) &&
157+
second=$(test_oid oid000 | git hash-object -w --stdin) &&
147158
do_pack "$object $second" --index-version=2 &&
148159
149160
# We have to make extra room for the table, so we cannot

0 commit comments

Comments
 (0)