|
19 | 19 | #define MIDX_BYTE_NUM_PACKS 8
|
20 | 20 | #define MIDX_HASH_VERSION 1
|
21 | 21 | #define MIDX_HEADER_SIZE 12
|
22 |
| -#define MIDX_HASH_LEN 20 |
23 |
| -#define MIDX_MIN_SIZE (MIDX_HEADER_SIZE + MIDX_HASH_LEN) |
| 22 | +#define MIDX_MIN_SIZE (MIDX_HEADER_SIZE + the_hash_algo->rawsz) |
24 | 23 |
|
25 | 24 | #define MIDX_MAX_CHUNKS 5
|
26 | 25 | #define MIDX_CHUNK_ALIGNMENT 4
|
@@ -93,7 +92,7 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local
|
93 | 92 | hash_version = m->data[MIDX_BYTE_HASH_VERSION];
|
94 | 93 | if (hash_version != MIDX_HASH_VERSION)
|
95 | 94 | die(_("hash version %u does not match"), hash_version);
|
96 |
| - m->hash_len = MIDX_HASH_LEN; |
| 95 | + m->hash_len = the_hash_algo->rawsz; |
97 | 96 |
|
98 | 97 | m->num_chunks = m->data[MIDX_BYTE_NUM_CHUNKS];
|
99 | 98 |
|
@@ -234,7 +233,7 @@ int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, uint32_t
|
234 | 233 | int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m, uint32_t *result)
|
235 | 234 | {
|
236 | 235 | return bsearch_hash(oid->hash, m->chunk_oid_fanout, m->chunk_oid_lookup,
|
237 |
| - MIDX_HASH_LEN, result); |
| 236 | + the_hash_algo->rawsz, result); |
238 | 237 | }
|
239 | 238 |
|
240 | 239 | struct object_id *nth_midxed_object_oid(struct object_id *oid,
|
@@ -928,7 +927,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
|
928 | 927 |
|
929 | 928 | cur_chunk++;
|
930 | 929 | chunk_ids[cur_chunk] = MIDX_CHUNKID_OBJECTOFFSETS;
|
931 |
| - chunk_offsets[cur_chunk] = chunk_offsets[cur_chunk - 1] + nr_entries * MIDX_HASH_LEN; |
| 930 | + chunk_offsets[cur_chunk] = chunk_offsets[cur_chunk - 1] + nr_entries * the_hash_algo->rawsz; |
932 | 931 |
|
933 | 932 | cur_chunk++;
|
934 | 933 | chunk_offsets[cur_chunk] = chunk_offsets[cur_chunk - 1] + nr_entries * MIDX_CHUNK_OFFSET_WIDTH;
|
@@ -976,7 +975,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
|
976 | 975 | break;
|
977 | 976 |
|
978 | 977 | case MIDX_CHUNKID_OIDLOOKUP:
|
979 |
| - written += write_midx_oid_lookup(f, MIDX_HASH_LEN, entries, nr_entries); |
| 978 | + written += write_midx_oid_lookup(f, the_hash_algo->rawsz, entries, nr_entries); |
980 | 979 | break;
|
981 | 980 |
|
982 | 981 | case MIDX_CHUNKID_OBJECTOFFSETS:
|
|
0 commit comments