@@ -110,6 +110,8 @@ struct write_midx_context {
110
110
uint32_t num_multi_pack_indexes_before ;
111
111
112
112
struct string_list * to_include ;
113
+
114
+ struct repository * repo ;
113
115
};
114
116
115
117
static 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,
154
156
return ;
155
157
156
158
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 );
158
160
if (!p ) {
159
161
warning (_ ("failed to add packfile '%s'" ),
160
162
full_path );
@@ -480,7 +482,7 @@ static int write_midx_oid_lookup(struct hashfile *f,
480
482
void * data )
481
483
{
482
484
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 ;
484
486
struct pack_midx_entry * list = ctx -> entries ;
485
487
uint32_t i ;
486
488
@@ -605,7 +607,7 @@ static uint32_t *midx_pack_order(struct write_midx_context *ctx)
605
607
uint32_t * pack_order , base_objects = 0 ;
606
608
uint32_t i ;
607
609
608
- trace2_region_enter ("midx" , "midx_pack_order" , the_repository );
610
+ trace2_region_enter ("midx" , "midx_pack_order" , ctx -> repo );
609
611
610
612
if (ctx -> incremental && ctx -> base_midx )
611
613
base_objects = ctx -> base_midx -> num_objects +
@@ -640,7 +642,7 @@ static uint32_t *midx_pack_order(struct write_midx_context *ctx)
640
642
}
641
643
free (data );
642
644
643
- trace2_region_leave ("midx" , "midx_pack_order" , the_repository );
645
+ trace2_region_leave ("midx" , "midx_pack_order" , ctx -> repo );
644
646
645
647
return pack_order ;
646
648
}
@@ -651,9 +653,10 @@ static void write_midx_reverse_index(char *midx_name, unsigned char *midx_hash,
651
653
struct strbuf buf = STRBUF_INIT ;
652
654
char * tmp_file ;
653
655
654
- trace2_region_enter ("midx" , "write_midx_reverse_index" , the_repository );
656
+ trace2_region_enter ("midx" , "write_midx_reverse_index" , ctx -> repo );
655
657
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 ));
657
660
658
661
tmp_file = write_rev_file_order (NULL , ctx -> pack_order , ctx -> entries_nr ,
659
662
midx_hash , WRITE_REV );
@@ -664,18 +667,18 @@ static void write_midx_reverse_index(char *midx_name, unsigned char *midx_hash,
664
667
strbuf_release (& buf );
665
668
free (tmp_file );
666
669
667
- trace2_region_leave ("midx" , "write_midx_reverse_index" , the_repository );
670
+ trace2_region_leave ("midx" , "write_midx_reverse_index" , ctx -> repo );
668
671
}
669
672
670
673
static void prepare_midx_packing_data (struct packing_data * pdata ,
671
674
struct write_midx_context * ctx )
672
675
{
673
676
uint32_t i ;
674
677
675
- trace2_region_enter ("midx" , "prepare_midx_packing_data" , the_repository );
678
+ trace2_region_enter ("midx" , "prepare_midx_packing_data" , ctx -> repo );
676
679
677
680
memset (pdata , 0 , sizeof (struct packing_data ));
678
- prepare_packing_data (the_repository , pdata );
681
+ prepare_packing_data (ctx -> repo , pdata );
679
682
680
683
for (i = 0 ; i < ctx -> entries_nr ; i ++ ) {
681
684
uint32_t pos = ctx -> pack_order [i ];
@@ -686,7 +689,7 @@ static void prepare_midx_packing_data(struct packing_data *pdata,
686
689
ctx -> info [ctx -> pack_perm [from -> pack_int_id ]].p );
687
690
}
688
691
689
- trace2_region_leave ("midx" , "prepare_midx_packing_data" , the_repository );
692
+ trace2_region_leave ("midx" , "prepare_midx_packing_data" , ctx -> repo );
690
693
}
691
694
692
695
static 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
784
787
struct rev_info revs ;
785
788
struct bitmap_commit_cb cb = {0 };
786
789
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 );
789
791
790
792
cb .ctx = ctx ;
791
793
792
- repo_init_revisions (the_repository , & revs , NULL );
794
+ repo_init_revisions (ctx -> repo , & revs , NULL );
793
795
if (refs_snapshot ) {
794
796
read_refs_snapshot (refs_snapshot , & revs );
795
797
} else {
796
798
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 ),
798
800
add_ref_to_pending , & revs );
799
801
}
800
802
@@ -822,8 +824,7 @@ static struct commit **find_commits_for_midx_bitmap(uint32_t *indexed_commits_nr
822
824
823
825
release_revisions (& revs );
824
826
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 );
827
828
828
829
return cb .commits ;
829
830
}
@@ -945,7 +946,7 @@ static int fill_packs_from_midx(struct write_midx_context *ctx,
945
946
*/
946
947
if (flags & MIDX_WRITE_REV_INDEX ||
947
948
preferred_pack_name ) {
948
- if (prepare_midx_pack (the_repository , m ,
949
+ if (prepare_midx_pack (ctx -> repo , m ,
949
950
m -> num_packs_in_base + i )) {
950
951
error (_ ("could not load pack" ));
951
952
return 1 ;
@@ -1073,6 +1074,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1073
1074
1074
1075
trace2_region_enter ("midx" , "write_midx_internal" , r );
1075
1076
1077
+ ctx .repo = r ;
1076
1078
1077
1079
ctx .incremental = !!(flags & MIDX_WRITE_INCREMENTAL );
1078
1080
if (ctx .incremental && (flags & MIDX_WRITE_BITMAP ))
@@ -1469,7 +1471,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1469
1471
}
1470
1472
1471
1473
if (ctx .m || ctx .base_midx )
1472
- close_object_store (the_repository -> objects );
1474
+ close_object_store (ctx . repo -> objects );
1473
1475
1474
1476
if (commit_lock_file (& lk ) < 0 )
1475
1477
die_errno (_ ("could not write multi-pack-index" ));
0 commit comments