@@ -25,7 +25,7 @@ int cmp_idx_or_pack_name(const char *idx_or_pack_name,
25
25
26
26
const unsigned char * get_midx_checksum (struct multi_pack_index * m )
27
27
{
28
- return m -> data + m -> data_len - the_hash_algo -> rawsz ;
28
+ return m -> data + m -> data_len - m -> repo -> hash_algo -> rawsz ;
29
29
}
30
30
31
31
void get_midx_filename (struct strbuf * out , const char * object_dir )
@@ -94,7 +94,8 @@ static int midx_read_object_offsets(const unsigned char *chunk_start,
94
94
95
95
#define MIDX_MIN_SIZE (MIDX_HEADER_SIZE + the_hash_algo->rawsz)
96
96
97
- static struct multi_pack_index * load_multi_pack_index_one (const char * object_dir ,
97
+ static struct multi_pack_index * load_multi_pack_index_one (struct repository * r ,
98
+ const char * object_dir ,
98
99
const char * midx_name ,
99
100
int local )
100
101
{
@@ -131,7 +132,7 @@ static struct multi_pack_index *load_multi_pack_index_one(const char *object_dir
131
132
m -> data = midx_map ;
132
133
m -> data_len = midx_size ;
133
134
m -> local = local ;
134
- m -> repo = the_repository ;
135
+ m -> repo = r ;
135
136
136
137
m -> signature = get_be32 (m -> data );
137
138
if (m -> signature != MIDX_SIGNATURE )
@@ -144,12 +145,12 @@ static struct multi_pack_index *load_multi_pack_index_one(const char *object_dir
144
145
m -> version );
145
146
146
147
hash_version = m -> data [MIDX_BYTE_HASH_VERSION ];
147
- if (hash_version != oid_version (the_hash_algo )) {
148
+ if (hash_version != oid_version (r -> hash_algo )) {
148
149
error (_ ("multi-pack-index hash version %u does not match version %u" ),
149
- hash_version , oid_version (the_hash_algo ));
150
+ hash_version , oid_version (r -> hash_algo ));
150
151
goto cleanup_fail ;
151
152
}
152
- m -> hash_len = the_hash_algo -> rawsz ;
153
+ m -> hash_len = r -> hash_algo -> rawsz ;
153
154
154
155
m -> num_chunks = m -> data [MIDX_BYTE_NUM_CHUNKS ];
155
156
@@ -206,8 +207,8 @@ static struct multi_pack_index *load_multi_pack_index_one(const char *object_dir
206
207
m -> pack_names [i ]);
207
208
}
208
209
209
- trace2_data_intmax ("midx" , the_repository , "load/num_packs" , m -> num_packs );
210
- trace2_data_intmax ("midx" , the_repository , "load/num_objects" , m -> num_objects );
210
+ trace2_data_intmax ("midx" , r , "load/num_packs" , m -> num_packs );
211
+ trace2_data_intmax ("midx" , r , "load/num_objects" , m -> num_objects );
211
212
212
213
free_chunkfile (cf );
213
214
return m ;
@@ -240,8 +241,9 @@ void get_split_midx_filename_ext(struct strbuf *buf, const char *object_dir,
240
241
strbuf_addf (buf , "/multi-pack-index-%s.%s" , hash_to_hex (hash ), ext );
241
242
}
242
243
243
- static int open_multi_pack_index_chain (const char * chain_file ,
244
- int * fd , struct stat * st )
244
+ static int open_multi_pack_index_chain (const struct git_hash_algo * hash_algo ,
245
+ const char * chain_file , int * fd ,
246
+ struct stat * st )
245
247
{
246
248
* fd = git_open (chain_file );
247
249
if (* fd < 0 )
@@ -250,7 +252,7 @@ static int open_multi_pack_index_chain(const char *chain_file,
250
252
close (* fd );
251
253
return 0 ;
252
254
}
253
- if (st -> st_size < the_hash_algo -> hexsz ) {
255
+ if (st -> st_size < hash_algo -> hexsz ) {
254
256
close (* fd );
255
257
if (!st -> st_size ) {
256
258
/* treat empty files the same as missing */
@@ -292,7 +294,8 @@ static int add_midx_to_chain(struct multi_pack_index *midx,
292
294
return 1 ;
293
295
}
294
296
295
- static struct multi_pack_index * load_midx_chain_fd_st (const char * object_dir ,
297
+ static struct multi_pack_index * load_midx_chain_fd_st (struct repository * r ,
298
+ const char * object_dir ,
296
299
int local ,
297
300
int fd , struct stat * st ,
298
301
int * incomplete_chain )
@@ -303,7 +306,7 @@ static struct multi_pack_index *load_midx_chain_fd_st(const char *object_dir,
303
306
uint32_t i , count ;
304
307
FILE * fp = xfdopen (fd , "r" );
305
308
306
- count = st -> st_size / (the_hash_algo -> hexsz + 1 );
309
+ count = st -> st_size / (r -> hash_algo -> hexsz + 1 );
307
310
308
311
for (i = 0 ; i < count ; i ++ ) {
309
312
struct multi_pack_index * m ;
@@ -312,7 +315,7 @@ static struct multi_pack_index *load_midx_chain_fd_st(const char *object_dir,
312
315
if (strbuf_getline_lf (& buf , fp ) == EOF )
313
316
break ;
314
317
315
- if (get_oid_hex (buf .buf , & layer )) {
318
+ if (get_oid_hex_algop (buf .buf , & layer , r -> hash_algo )) {
316
319
warning (_ ("invalid multi-pack-index chain: line '%s' "
317
320
"not a hash" ),
318
321
buf .buf );
@@ -325,7 +328,7 @@ static struct multi_pack_index *load_midx_chain_fd_st(const char *object_dir,
325
328
strbuf_reset (& buf );
326
329
get_split_midx_filename_ext (& buf , object_dir , layer .hash ,
327
330
MIDX_EXT_MIDX );
328
- m = load_multi_pack_index_one (object_dir , buf .buf , local );
331
+ m = load_multi_pack_index_one (r , object_dir , buf .buf , local );
329
332
330
333
if (m ) {
331
334
if (add_midx_to_chain (m , midx_chain )) {
@@ -348,7 +351,8 @@ static struct multi_pack_index *load_midx_chain_fd_st(const char *object_dir,
348
351
return midx_chain ;
349
352
}
350
353
351
- static struct multi_pack_index * load_multi_pack_index_chain (const char * object_dir ,
354
+ static struct multi_pack_index * load_multi_pack_index_chain (struct repository * r ,
355
+ const char * object_dir ,
352
356
int local )
353
357
{
354
358
struct strbuf chain_file = STRBUF_INIT ;
@@ -357,10 +361,10 @@ static struct multi_pack_index *load_multi_pack_index_chain(const char *object_d
357
361
struct multi_pack_index * m = NULL ;
358
362
359
363
get_midx_chain_filename (& chain_file , object_dir );
360
- if (open_multi_pack_index_chain (chain_file .buf , & fd , & st )) {
364
+ if (open_multi_pack_index_chain (r -> hash_algo , chain_file .buf , & fd , & st )) {
361
365
int incomplete ;
362
366
/* ownership of fd is taken over by load function */
363
- m = load_midx_chain_fd_st (object_dir , local , fd , & st ,
367
+ m = load_midx_chain_fd_st (r , object_dir , local , fd , & st ,
364
368
& incomplete );
365
369
}
366
370
@@ -376,9 +380,10 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir,
376
380
377
381
get_midx_filename (& midx_name , object_dir );
378
382
379
- m = load_multi_pack_index_one (object_dir , midx_name .buf , local );
383
+ m = load_multi_pack_index_one (the_repository , object_dir ,
384
+ midx_name .buf , local );
380
385
if (!m )
381
- m = load_multi_pack_index_chain (object_dir , local );
386
+ m = load_multi_pack_index_chain (the_repository , object_dir , local );
382
387
383
388
strbuf_release (& midx_name );
384
389
@@ -520,7 +525,7 @@ int bsearch_one_midx(const struct object_id *oid, struct multi_pack_index *m,
520
525
uint32_t * result )
521
526
{
522
527
int ret = bsearch_hash (oid -> hash , m -> chunk_oid_fanout ,
523
- m -> chunk_oid_lookup , the_hash_algo -> rawsz ,
528
+ m -> chunk_oid_lookup , m -> repo -> hash_algo -> rawsz ,
524
529
result );
525
530
if (result )
526
531
* result += m -> num_objects_in_base ;
@@ -551,7 +556,7 @@ struct object_id *nth_midxed_object_oid(struct object_id *oid,
551
556
n = midx_for_object (& m , n );
552
557
553
558
oidread (oid , m -> chunk_oid_lookup + st_mult (m -> hash_len , n ),
554
- the_repository -> hash_algo );
559
+ m -> repo -> hash_algo );
555
560
return oid ;
556
561
}
557
562
0 commit comments