2626#define MIDX_CHUNK_LARGE_OFFSET_WIDTH (sizeof(uint64_t))
2727
2828extern 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 ,
3030 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 ,
3232 const char * ext ,
3333 const char * * keep_hashes ,
3434 uint32_t hashes_nr );
@@ -112,6 +112,7 @@ struct write_midx_context {
112112 struct string_list * to_include ;
113113
114114 struct repository * repo ;
115+ struct odb_source * source ;
115116};
116117
117118static 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)
648649}
649650
650651static void write_midx_reverse_index (struct write_midx_context * ctx ,
651- const char * object_dir ,
652652 unsigned char * midx_hash )
653653{
654654 struct strbuf buf = STRBUF_INIT ;
@@ -657,11 +657,10 @@ static void write_midx_reverse_index(struct write_midx_context *ctx,
657657 trace2_region_enter ("midx" , "write_midx_reverse_index" , ctx -> repo );
658658
659659 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 );
663662 else
664- get_midx_filename_ext (ctx -> repo -> hash_algo , & buf , object_dir ,
663+ get_midx_filename_ext (ctx -> source , & buf ,
665664 midx_hash , MIDX_EXT_REV );
666665
667666 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
836835}
837836
838837static int write_midx_bitmap (struct write_midx_context * ctx ,
839- const char * object_dir ,
840838 const unsigned char * midx_hash ,
841839 struct packing_data * pdata ,
842840 struct commit * * commits ,
@@ -852,12 +850,11 @@ static int write_midx_bitmap(struct write_midx_context *ctx,
852850 trace2_region_enter ("midx" , "write_midx_bitmap" , ctx -> repo );
853851
854852 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 );
858855 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 );
861858
862859 if (flags & MIDX_WRITE_BITMAP_HASH_CACHE )
863860 options |= BITMAP_OPT_HASH_CACHE ;
@@ -981,11 +978,9 @@ static int link_midx_to_chain(struct multi_pack_index *m)
981978 for (i = 0 ; i < ARRAY_SIZE (midx_exts ); i ++ ) {
982979 const unsigned char * hash = get_midx_checksum (m );
983980
984- get_midx_filename_ext (m -> source -> odb -> repo -> hash_algo , & from ,
985- m -> source -> path ,
981+ get_midx_filename_ext (m -> source , & from ,
986982 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 ,
989984 midx_exts [i ].split );
990985
991986 if (link (from .buf , to .buf ) < 0 && errno != ENOENT ) {
@@ -1023,16 +1018,16 @@ static void clear_midx_files(struct odb_source *source,
10231018 uint32_t i , j ;
10241019
10251020 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 ],
10271022 hashes , hashes_nr );
10281023 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 ]);
10301025 }
10311026
10321027 if (incremental )
1033- get_midx_filename (source -> odb -> repo -> hash_algo , & buf , source -> path );
1028+ get_midx_filename (source , & buf );
10341029 else
1035- get_midx_chain_filename (& buf , source -> path );
1030+ get_midx_chain_filename (source , & buf );
10361031
10371032 if (unlink (buf .buf ) && errno != ENOENT )
10381033 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,
10651060 trace2_region_enter ("midx" , "write_midx_internal" , r );
10661061
10671062 ctx .repo = r ;
1063+ ctx .source = source ;
10681064
10691065 ctx .incremental = !!(flags & MIDX_WRITE_INCREMENTAL );
10701066
@@ -1073,7 +1069,7 @@ static int write_midx_internal(struct odb_source *source,
10731069 "%s/pack/multi-pack-index.d/tmp_midx_XXXXXX" ,
10741070 source -> path );
10751071 else
1076- get_midx_filename (r -> hash_algo , & midx_name , source -> path );
1072+ get_midx_filename (source , & midx_name );
10771073 if (safe_create_leading_directories (r , midx_name .buf ))
10781074 die_errno (_ ("unable to create leading directories of %s" ),
10791075 midx_name .buf );
@@ -1153,7 +1149,7 @@ static int write_midx_internal(struct odb_source *source,
11531149 * corresponding bitmap (or one wasn't requested).
11541150 */
11551151 if (!want_bitmap )
1156- clear_midx_files_ext (source -> path , "bitmap" , NULL );
1152+ clear_midx_files_ext (source , "bitmap" , NULL );
11571153 goto cleanup ;
11581154 }
11591155 }
@@ -1321,7 +1317,7 @@ static int write_midx_internal(struct odb_source *source,
13211317 if (ctx .incremental ) {
13221318 struct strbuf lock_name = STRBUF_INIT ;
13231319
1324- get_midx_chain_filename (& lock_name , source -> path );
1320+ get_midx_chain_filename (source , & lock_name );
13251321 hold_lock_file_for_update (& lk , lock_name .buf , LOCK_DIE_ON_ERROR );
13261322 strbuf_release (& lock_name );
13271323
@@ -1384,7 +1380,7 @@ static int write_midx_internal(struct odb_source *source,
13841380
13851381 if (flags & MIDX_WRITE_REV_INDEX &&
13861382 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 );
13881384
13891385 if (flags & MIDX_WRITE_BITMAP ) {
13901386 struct packing_data pdata ;
@@ -1407,7 +1403,7 @@ static int write_midx_internal(struct odb_source *source,
14071403 FREE_AND_NULL (ctx .entries );
14081404 ctx .entries_nr = 0 ;
14091405
1410- if (write_midx_bitmap (& ctx , source -> path ,
1406+ if (write_midx_bitmap (& ctx ,
14111407 midx_hash , & pdata , commits , commits_nr ,
14121408 flags ) < 0 ) {
14131409 error (_ ("could not write multi-pack bitmap" ));
@@ -1440,8 +1436,8 @@ static int write_midx_internal(struct odb_source *source,
14401436 if (link_midx_to_chain (ctx .base_midx ) < 0 )
14411437 return -1 ;
14421438
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 );
14451441
14461442 if (rename_tempfile (& incr , final_midx_name .buf ) < 0 ) {
14471443 error_errno (_ ("unable to rename new multi-pack-index layer" ));
0 commit comments