@@ -35,13 +35,13 @@ extern void clear_incremental_midx_files_ext(const char *object_dir,
35
35
extern int cmp_idx_or_pack_name (const char * idx_or_pack_name ,
36
36
const char * idx_name );
37
37
38
- static size_t write_midx_header (struct hashfile * f ,
39
- unsigned char num_chunks ,
38
+ static size_t write_midx_header (const struct git_hash_algo * hash_algo ,
39
+ struct hashfile * f , unsigned char num_chunks ,
40
40
uint32_t num_packs )
41
41
{
42
42
hashwrite_be32 (f , MIDX_SIGNATURE );
43
43
hashwrite_u8 (f , MIDX_VERSION );
44
- hashwrite_u8 (f , oid_version (the_hash_algo ));
44
+ hashwrite_u8 (f , oid_version (hash_algo ));
45
45
hashwrite_u8 (f , num_chunks );
46
46
hashwrite_u8 (f , 0 ); /* unused */
47
47
hashwrite_be32 (f , num_packs );
@@ -702,7 +702,7 @@ static int add_ref_to_pending(const char *refname, const char *referent UNUSED,
702
702
return 0 ;
703
703
}
704
704
705
- if (!peel_iterated_oid (the_repository , oid , & peeled ))
705
+ if (!peel_iterated_oid (revs -> repo , oid , & peeled ))
706
706
oid = & peeled ;
707
707
708
708
object = parse_object_or_die (oid , refname );
@@ -827,7 +827,7 @@ static struct commit **find_commits_for_midx_bitmap(uint32_t *indexed_commits_nr
827
827
return cb .commits ;
828
828
}
829
829
830
- static int write_midx_bitmap (const char * midx_name ,
830
+ static int write_midx_bitmap (struct repository * r , const char * midx_name ,
831
831
const unsigned char * midx_hash ,
832
832
struct packing_data * pdata ,
833
833
struct commit * * commits ,
@@ -840,9 +840,9 @@ static int write_midx_bitmap(const char *midx_name,
840
840
struct bitmap_writer writer ;
841
841
struct pack_idx_entry * * index ;
842
842
char * bitmap_name = xstrfmt ("%s-%s.bitmap" , midx_name ,
843
- hash_to_hex (midx_hash ));
843
+ hash_to_hex_algop (midx_hash , r -> hash_algo ));
844
844
845
- trace2_region_enter ("midx" , "write_midx_bitmap" , the_repository );
845
+ trace2_region_enter ("midx" , "write_midx_bitmap" , r );
846
846
847
847
if (flags & MIDX_WRITE_BITMAP_HASH_CACHE )
848
848
options |= BITMAP_OPT_HASH_CACHE ;
@@ -859,7 +859,7 @@ static int write_midx_bitmap(const char *midx_name,
859
859
for (i = 0 ; i < pdata -> nr_objects ; i ++ )
860
860
index [i ] = & pdata -> objects [i ].idx ;
861
861
862
- bitmap_writer_init (& writer , the_repository , pdata );
862
+ bitmap_writer_init (& writer , r , pdata );
863
863
bitmap_writer_show_progress (& writer , flags & MIDX_PROGRESS );
864
864
bitmap_writer_build_type_index (& writer , index );
865
865
@@ -892,7 +892,7 @@ static int write_midx_bitmap(const char *midx_name,
892
892
free (bitmap_name );
893
893
bitmap_writer_free (& writer );
894
894
895
- trace2_region_leave ("midx" , "write_midx_bitmap" , the_repository );
895
+ trace2_region_leave ("midx" , "write_midx_bitmap" , r );
896
896
897
897
return ret ;
898
898
}
@@ -1049,7 +1049,7 @@ static void clear_midx_files(const char *object_dir,
1049
1049
strbuf_release (& buf );
1050
1050
}
1051
1051
1052
- static int write_midx_internal (const char * object_dir ,
1052
+ static int write_midx_internal (struct repository * r , const char * object_dir ,
1053
1053
struct string_list * packs_to_include ,
1054
1054
struct string_list * packs_to_drop ,
1055
1055
const char * preferred_pack_name ,
@@ -1070,7 +1070,8 @@ static int write_midx_internal(const char *object_dir,
1070
1070
const char * * keep_hashes = NULL ;
1071
1071
struct chunkfile * cf ;
1072
1072
1073
- trace2_region_enter ("midx" , "write_midx_internal" , the_repository );
1073
+ trace2_region_enter ("midx" , "write_midx_internal" , r );
1074
+
1074
1075
1075
1076
ctx .incremental = !!(flags & MIDX_WRITE_INCREMENTAL );
1076
1077
if (ctx .incremental && (flags & MIDX_WRITE_BITMAP ))
@@ -1087,8 +1088,7 @@ static int write_midx_internal(const char *object_dir,
1087
1088
midx_name .buf );
1088
1089
1089
1090
if (!packs_to_include || ctx .incremental ) {
1090
- struct multi_pack_index * m = lookup_multi_pack_index (the_repository ,
1091
- object_dir );
1091
+ struct multi_pack_index * m = lookup_multi_pack_index (r , object_dir );
1092
1092
if (m && !midx_checksum_valid (m )) {
1093
1093
warning (_ ("ignoring existing multi-pack-index; checksum mismatch" ));
1094
1094
m = NULL ;
@@ -1351,7 +1351,7 @@ static int write_midx_internal(const char *object_dir,
1351
1351
add_chunk (cf , MIDX_CHUNKID_OIDFANOUT , MIDX_CHUNK_FANOUT_SIZE ,
1352
1352
write_midx_oid_fanout );
1353
1353
add_chunk (cf , MIDX_CHUNKID_OIDLOOKUP ,
1354
- st_mult (ctx .entries_nr , the_hash_algo -> rawsz ),
1354
+ st_mult (ctx .entries_nr , r -> hash_algo -> rawsz ),
1355
1355
write_midx_oid_lookup );
1356
1356
add_chunk (cf , MIDX_CHUNKID_OBJECTOFFSETS ,
1357
1357
st_mult (ctx .entries_nr , MIDX_CHUNK_OFFSET_WIDTH ),
@@ -1373,7 +1373,8 @@ static int write_midx_internal(const char *object_dir,
1373
1373
write_midx_bitmapped_packs );
1374
1374
}
1375
1375
1376
- write_midx_header (f , get_num_chunks (cf ), ctx .nr - dropped_packs );
1376
+ write_midx_header (r -> hash_algo , f , get_num_chunks (cf ),
1377
+ ctx .nr - dropped_packs );
1377
1378
write_chunkfile (cf , & ctx );
1378
1379
1379
1380
finalize_hashfile (f , midx_hash , FSYNC_COMPONENT_PACK_METADATA ,
@@ -1405,7 +1406,7 @@ static int write_midx_internal(const char *object_dir,
1405
1406
FREE_AND_NULL (ctx .entries );
1406
1407
ctx .entries_nr = 0 ;
1407
1408
1408
- if (write_midx_bitmap (midx_name .buf , midx_hash , & pdata ,
1409
+ if (write_midx_bitmap (r , midx_name .buf , midx_hash , & pdata ,
1409
1410
commits , commits_nr , ctx .pack_order ,
1410
1411
flags ) < 0 ) {
1411
1412
error (_ ("could not write multi-pack bitmap" ));
@@ -1449,20 +1450,21 @@ static int write_midx_internal(const char *object_dir,
1449
1450
strbuf_release (& final_midx_name );
1450
1451
1451
1452
keep_hashes [ctx .num_multi_pack_indexes_before ] =
1452
- xstrdup (hash_to_hex (midx_hash ));
1453
+ xstrdup (hash_to_hex_algop (midx_hash , r -> hash_algo ));
1453
1454
1454
1455
for (i = 0 ; i < ctx .num_multi_pack_indexes_before ; i ++ ) {
1455
1456
uint32_t j = ctx .num_multi_pack_indexes_before - i - 1 ;
1456
1457
1457
- keep_hashes [j ] = xstrdup (hash_to_hex (get_midx_checksum (m )));
1458
+ keep_hashes [j ] = xstrdup (hash_to_hex_algop (get_midx_checksum (m ),
1459
+ r -> hash_algo ));
1458
1460
m = m -> base_midx ;
1459
1461
}
1460
1462
1461
1463
for (i = 0 ; i < ctx .num_multi_pack_indexes_before + 1 ; i ++ )
1462
1464
fprintf (get_lock_file_fp (& lk ), "%s\n" , keep_hashes [i ]);
1463
1465
} else {
1464
1466
keep_hashes [ctx .num_multi_pack_indexes_before ] =
1465
- xstrdup (hash_to_hex (midx_hash ));
1467
+ xstrdup (hash_to_hex_algop (midx_hash , r -> hash_algo ));
1466
1468
}
1467
1469
1468
1470
if (ctx .m || ctx .base_midx )
@@ -1495,7 +1497,7 @@ static int write_midx_internal(const char *object_dir,
1495
1497
}
1496
1498
strbuf_release (& midx_name );
1497
1499
1498
- trace2_region_leave ("midx" , "write_midx_internal" , the_repository );
1500
+ trace2_region_leave ("midx" , "write_midx_internal" , r );
1499
1501
1500
1502
return result ;
1501
1503
}
@@ -1505,8 +1507,8 @@ int write_midx_file(const char *object_dir,
1505
1507
const char * refs_snapshot ,
1506
1508
unsigned flags )
1507
1509
{
1508
- return write_midx_internal (object_dir , NULL , NULL , preferred_pack_name ,
1509
- refs_snapshot , flags );
1510
+ return write_midx_internal (the_repository , object_dir , NULL , NULL ,
1511
+ preferred_pack_name , refs_snapshot , flags );
1510
1512
}
1511
1513
1512
1514
int write_midx_file_only (const char * object_dir ,
@@ -1515,8 +1517,9 @@ int write_midx_file_only(const char *object_dir,
1515
1517
const char * refs_snapshot ,
1516
1518
unsigned flags )
1517
1519
{
1518
- return write_midx_internal (object_dir , packs_to_include , NULL ,
1519
- preferred_pack_name , refs_snapshot , flags );
1520
+ return write_midx_internal (the_repository , object_dir , packs_to_include ,
1521
+ NULL , preferred_pack_name , refs_snapshot ,
1522
+ flags );
1520
1523
}
1521
1524
1522
1525
int expire_midx_packs (struct repository * r , const char * object_dir , unsigned flags )
@@ -1572,7 +1575,8 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
1572
1575
free (count );
1573
1576
1574
1577
if (packs_to_drop .nr )
1575
- result = write_midx_internal (object_dir , NULL , & packs_to_drop , NULL , NULL , flags );
1578
+ result = write_midx_internal (r , object_dir , NULL ,
1579
+ & packs_to_drop , NULL , NULL , flags );
1576
1580
1577
1581
string_list_clear (& packs_to_drop , 0 );
1578
1582
@@ -1769,7 +1773,8 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
1769
1773
goto cleanup ;
1770
1774
}
1771
1775
1772
- result = write_midx_internal (object_dir , NULL , NULL , NULL , NULL , flags );
1776
+ result = write_midx_internal (r , object_dir , NULL , NULL , NULL , NULL ,
1777
+ flags );
1773
1778
1774
1779
cleanup :
1775
1780
free (include_pack );
0 commit comments