1- #define USE_THE_REPOSITORY_VARIABLE
2-
31#include "git-compat-util.h"
42#include "commit.h"
53#include "gettext.h"
@@ -177,12 +175,21 @@ static uint32_t bitmap_num_objects(struct bitmap_index *index)
177175 return index -> pack -> num_objects ;
178176}
179177
178+ static struct repository * bitmap_repo (struct bitmap_index * bitmap_git )
179+ {
180+ if (bitmap_is_midx (bitmap_git ))
181+ return bitmap_git -> midx -> r ;
182+ return bitmap_git -> pack -> r ;
183+ }
184+
180185static int load_bitmap_header (struct bitmap_index * index )
181186{
182187 struct bitmap_disk_header * header = (void * )index -> map ;
183- size_t header_size = sizeof (* header ) - GIT_MAX_RAWSZ + the_hash_algo -> rawsz ;
188+ const struct git_hash_algo * hash_algo = bitmap_repo (index )-> hash_algo ;
189+
190+ size_t header_size = sizeof (* header ) - GIT_MAX_RAWSZ + hash_algo -> rawsz ;
184191
185- if (index -> map_size < header_size + the_hash_algo -> rawsz )
192+ if (index -> map_size < header_size + hash_algo -> rawsz )
186193 return error (_ ("corrupted bitmap index (too small)" ));
187194
188195 if (memcmp (header -> magic , BITMAP_IDX_SIGNATURE , sizeof (BITMAP_IDX_SIGNATURE )) != 0 )
@@ -196,7 +203,7 @@ static int load_bitmap_header(struct bitmap_index *index)
196203 {
197204 uint32_t flags = ntohs (header -> options );
198205 size_t cache_size = st_mult (bitmap_num_objects (index ), sizeof (uint32_t ));
199- unsigned char * index_end = index -> map + index -> map_size - the_hash_algo -> rawsz ;
206+ unsigned char * index_end = index -> map + index -> map_size - hash_algo -> rawsz ;
200207
201208 if ((flags & BITMAP_OPT_FULL_DAG ) == 0 )
202209 BUG ("unsupported options for bitmap index file "
@@ -409,7 +416,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
409416 if (bitmap_git -> pack || bitmap_git -> midx ) {
410417 struct strbuf buf = STRBUF_INIT ;
411418 get_midx_filename (& buf , midx -> object_dir );
412- trace2_data_string ("bitmap" , the_repository ,
419+ trace2_data_string ("bitmap" , bitmap_repo ( bitmap_git ) ,
413420 "ignoring extra midx bitmap file" , buf .buf );
414421 close (fd );
415422 strbuf_release (& buf );
@@ -427,7 +434,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
427434 goto cleanup ;
428435
429436 if (!hasheq (get_midx_checksum (bitmap_git -> midx ), bitmap_git -> checksum ,
430- the_repository -> hash_algo )) {
437+ bitmap_repo ( bitmap_git ) -> hash_algo )) {
431438 error (_ ("checksum doesn't match in MIDX and bitmap" ));
432439 goto cleanup ;
433440 }
@@ -438,7 +445,9 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
438445 }
439446
440447 for (i = 0 ; i < bitmap_git -> midx -> num_packs ; i ++ ) {
441- if (prepare_midx_pack (the_repository , bitmap_git -> midx , i )) {
448+ if (prepare_midx_pack (bitmap_repo (bitmap_git ),
449+ bitmap_git -> midx ,
450+ i )) {
442451 warning (_ ("could not open pack %s" ),
443452 bitmap_git -> midx -> pack_names [i ]);
444453 goto cleanup ;
@@ -492,8 +501,9 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
492501 }
493502
494503 if (bitmap_git -> pack || bitmap_git -> midx ) {
495- trace2_data_string ("bitmap" , the_repository ,
496- "ignoring extra bitmap file" , packfile -> pack_name );
504+ trace2_data_string ("bitmap" , bitmap_repo (bitmap_git ),
505+ "ignoring extra bitmap file" ,
506+ packfile -> pack_name );
497507 close (fd );
498508 return -1 ;
499509 }
@@ -518,8 +528,8 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
518528 return -1 ;
519529 }
520530
521- trace2_data_string ("bitmap" , the_repository , "opened bitmap file" ,
522- packfile -> pack_name );
531+ trace2_data_string ("bitmap" , bitmap_repo ( bitmap_git ) ,
532+ "opened bitmap file" , packfile -> pack_name );
523533 return 0 ;
524534}
525535
@@ -649,7 +659,7 @@ struct bitmap_index *prepare_bitmap_git(struct repository *r)
649659
650660struct bitmap_index * prepare_midx_bitmap_git (struct multi_pack_index * midx )
651661{
652- struct repository * r = the_repository ;
662+ struct repository * r = midx -> r ;
653663 struct bitmap_index * bitmap_git = xcalloc (1 , sizeof (* bitmap_git ));
654664
655665 if (!open_midx_bitmap_1 (bitmap_git , midx ) && !load_bitmap (r , bitmap_git ))
@@ -1213,6 +1223,7 @@ static struct bitmap *find_boundary_objects(struct bitmap_index *bitmap_git,
12131223{
12141224 struct bitmap_boundary_cb cb ;
12151225 struct object_list * root ;
1226+ struct repository * repo ;
12161227 unsigned int i ;
12171228 unsigned int tmp_blobs , tmp_trees , tmp_tags ;
12181229 int any_missing = 0 ;
@@ -1222,6 +1233,8 @@ static struct bitmap *find_boundary_objects(struct bitmap_index *bitmap_git,
12221233 cb .base = bitmap_new ();
12231234 object_array_init (& cb .boundary );
12241235
1236+ repo = bitmap_repo (bitmap_git );
1237+
12251238 revs -> ignore_missing_links = 1 ;
12261239
12271240 if (bitmap_git -> pseudo_merges .nr ) {
@@ -1280,19 +1293,19 @@ static struct bitmap *find_boundary_objects(struct bitmap_index *bitmap_git,
12801293 * revision walk to (a) OR in any bitmaps that are UNINTERESTING
12811294 * between the tips and boundary, and (b) record the boundary.
12821295 */
1283- trace2_region_enter ("pack-bitmap" , "boundary-prepare" , the_repository );
1296+ trace2_region_enter ("pack-bitmap" , "boundary-prepare" , repo );
12841297 if (prepare_revision_walk (revs ))
12851298 die ("revision walk setup failed" );
1286- trace2_region_leave ("pack-bitmap" , "boundary-prepare" , the_repository );
1299+ trace2_region_leave ("pack-bitmap" , "boundary-prepare" , repo );
12871300
1288- trace2_region_enter ("pack-bitmap" , "boundary-traverse" , the_repository );
1301+ trace2_region_enter ("pack-bitmap" , "boundary-traverse" , repo );
12891302 revs -> boundary = 1 ;
12901303 traverse_commit_list_filtered (revs ,
12911304 show_boundary_commit ,
12921305 show_boundary_object ,
12931306 & cb , NULL );
12941307 revs -> boundary = 0 ;
1295- trace2_region_leave ("pack-bitmap" , "boundary-traverse" , the_repository );
1308+ trace2_region_leave ("pack-bitmap" , "boundary-traverse" , repo );
12961309
12971310 revs -> blob_objects = tmp_blobs ;
12981311 revs -> tree_objects = tmp_trees ;
@@ -1304,7 +1317,7 @@ static struct bitmap *find_boundary_objects(struct bitmap_index *bitmap_git,
13041317 /*
13051318 * Then add the boundary commit(s) as fill-in traversal tips.
13061319 */
1307- trace2_region_enter ("pack-bitmap" , "boundary-fill-in" , the_repository );
1320+ trace2_region_enter ("pack-bitmap" , "boundary-fill-in" , repo );
13081321 for (i = 0 ; i < cb .boundary .nr ; i ++ ) {
13091322 struct object * obj = cb .boundary .objects [i ].item ;
13101323 if (bitmap_walk_contains (bitmap_git , cb .base , & obj -> oid ))
@@ -1314,7 +1327,7 @@ static struct bitmap *find_boundary_objects(struct bitmap_index *bitmap_git,
13141327 }
13151328 if (revs -> pending .nr )
13161329 cb .base = fill_in_bitmap (bitmap_git , revs , cb .base , NULL );
1317- trace2_region_leave ("pack-bitmap" , "boundary-fill-in" , the_repository );
1330+ trace2_region_leave ("pack-bitmap" , "boundary-fill-in" , repo );
13181331
13191332cleanup :
13201333 object_array_clear (& cb .boundary );
@@ -1718,7 +1731,8 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
17181731 ofs = pack_pos_to_offset (pack , pos );
17191732 }
17201733
1721- if (packed_object_info (the_repository , pack , ofs , & oi ) < 0 ) {
1734+ if (packed_object_info (bitmap_repo (bitmap_git ), pack , ofs ,
1735+ & oi ) < 0 ) {
17221736 struct object_id oid ;
17231737 nth_bitmap_object_oid (bitmap_git , & oid ,
17241738 pack_pos_to_index (pack , pos ));
@@ -1727,7 +1741,8 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
17271741 } else {
17281742 struct eindex * eindex = & bitmap_git -> ext_index ;
17291743 struct object * obj = eindex -> objects [pos - bitmap_num_objects (bitmap_git )];
1730- if (oid_object_info_extended (the_repository , & obj -> oid , & oi , 0 ) < 0 )
1744+ if (oid_object_info_extended (bitmap_repo (bitmap_git ), & obj -> oid ,
1745+ & oi , 0 ) < 0 )
17311746 die (_ ("unable to get size of %s" ), oid_to_hex (& obj -> oid ));
17321747 }
17331748
@@ -1889,7 +1904,8 @@ static void filter_packed_objects_from_bitmap(struct bitmap_index *bitmap_git,
18891904 bitmap_unset (result , i );
18901905
18911906 for (i = 0 ; i < eindex -> count ; ++ i ) {
1892- if (has_object_pack (the_repository , & eindex -> objects [i ]-> oid ))
1907+ if (has_object_pack (bitmap_repo (bitmap_git ),
1908+ & eindex -> objects [i ]-> oid ))
18931909 bitmap_unset (result , objects_nr + i );
18941910 }
18951911}
@@ -1907,6 +1923,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
19071923 struct bitmap * haves_bitmap = NULL ;
19081924
19091925 struct bitmap_index * bitmap_git ;
1926+ struct repository * repo ;
19101927
19111928 /*
19121929 * We can't do pathspec limiting with bitmaps, because we don't know
@@ -1980,18 +1997,23 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
19801997 if (!use_boundary_traversal )
19811998 object_array_clear (& revs -> pending );
19821999
2000+ repo = bitmap_repo (bitmap_git );
2001+
19832002 if (haves ) {
1984- if (use_boundary_traversal ) {
1985- trace2_region_enter ("pack-bitmap" , "haves/boundary" , the_repository );
2003+ if (use_boundary_traversal )
2004+ {
2005+ trace2_region_enter ("pack-bitmap" , "haves/boundary" , repo );
19862006 haves_bitmap = find_boundary_objects (bitmap_git , revs , haves );
1987- trace2_region_leave ("pack-bitmap" , "haves/boundary" , the_repository );
1988- } else {
1989- trace2_region_enter ("pack-bitmap" , "haves/classic" , the_repository );
2007+ trace2_region_leave ("pack-bitmap" , "haves/boundary" , repo );
2008+ }
2009+ else
2010+ {
2011+ trace2_region_enter ("pack-bitmap" , "haves/classic" , repo );
19902012 revs -> ignore_missing_links = 1 ;
19912013 haves_bitmap = find_objects (bitmap_git , revs , haves , NULL );
19922014 reset_revision_walk ();
19932015 revs -> ignore_missing_links = 0 ;
1994- trace2_region_leave ("pack-bitmap" , "haves/classic" , the_repository );
2016+ trace2_region_leave ("pack-bitmap" , "haves/classic" , repo );
19952017 }
19962018
19972019 if (!haves_bitmap )
@@ -2025,17 +2047,17 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
20252047 object_list_free (& wants );
20262048 object_list_free (& haves );
20272049
2028- trace2_data_intmax ("bitmap" , the_repository , "pseudo_merges_satisfied" ,
2050+ trace2_data_intmax ("bitmap" , repo , "pseudo_merges_satisfied" ,
20292051 pseudo_merges_satisfied_nr );
2030- trace2_data_intmax ("bitmap" , the_repository , "pseudo_merges_cascades" ,
2052+ trace2_data_intmax ("bitmap" , repo , "pseudo_merges_cascades" ,
20312053 pseudo_merges_cascades_nr );
2032- trace2_data_intmax ("bitmap" , the_repository , "bitmap/hits" ,
2054+ trace2_data_intmax ("bitmap" , repo , "bitmap/hits" ,
20332055 existing_bitmaps_hits_nr );
2034- trace2_data_intmax ("bitmap" , the_repository , "bitmap/misses" ,
2056+ trace2_data_intmax ("bitmap" , repo , "bitmap/misses" ,
20352057 existing_bitmaps_misses_nr );
2036- trace2_data_intmax ("bitmap" , the_repository , "bitmap/roots_with_bitmap" ,
2058+ trace2_data_intmax ("bitmap" , repo , "bitmap/roots_with_bitmap" ,
20372059 roots_with_bitmaps_nr );
2038- trace2_data_intmax ("bitmap" , the_repository , "bitmap/roots_without_bitmap" ,
2060+ trace2_data_intmax ("bitmap" , repo , "bitmap/roots_without_bitmap" ,
20392061 roots_without_bitmaps_nr );
20402062
20412063 return bitmap_git ;
@@ -2256,7 +2278,7 @@ void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
22562278 struct bitmap * * reuse_out ,
22572279 int multi_pack_reuse )
22582280{
2259- struct repository * r = the_repository ;
2281+ struct repository * r = bitmap_repo ( bitmap_git ) ;
22602282 struct bitmapped_pack * packs = NULL ;
22612283 struct bitmap * result = bitmap_git -> result ;
22622284 struct bitmap * reuse ;
@@ -2792,7 +2814,7 @@ int rebuild_bitmap(const uint32_t *reposition,
27922814uint32_t * create_bitmap_mapping (struct bitmap_index * bitmap_git ,
27932815 struct packing_data * mapping )
27942816{
2795- struct repository * r = the_repository ;
2817+ struct repository * r = bitmap_repo ( bitmap_git ) ;
27962818 uint32_t i , num_objects ;
27972819 uint32_t * reposition ;
27982820
@@ -2948,7 +2970,8 @@ static off_t get_disk_usage_for_extended(struct bitmap_index *bitmap_git)
29482970 st_add (bitmap_num_objects (bitmap_git ), i )))
29492971 continue ;
29502972
2951- if (oid_object_info_extended (the_repository , & obj -> oid , & oi , 0 ) < 0 )
2973+ if (oid_object_info_extended (bitmap_repo (bitmap_git ), & obj -> oid ,
2974+ & oi , 0 ) < 0 )
29522975 die (_ ("unable to get disk usage of '%s'" ),
29532976 oid_to_hex (& obj -> oid ));
29542977
0 commit comments