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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Feb 7, 2020 at 00:52 UTC
796d1383a395fb0eaf521b94d1305eb7fce3f579
1 file changed
+12
-9
t/t5302-pack-index.sh
+12
-9
@@ -6,9 +6,10 @@
6
test_description='pack index with 64-bit offsets and object CRC'
7
. ./test-lib.sh
8
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 &&
13
git init &&
14
git config pack.threads 1 &&
15
i=1 &&
@@ -32,7 +33,8 @@ test_expect_success \
33
echo $tree &&
34
git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/"
35
} >obj-list &&
35
- git update-ref HEAD $commit'
36
+ git update-ref HEAD $commit
37
+'
38
39
test_expect_success \
40
'pack-objects with index version 1' \
@@ -157,10 +159,11 @@ test_expect_success \
159
offs_101=$(index_obj_offset 1.idx $sha1_101) &&
160
nr_099=$(index_obj_nr 1.idx $sha1_099) &&
161
chmod +w ".git/objects/pack/pack-${pack1}.pack" &&
162
+ recordsz=$((rawsz + 4)) &&
163
dd of=".git/objects/pack/pack-${pack1}.pack" seek=$(($offs_101 + 1)) \
164
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 &&
167
git cat-file blob $sha1_101 > file_101_foo1'
168
169
test_expect_success \
@@ -200,8 +203,8 @@ test_expect_success \
203
chmod +w ".git/objects/pack/pack-${pack1}.pack" &&
204
dd of=".git/objects/pack/pack-${pack1}.pack" seek=$(($offs_101 + 1)) \
205
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 &&
208
git cat-file blob $sha1_101 > file_101_foo2'
209
210
test_expect_success \
@@ -226,7 +229,7 @@ test_expect_success \
229
nr=$(index_obj_nr ".git/objects/pack/pack-${pack1}.idx" $obj) &&
230
chmod +w ".git/objects/pack/pack-${pack1}.idx" &&
231
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)) &&
233
( while read obj
234
do git cat-file -p $obj >/dev/null || exit 1
235
done <obj-list ) &&