Skip to content

Commit 796d138

Browse files
bk2204gitster
authored andcommitted
t5302: make hash size independent
Compute the length of object IDs and pack offsets instead of hard-coding constants. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 417e45e commit 796d138

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

t/t5302-pack-index.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
test_description='pack index with 64-bit offsets and object CRC'
77
. ./test-lib.sh
88

9-
test_expect_success \
10-
'setup' \
11-
'rm -rf .git &&
9+
test_expect_success 'setup' '
10+
test_oid_init &&
11+
rawsz=$(test_oid rawsz) &&
12+
rm -rf .git &&
1213
git init &&
1314
git config pack.threads 1 &&
1415
i=1 &&
@@ -32,7 +33,8 @@ test_expect_success \
3233
echo $tree &&
3334
git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/"
3435
} >obj-list &&
35-
git update-ref HEAD $commit'
36+
git update-ref HEAD $commit
37+
'
3638

3739
test_expect_success \
3840
'pack-objects with index version 1' \
@@ -157,10 +159,11 @@ test_expect_success \
157159
offs_101=$(index_obj_offset 1.idx $sha1_101) &&
158160
nr_099=$(index_obj_nr 1.idx $sha1_099) &&
159161
chmod +w ".git/objects/pack/pack-${pack1}.pack" &&
162+
recordsz=$((rawsz + 4)) &&
160163
dd of=".git/objects/pack/pack-${pack1}.pack" seek=$(($offs_101 + 1)) \
161164
if=".git/objects/pack/pack-${pack1}.idx" \
162-
skip=$((4 + 256 * 4 + $nr_099 * 24)) \
163-
bs=1 count=20 conv=notrunc &&
165+
skip=$((4 + 256 * 4 + $nr_099 * recordsz)) \
166+
bs=1 count=$rawsz conv=notrunc &&
164167
git cat-file blob $sha1_101 > file_101_foo1'
165168

166169
test_expect_success \
@@ -200,8 +203,8 @@ test_expect_success \
200203
chmod +w ".git/objects/pack/pack-${pack1}.pack" &&
201204
dd of=".git/objects/pack/pack-${pack1}.pack" seek=$(($offs_101 + 1)) \
202205
if=".git/objects/pack/pack-${pack1}.idx" \
203-
skip=$((8 + 256 * 4 + $nr_099 * 20)) \
204-
bs=1 count=20 conv=notrunc &&
206+
skip=$((8 + 256 * 4 + $nr_099 * rawsz)) \
207+
bs=1 count=$rawsz conv=notrunc &&
205208
git cat-file blob $sha1_101 > file_101_foo2'
206209

207210
test_expect_success \
@@ -226,7 +229,7 @@ test_expect_success \
226229
nr=$(index_obj_nr ".git/objects/pack/pack-${pack1}.idx" $obj) &&
227230
chmod +w ".git/objects/pack/pack-${pack1}.idx" &&
228231
printf xxxx | dd of=".git/objects/pack/pack-${pack1}.idx" conv=notrunc \
229-
bs=1 count=4 seek=$((8 + 256 * 4 + $(wc -l <obj-list) * 20 + $nr * 4)) &&
232+
bs=1 count=4 seek=$((8 + 256 * 4 + $(wc -l <obj-list) * rawsz + $nr * 4)) &&
230233
( while read obj
231234
do git cat-file -p $obj >/dev/null || exit 1
232235
done <obj-list ) &&

0 commit comments

Comments
 (0)