@@ -110,6 +110,8 @@ struct write_midx_context {
110110 uint32_t num_multi_pack_indexes_before ;
111111
112112 struct string_list * to_include ;
113+
114+ struct repository * repo ;
113115};
114116
115117static int should_include_pack (const struct write_midx_context * ctx ,
@@ -154,7 +156,7 @@ static void add_pack_to_midx(const char *full_path, size_t full_path_len,
154156 return ;
155157
156158 ALLOC_GROW (ctx -> info , ctx -> nr + 1 , ctx -> alloc );
157- p = add_packed_git (the_repository , full_path , full_path_len , 0 );
159+ p = add_packed_git (ctx -> repo , full_path , full_path_len , 0 );
158160 if (!p ) {
159161 warning (_ ("failed to add packfile '%s'" ),
160162 full_path );
@@ -480,7 +482,7 @@ static int write_midx_oid_lookup(struct hashfile *f,
480482 void * data )
481483{
482484 struct write_midx_context * ctx = data ;
483- unsigned char hash_len = the_hash_algo -> rawsz ;
485+ unsigned char hash_len = ctx -> repo -> hash_algo -> rawsz ;
484486 struct pack_midx_entry * list = ctx -> entries ;
485487 uint32_t i ;
486488
@@ -605,7 +607,7 @@ static uint32_t *midx_pack_order(struct write_midx_context *ctx)
605607 uint32_t * pack_order , base_objects = 0 ;
606608 uint32_t i ;
607609
608- trace2_region_enter ("midx" , "midx_pack_order" , the_repository );
610+ trace2_region_enter ("midx" , "midx_pack_order" , ctx -> repo );
609611
610612 if (ctx -> incremental && ctx -> base_midx )
611613 base_objects = ctx -> base_midx -> num_objects +
@@ -640,7 +642,7 @@ static uint32_t *midx_pack_order(struct write_midx_context *ctx)
640642 }
641643 free (data );
642644
643- trace2_region_leave ("midx" , "midx_pack_order" , the_repository );
645+ trace2_region_leave ("midx" , "midx_pack_order" , ctx -> repo );
644646
645647 return pack_order ;
646648}
@@ -651,9 +653,10 @@ static void write_midx_reverse_index(char *midx_name, unsigned char *midx_hash,
651653 struct strbuf buf = STRBUF_INIT ;
652654 char * tmp_file ;
653655
654- trace2_region_enter ("midx" , "write_midx_reverse_index" , the_repository );
656+ trace2_region_enter ("midx" , "write_midx_reverse_index" , ctx -> repo );
655657
656- strbuf_addf (& buf , "%s-%s.rev" , midx_name , hash_to_hex (midx_hash ));
658+ strbuf_addf (& buf , "%s-%s.rev" , midx_name , hash_to_hex_algop (midx_hash ,
659+ ctx -> repo -> hash_algo ));
657660
658661 tmp_file = write_rev_file_order (NULL , ctx -> pack_order , ctx -> entries_nr ,
659662 midx_hash , WRITE_REV );
@@ -664,18 +667,18 @@ static void write_midx_reverse_index(char *midx_name, unsigned char *midx_hash,
664667 strbuf_release (& buf );
665668 free (tmp_file );
666669
667- trace2_region_leave ("midx" , "write_midx_reverse_index" , the_repository );
670+ trace2_region_leave ("midx" , "write_midx_reverse_index" , ctx -> repo );
668671}
669672
670673static void prepare_midx_packing_data (struct packing_data * pdata ,
671674 struct write_midx_context * ctx )
672675{
673676 uint32_t i ;
674677
675- trace2_region_enter ("midx" , "prepare_midx_packing_data" , the_repository );
678+ trace2_region_enter ("midx" , "prepare_midx_packing_data" , ctx -> repo );
676679
677680 memset (pdata , 0 , sizeof (struct packing_data ));
678- prepare_packing_data (the_repository , pdata );
681+ prepare_packing_data (ctx -> repo , pdata );
679682
680683 for (i = 0 ; i < ctx -> entries_nr ; i ++ ) {
681684 uint32_t pos = ctx -> pack_order [i ];
@@ -686,7 +689,7 @@ static void prepare_midx_packing_data(struct packing_data *pdata,
686689 ctx -> info [ctx -> pack_perm [from -> pack_int_id ]].p );
687690 }
688691
689- trace2_region_leave ("midx" , "prepare_midx_packing_data" , the_repository );
692+ trace2_region_leave ("midx" , "prepare_midx_packing_data" , ctx -> repo );
690693}
691694
692695static int add_ref_to_pending (const char * refname , const char * referent UNUSED ,
@@ -784,17 +787,16 @@ static struct commit **find_commits_for_midx_bitmap(uint32_t *indexed_commits_nr
784787 struct rev_info revs ;
785788 struct bitmap_commit_cb cb = {0 };
786789
787- trace2_region_enter ("midx" , "find_commits_for_midx_bitmap" ,
788- the_repository );
790+ trace2_region_enter ("midx" , "find_commits_for_midx_bitmap" , ctx -> repo );
789791
790792 cb .ctx = ctx ;
791793
792- repo_init_revisions (the_repository , & revs , NULL );
794+ repo_init_revisions (ctx -> repo , & revs , NULL );
793795 if (refs_snapshot ) {
794796 read_refs_snapshot (refs_snapshot , & revs );
795797 } else {
796798 setup_revisions (0 , NULL , & revs , NULL );
797- refs_for_each_ref (get_main_ref_store (the_repository ),
799+ refs_for_each_ref (get_main_ref_store (ctx -> repo ),
798800 add_ref_to_pending , & revs );
799801 }
800802
@@ -822,8 +824,7 @@ static struct commit **find_commits_for_midx_bitmap(uint32_t *indexed_commits_nr
822824
823825 release_revisions (& revs );
824826
825- trace2_region_leave ("midx" , "find_commits_for_midx_bitmap" ,
826- the_repository );
827+ trace2_region_leave ("midx" , "find_commits_for_midx_bitmap" , ctx -> repo );
827828
828829 return cb .commits ;
829830}
@@ -945,7 +946,7 @@ static int fill_packs_from_midx(struct write_midx_context *ctx,
945946 */
946947 if (flags & MIDX_WRITE_REV_INDEX ||
947948 preferred_pack_name ) {
948- if (prepare_midx_pack (the_repository , m ,
949+ if (prepare_midx_pack (ctx -> repo , m ,
949950 m -> num_packs_in_base + i )) {
950951 error (_ ("could not load pack" ));
951952 return 1 ;
@@ -1073,6 +1074,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
10731074
10741075 trace2_region_enter ("midx" , "write_midx_internal" , r );
10751076
1077+ ctx .repo = r ;
10761078
10771079 ctx .incremental = !!(flags & MIDX_WRITE_INCREMENTAL );
10781080 if (ctx .incremental && (flags & MIDX_WRITE_BITMAP ))
@@ -1469,7 +1471,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
14691471 }
14701472
14711473 if (ctx .m || ctx .base_midx )
1472- close_object_store (the_repository -> objects );
1474+ close_object_store (ctx . repo -> objects );
14731475
14741476 if (commit_lock_file (& lk ) < 0 )
14751477 die_errno (_ ("could not write multi-pack-index" ));
0 commit comments