26
26
#define MIDX_CHUNK_LARGE_OFFSET_WIDTH (sizeof(uint64_t))
27
27
28
28
extern int midx_checksum_valid (struct multi_pack_index * m );
29
- extern void clear_midx_files_ext (const char * object_dir , const char * ext ,
29
+ extern void clear_midx_files_ext (struct odb_source * source , const char * ext ,
30
30
const char * keep_hash );
31
- extern void clear_incremental_midx_files_ext (const char * object_dir ,
31
+ extern void clear_incremental_midx_files_ext (struct odb_source * source ,
32
32
const char * ext ,
33
33
const char * * keep_hashes ,
34
34
uint32_t hashes_nr );
@@ -112,6 +112,7 @@ struct write_midx_context {
112
112
struct string_list * to_include ;
113
113
114
114
struct repository * repo ;
115
+ struct odb_source * source ;
115
116
};
116
117
117
118
static int should_include_pack (const struct write_midx_context * ctx ,
@@ -648,7 +649,6 @@ static uint32_t *midx_pack_order(struct write_midx_context *ctx)
648
649
}
649
650
650
651
static void write_midx_reverse_index (struct write_midx_context * ctx ,
651
- const char * object_dir ,
652
652
unsigned char * midx_hash )
653
653
{
654
654
struct strbuf buf = STRBUF_INIT ;
@@ -657,11 +657,10 @@ static void write_midx_reverse_index(struct write_midx_context *ctx,
657
657
trace2_region_enter ("midx" , "write_midx_reverse_index" , ctx -> repo );
658
658
659
659
if (ctx -> incremental )
660
- get_split_midx_filename_ext (ctx -> repo -> hash_algo , & buf ,
661
- object_dir , midx_hash ,
662
- MIDX_EXT_REV );
660
+ get_split_midx_filename_ext (ctx -> source , & buf ,
661
+ midx_hash , MIDX_EXT_REV );
663
662
else
664
- get_midx_filename_ext (ctx -> repo -> hash_algo , & buf , object_dir ,
663
+ get_midx_filename_ext (ctx -> source , & buf ,
665
664
midx_hash , MIDX_EXT_REV );
666
665
667
666
tmp_file = write_rev_file_order (ctx -> repo , NULL , ctx -> pack_order ,
@@ -836,7 +835,6 @@ static struct commit **find_commits_for_midx_bitmap(uint32_t *indexed_commits_nr
836
835
}
837
836
838
837
static int write_midx_bitmap (struct write_midx_context * ctx ,
839
- const char * object_dir ,
840
838
const unsigned char * midx_hash ,
841
839
struct packing_data * pdata ,
842
840
struct commit * * commits ,
@@ -852,12 +850,11 @@ static int write_midx_bitmap(struct write_midx_context *ctx,
852
850
trace2_region_enter ("midx" , "write_midx_bitmap" , ctx -> repo );
853
851
854
852
if (ctx -> incremental )
855
- get_split_midx_filename_ext (ctx -> repo -> hash_algo , & bitmap_name ,
856
- object_dir , midx_hash ,
857
- MIDX_EXT_BITMAP );
853
+ get_split_midx_filename_ext (ctx -> source , & bitmap_name ,
854
+ midx_hash , MIDX_EXT_BITMAP );
858
855
else
859
- get_midx_filename_ext (ctx -> repo -> hash_algo , & bitmap_name ,
860
- object_dir , midx_hash , MIDX_EXT_BITMAP );
856
+ get_midx_filename_ext (ctx -> source , & bitmap_name ,
857
+ midx_hash , MIDX_EXT_BITMAP );
861
858
862
859
if (flags & MIDX_WRITE_BITMAP_HASH_CACHE )
863
860
options |= BITMAP_OPT_HASH_CACHE ;
@@ -981,11 +978,9 @@ static int link_midx_to_chain(struct multi_pack_index *m)
981
978
for (i = 0 ; i < ARRAY_SIZE (midx_exts ); i ++ ) {
982
979
const unsigned char * hash = get_midx_checksum (m );
983
980
984
- get_midx_filename_ext (m -> source -> odb -> repo -> hash_algo , & from ,
985
- m -> source -> path ,
981
+ get_midx_filename_ext (m -> source , & from ,
986
982
hash , midx_exts [i ].non_split );
987
- get_split_midx_filename_ext (m -> source -> odb -> repo -> hash_algo , & to ,
988
- m -> source -> path , hash ,
983
+ get_split_midx_filename_ext (m -> source , & to , hash ,
989
984
midx_exts [i ].split );
990
985
991
986
if (link (from .buf , to .buf ) < 0 && errno != ENOENT ) {
@@ -1023,16 +1018,16 @@ static void clear_midx_files(struct odb_source *source,
1023
1018
uint32_t i , j ;
1024
1019
1025
1020
for (i = 0 ; i < ARRAY_SIZE (exts ); i ++ ) {
1026
- clear_incremental_midx_files_ext (source -> path , exts [i ],
1021
+ clear_incremental_midx_files_ext (source , exts [i ],
1027
1022
hashes , hashes_nr );
1028
1023
for (j = 0 ; j < hashes_nr ; j ++ )
1029
- clear_midx_files_ext (source -> path , exts [i ], hashes [j ]);
1024
+ clear_midx_files_ext (source , exts [i ], hashes [j ]);
1030
1025
}
1031
1026
1032
1027
if (incremental )
1033
- get_midx_filename (source -> odb -> repo -> hash_algo , & buf , source -> path );
1028
+ get_midx_filename (source , & buf );
1034
1029
else
1035
- get_midx_chain_filename (& buf , source -> path );
1030
+ get_midx_chain_filename (source , & buf );
1036
1031
1037
1032
if (unlink (buf .buf ) && errno != ENOENT )
1038
1033
die_errno (_ ("failed to clear multi-pack-index at %s" ), buf .buf );
@@ -1065,6 +1060,7 @@ static int write_midx_internal(struct odb_source *source,
1065
1060
trace2_region_enter ("midx" , "write_midx_internal" , r );
1066
1061
1067
1062
ctx .repo = r ;
1063
+ ctx .source = source ;
1068
1064
1069
1065
ctx .incremental = !!(flags & MIDX_WRITE_INCREMENTAL );
1070
1066
@@ -1073,7 +1069,7 @@ static int write_midx_internal(struct odb_source *source,
1073
1069
"%s/pack/multi-pack-index.d/tmp_midx_XXXXXX" ,
1074
1070
source -> path );
1075
1071
else
1076
- get_midx_filename (r -> hash_algo , & midx_name , source -> path );
1072
+ get_midx_filename (source , & midx_name );
1077
1073
if (safe_create_leading_directories (r , midx_name .buf ))
1078
1074
die_errno (_ ("unable to create leading directories of %s" ),
1079
1075
midx_name .buf );
@@ -1153,7 +1149,7 @@ static int write_midx_internal(struct odb_source *source,
1153
1149
* corresponding bitmap (or one wasn't requested).
1154
1150
*/
1155
1151
if (!want_bitmap )
1156
- clear_midx_files_ext (source -> path , "bitmap" , NULL );
1152
+ clear_midx_files_ext (source , "bitmap" , NULL );
1157
1153
goto cleanup ;
1158
1154
}
1159
1155
}
@@ -1321,7 +1317,7 @@ static int write_midx_internal(struct odb_source *source,
1321
1317
if (ctx .incremental ) {
1322
1318
struct strbuf lock_name = STRBUF_INIT ;
1323
1319
1324
- get_midx_chain_filename (& lock_name , source -> path );
1320
+ get_midx_chain_filename (source , & lock_name );
1325
1321
hold_lock_file_for_update (& lk , lock_name .buf , LOCK_DIE_ON_ERROR );
1326
1322
strbuf_release (& lock_name );
1327
1323
@@ -1384,7 +1380,7 @@ static int write_midx_internal(struct odb_source *source,
1384
1380
1385
1381
if (flags & MIDX_WRITE_REV_INDEX &&
1386
1382
git_env_bool ("GIT_TEST_MIDX_WRITE_REV" , 0 ))
1387
- write_midx_reverse_index (& ctx , source -> path , midx_hash );
1383
+ write_midx_reverse_index (& ctx , midx_hash );
1388
1384
1389
1385
if (flags & MIDX_WRITE_BITMAP ) {
1390
1386
struct packing_data pdata ;
@@ -1407,7 +1403,7 @@ static int write_midx_internal(struct odb_source *source,
1407
1403
FREE_AND_NULL (ctx .entries );
1408
1404
ctx .entries_nr = 0 ;
1409
1405
1410
- if (write_midx_bitmap (& ctx , source -> path ,
1406
+ if (write_midx_bitmap (& ctx ,
1411
1407
midx_hash , & pdata , commits , commits_nr ,
1412
1408
flags ) < 0 ) {
1413
1409
error (_ ("could not write multi-pack bitmap" ));
@@ -1440,8 +1436,8 @@ static int write_midx_internal(struct odb_source *source,
1440
1436
if (link_midx_to_chain (ctx .base_midx ) < 0 )
1441
1437
return -1 ;
1442
1438
1443
- get_split_midx_filename_ext (r -> hash_algo , & final_midx_name ,
1444
- source -> path , midx_hash , MIDX_EXT_MIDX );
1439
+ get_split_midx_filename_ext (source , & final_midx_name ,
1440
+ midx_hash , MIDX_EXT_MIDX );
1445
1441
1446
1442
if (rename_tempfile (& incr , final_midx_name .buf ) < 0 ) {
1447
1443
error_errno (_ ("unable to rename new multi-pack-index layer" ));
0 commit comments