index-pack: abstract away hash function constant
The code for reading certain pack v2 offsets had a hard-coded 5 representing the number of uint32_t words that we needed to skip over. Specify this value in terms of a value from the_hash_algo. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
May 2, 2018 at 00:25 UTC
5d9e19824573782a9d4461b49bcd78b5faa79963
1 file changed
+2
-1
builtin/index-pack.c
+2
-1
@@ -1543,12 +1543,13 @@ static void read_v2_anomalous_offsets(struct packed_git *p,
1543
{
1544
const uint32_t *idx1, *idx2;
1545
uint32_t i;
1546
+ const uint32_t hashwords = the_hash_algo->rawsz / sizeof(uint32_t);
1547
1548
/* The address of the 4-byte offset table */
1549
idx1 = (((const uint32_t *)p->index_data)
1550
+ 2 /* 8-byte header */
1551
+ 256 /* fan out */
1551
- + 5 * p->num_objects /* 20-byte SHA-1 table */
1552
+ + hashwords * p->num_objects /* object ID table */
1553
+ p->num_objects /* CRC32 table */
1554
);
1555