@@ -913,13 +913,6 @@ static int write_midx_bitmap(struct write_midx_context *ctx,
913913 return ret ;
914914}
915915
916- static struct multi_pack_index * lookup_multi_pack_index (struct repository * r ,
917- const char * object_dir )
918- {
919- struct odb_source * source = odb_find_source_or_die (r -> objects , object_dir );
920- return get_multi_pack_index (source );
921- }
922-
923916static int fill_packs_from_midx (struct write_midx_context * ctx ,
924917 const char * preferred_pack_name , uint32_t flags )
925918{
@@ -1010,7 +1003,7 @@ static int link_midx_to_chain(struct multi_pack_index *m)
10101003 return ret ;
10111004}
10121005
1013- static void clear_midx_files (struct repository * r , const char * object_dir ,
1006+ static void clear_midx_files (struct odb_source * source ,
10141007 const char * * hashes , uint32_t hashes_nr ,
10151008 unsigned incremental )
10161009{
@@ -1029,30 +1022,31 @@ static void clear_midx_files(struct repository *r, const char *object_dir,
10291022 uint32_t i , j ;
10301023
10311024 for (i = 0 ; i < ARRAY_SIZE (exts ); i ++ ) {
1032- clear_incremental_midx_files_ext (object_dir , exts [i ],
1025+ clear_incremental_midx_files_ext (source -> path , exts [i ],
10331026 hashes , hashes_nr );
10341027 for (j = 0 ; j < hashes_nr ; j ++ )
1035- clear_midx_files_ext (object_dir , exts [i ], hashes [j ]);
1028+ clear_midx_files_ext (source -> path , exts [i ], hashes [j ]);
10361029 }
10371030
10381031 if (incremental )
1039- get_midx_filename (r -> hash_algo , & buf , object_dir );
1032+ get_midx_filename (source -> odb -> repo -> hash_algo , & buf , source -> path );
10401033 else
1041- get_midx_chain_filename (& buf , object_dir );
1034+ get_midx_chain_filename (& buf , source -> path );
10421035
10431036 if (unlink (buf .buf ) && errno != ENOENT )
10441037 die_errno (_ ("failed to clear multi-pack-index at %s" ), buf .buf );
10451038
10461039 strbuf_release (& buf );
10471040}
10481041
1049- static int write_midx_internal (struct repository * r , const char * object_dir ,
1042+ static int write_midx_internal (struct odb_source * source ,
10501043 struct string_list * packs_to_include ,
10511044 struct string_list * packs_to_drop ,
10521045 const char * preferred_pack_name ,
10531046 const char * refs_snapshot ,
10541047 unsigned flags )
10551048{
1049+ struct repository * r = source -> odb -> repo ;
10561050 struct strbuf midx_name = STRBUF_INIT ;
10571051 unsigned char midx_hash [GIT_MAX_RAWSZ ];
10581052 uint32_t i , start_pack ;
@@ -1076,15 +1070,15 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
10761070 if (ctx .incremental )
10771071 strbuf_addf (& midx_name ,
10781072 "%s/pack/multi-pack-index.d/tmp_midx_XXXXXX" ,
1079- object_dir );
1073+ source -> path );
10801074 else
1081- get_midx_filename (r -> hash_algo , & midx_name , object_dir );
1075+ get_midx_filename (r -> hash_algo , & midx_name , source -> path );
10821076 if (safe_create_leading_directories (r , midx_name .buf ))
10831077 die_errno (_ ("unable to create leading directories of %s" ),
10841078 midx_name .buf );
10851079
10861080 if (!packs_to_include || ctx .incremental ) {
1087- struct multi_pack_index * m = lookup_multi_pack_index ( r , object_dir );
1081+ struct multi_pack_index * m = get_multi_pack_index ( source );
10881082 if (m && !midx_checksum_valid (m )) {
10891083 warning (_ ("ignoring existing multi-pack-index; checksum mismatch" ));
10901084 m = NULL ;
@@ -1138,7 +1132,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
11381132
11391133 ctx .to_include = packs_to_include ;
11401134
1141- for_each_file_in_pack_dir (object_dir , add_pack_to_midx , & ctx );
1135+ for_each_file_in_pack_dir (source -> path , add_pack_to_midx , & ctx );
11421136 stop_progress (& ctx .progress );
11431137
11441138 if ((ctx .m && ctx .nr == ctx .m -> num_packs + ctx .m -> num_packs_in_base ) &&
@@ -1158,7 +1152,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
11581152 * corresponding bitmap (or one wasn't requested).
11591153 */
11601154 if (!want_bitmap )
1161- clear_midx_files_ext (object_dir , "bitmap" , NULL );
1155+ clear_midx_files_ext (source -> path , "bitmap" , NULL );
11621156 goto cleanup ;
11631157 }
11641158 }
@@ -1326,7 +1320,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
13261320 if (ctx .incremental ) {
13271321 struct strbuf lock_name = STRBUF_INIT ;
13281322
1329- get_midx_chain_filename (& lock_name , object_dir );
1323+ get_midx_chain_filename (& lock_name , source -> path );
13301324 hold_lock_file_for_update (& lk , lock_name .buf , LOCK_DIE_ON_ERROR );
13311325 strbuf_release (& lock_name );
13321326
@@ -1389,7 +1383,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
13891383
13901384 if (flags & MIDX_WRITE_REV_INDEX &&
13911385 git_env_bool ("GIT_TEST_MIDX_WRITE_REV" , 0 ))
1392- write_midx_reverse_index (& ctx , object_dir , midx_hash );
1386+ write_midx_reverse_index (& ctx , source -> path , midx_hash );
13931387
13941388 if (flags & MIDX_WRITE_BITMAP ) {
13951389 struct packing_data pdata ;
@@ -1412,7 +1406,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
14121406 FREE_AND_NULL (ctx .entries );
14131407 ctx .entries_nr = 0 ;
14141408
1415- if (write_midx_bitmap (& ctx , object_dir ,
1409+ if (write_midx_bitmap (& ctx , source -> path ,
14161410 midx_hash , & pdata , commits , commits_nr ,
14171411 flags ) < 0 ) {
14181412 error (_ ("could not write multi-pack bitmap" ));
@@ -1446,7 +1440,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
14461440 return -1 ;
14471441
14481442 get_split_midx_filename_ext (r -> hash_algo , & final_midx_name ,
1449- object_dir , midx_hash , MIDX_EXT_MIDX );
1443+ source -> path , midx_hash , MIDX_EXT_MIDX );
14501444
14511445 if (rename_tempfile (& incr , final_midx_name .buf ) < 0 ) {
14521446 error_errno (_ ("unable to rename new multi-pack-index layer" ));
@@ -1479,7 +1473,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
14791473 if (commit_lock_file (& lk ) < 0 )
14801474 die_errno (_ ("could not write multi-pack-index" ));
14811475
1482- clear_midx_files (r , object_dir , keep_hashes ,
1476+ clear_midx_files (source , keep_hashes ,
14831477 ctx .num_multi_pack_indexes_before + 1 ,
14841478 ctx .incremental );
14851479
@@ -1508,29 +1502,29 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
15081502 return result ;
15091503}
15101504
1511- int write_midx_file (struct repository * r , const char * object_dir ,
1505+ int write_midx_file (struct odb_source * source ,
15121506 const char * preferred_pack_name ,
15131507 const char * refs_snapshot , unsigned flags )
15141508{
1515- return write_midx_internal (r , object_dir , NULL , NULL ,
1509+ return write_midx_internal (source , NULL , NULL ,
15161510 preferred_pack_name , refs_snapshot ,
15171511 flags );
15181512}
15191513
1520- int write_midx_file_only (struct repository * r , const char * object_dir ,
1514+ int write_midx_file_only (struct odb_source * source ,
15211515 struct string_list * packs_to_include ,
15221516 const char * preferred_pack_name ,
15231517 const char * refs_snapshot , unsigned flags )
15241518{
1525- return write_midx_internal (r , object_dir , packs_to_include , NULL ,
1519+ return write_midx_internal (source , packs_to_include , NULL ,
15261520 preferred_pack_name , refs_snapshot , flags );
15271521}
15281522
1529- int expire_midx_packs (struct repository * r , const char * object_dir , unsigned flags )
1523+ int expire_midx_packs (struct odb_source * source , unsigned flags )
15301524{
15311525 uint32_t i , * count , result = 0 ;
15321526 struct string_list packs_to_drop = STRING_LIST_INIT_DUP ;
1533- struct multi_pack_index * m = lookup_multi_pack_index ( r , object_dir );
1527+ struct multi_pack_index * m = get_multi_pack_index ( source );
15341528 struct progress * progress = NULL ;
15351529
15361530 if (!m )
@@ -1543,7 +1537,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
15431537
15441538 if (flags & MIDX_PROGRESS )
15451539 progress = start_delayed_progress (
1546- r ,
1540+ source -> odb -> repo ,
15471541 _ ("Counting referenced objects" ),
15481542 m -> num_objects );
15491543 for (i = 0 ; i < m -> num_objects ; i ++ ) {
@@ -1555,7 +1549,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
15551549
15561550 if (flags & MIDX_PROGRESS )
15571551 progress = start_delayed_progress (
1558- r ,
1552+ source -> odb -> repo ,
15591553 _ ("Finding and deleting unreferenced packfiles" ),
15601554 m -> num_packs );
15611555 for (i = 0 ; i < m -> num_packs ; i ++ ) {
@@ -1583,7 +1577,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
15831577 free (count );
15841578
15851579 if (packs_to_drop .nr )
1586- result = write_midx_internal (r , object_dir , NULL ,
1580+ result = write_midx_internal (source , NULL ,
15871581 & packs_to_drop , NULL , NULL , flags );
15881582
15891583 string_list_clear (& packs_to_drop , 0 );
@@ -1708,14 +1702,15 @@ static void fill_included_packs_batch(struct repository *r,
17081702 free (pack_info );
17091703}
17101704
1711- int midx_repack (struct repository * r , const char * object_dir , size_t batch_size , unsigned flags )
1705+ int midx_repack (struct odb_source * source , size_t batch_size , unsigned flags )
17121706{
1707+ struct repository * r = source -> odb -> repo ;
17131708 int result = 0 ;
17141709 uint32_t i , packs_to_repack = 0 ;
17151710 unsigned char * include_pack ;
17161711 struct child_process cmd = CHILD_PROCESS_INIT ;
17171712 FILE * cmd_in ;
1718- struct multi_pack_index * m = lookup_multi_pack_index ( r , object_dir );
1713+ struct multi_pack_index * m = get_multi_pack_index ( source );
17191714
17201715 /*
17211716 * When updating the default for these configuration
@@ -1749,7 +1744,7 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
17491744
17501745 strvec_push (& cmd .args , "pack-objects" );
17511746
1752- strvec_pushf (& cmd .args , "%s/pack/pack" , object_dir );
1747+ strvec_pushf (& cmd .args , "%s/pack/pack" , source -> path );
17531748
17541749 if (delta_base_offset )
17551750 strvec_push (& cmd .args , "--delta-base-offset" );
@@ -1790,7 +1785,7 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
17901785 goto cleanup ;
17911786 }
17921787
1793- result = write_midx_internal (r , object_dir , NULL , NULL , NULL , NULL ,
1788+ result = write_midx_internal (source , NULL , NULL , NULL , NULL ,
17941789 flags );
17951790
17961791cleanup :
0 commit comments