1
- #define USE_THE_REPOSITORY_VARIABLE
2
-
3
1
#include "git-compat-util.h"
4
2
#include "commit.h"
5
3
#include "gettext.h"
@@ -177,12 +175,21 @@ static uint32_t bitmap_num_objects(struct bitmap_index *index)
177
175
return index -> pack -> num_objects ;
178
176
}
179
177
178
+ static struct repository * bitmap_repo (struct bitmap_index * bitmap_git )
179
+ {
180
+ if (bitmap_is_midx (bitmap_git ))
181
+ return bitmap_git -> midx -> repo ;
182
+ return bitmap_git -> pack -> repo ;
183
+ }
184
+
180
185
static int load_bitmap_header (struct bitmap_index * index )
181
186
{
182
187
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 ;
184
191
185
- if (index -> map_size < header_size + the_hash_algo -> rawsz )
192
+ if (index -> map_size < header_size + hash_algo -> rawsz )
186
193
return error (_ ("corrupted bitmap index (too small)" ));
187
194
188
195
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)
196
203
{
197
204
uint32_t flags = ntohs (header -> options );
198
205
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 ;
200
207
201
208
if ((flags & BITMAP_OPT_FULL_DAG ) == 0 )
202
209
BUG ("unsupported options for bitmap index file "
@@ -409,7 +416,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
409
416
if (bitmap_git -> pack || bitmap_git -> midx ) {
410
417
struct strbuf buf = STRBUF_INIT ;
411
418
get_midx_filename (& buf , midx -> object_dir );
412
- trace2_data_string ("bitmap" , the_repository ,
419
+ trace2_data_string ("bitmap" , bitmap_repo ( bitmap_git ) ,
413
420
"ignoring extra midx bitmap file" , buf .buf );
414
421
close (fd );
415
422
strbuf_release (& buf );
@@ -427,7 +434,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
427
434
goto cleanup ;
428
435
429
436
if (!hasheq (get_midx_checksum (bitmap_git -> midx ), bitmap_git -> checksum ,
430
- the_repository -> hash_algo )) {
437
+ bitmap_repo ( bitmap_git ) -> hash_algo )) {
431
438
error (_ ("checksum doesn't match in MIDX and bitmap" ));
432
439
goto cleanup ;
433
440
}
@@ -438,7 +445,9 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
438
445
}
439
446
440
447
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 )) {
442
451
warning (_ ("could not open pack %s" ),
443
452
bitmap_git -> midx -> pack_names [i ]);
444
453
goto cleanup ;
@@ -492,8 +501,9 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
492
501
}
493
502
494
503
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 );
497
507
close (fd );
498
508
return -1 ;
499
509
}
@@ -518,8 +528,8 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
518
528
return -1 ;
519
529
}
520
530
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 );
523
533
return 0 ;
524
534
}
525
535
@@ -649,7 +659,7 @@ struct bitmap_index *prepare_bitmap_git(struct repository *r)
649
659
650
660
struct bitmap_index * prepare_midx_bitmap_git (struct multi_pack_index * midx )
651
661
{
652
- struct repository * r = the_repository ;
662
+ struct repository * r = midx -> repo ;
653
663
struct bitmap_index * bitmap_git = xcalloc (1 , sizeof (* bitmap_git ));
654
664
655
665
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,
1213
1223
{
1214
1224
struct bitmap_boundary_cb cb ;
1215
1225
struct object_list * root ;
1226
+ struct repository * repo ;
1216
1227
unsigned int i ;
1217
1228
unsigned int tmp_blobs , tmp_trees , tmp_tags ;
1218
1229
int any_missing = 0 ;
@@ -1222,6 +1233,8 @@ static struct bitmap *find_boundary_objects(struct bitmap_index *bitmap_git,
1222
1233
cb .base = bitmap_new ();
1223
1234
object_array_init (& cb .boundary );
1224
1235
1236
+ repo = bitmap_repo (bitmap_git );
1237
+
1225
1238
revs -> ignore_missing_links = 1 ;
1226
1239
1227
1240
if (bitmap_git -> pseudo_merges .nr ) {
@@ -1280,19 +1293,19 @@ static struct bitmap *find_boundary_objects(struct bitmap_index *bitmap_git,
1280
1293
* revision walk to (a) OR in any bitmaps that are UNINTERESTING
1281
1294
* between the tips and boundary, and (b) record the boundary.
1282
1295
*/
1283
- trace2_region_enter ("pack-bitmap" , "boundary-prepare" , the_repository );
1296
+ trace2_region_enter ("pack-bitmap" , "boundary-prepare" , repo );
1284
1297
if (prepare_revision_walk (revs ))
1285
1298
die ("revision walk setup failed" );
1286
- trace2_region_leave ("pack-bitmap" , "boundary-prepare" , the_repository );
1299
+ trace2_region_leave ("pack-bitmap" , "boundary-prepare" , repo );
1287
1300
1288
- trace2_region_enter ("pack-bitmap" , "boundary-traverse" , the_repository );
1301
+ trace2_region_enter ("pack-bitmap" , "boundary-traverse" , repo );
1289
1302
revs -> boundary = 1 ;
1290
1303
traverse_commit_list_filtered (revs ,
1291
1304
show_boundary_commit ,
1292
1305
show_boundary_object ,
1293
1306
& cb , NULL );
1294
1307
revs -> boundary = 0 ;
1295
- trace2_region_leave ("pack-bitmap" , "boundary-traverse" , the_repository );
1308
+ trace2_region_leave ("pack-bitmap" , "boundary-traverse" , repo );
1296
1309
1297
1310
revs -> blob_objects = tmp_blobs ;
1298
1311
revs -> tree_objects = tmp_trees ;
@@ -1304,7 +1317,7 @@ static struct bitmap *find_boundary_objects(struct bitmap_index *bitmap_git,
1304
1317
/*
1305
1318
* Then add the boundary commit(s) as fill-in traversal tips.
1306
1319
*/
1307
- trace2_region_enter ("pack-bitmap" , "boundary-fill-in" , the_repository );
1320
+ trace2_region_enter ("pack-bitmap" , "boundary-fill-in" , repo );
1308
1321
for (i = 0 ; i < cb .boundary .nr ; i ++ ) {
1309
1322
struct object * obj = cb .boundary .objects [i ].item ;
1310
1323
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,
1314
1327
}
1315
1328
if (revs -> pending .nr )
1316
1329
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 );
1318
1331
1319
1332
cleanup :
1320
1333
object_array_clear (& cb .boundary );
@@ -1718,7 +1731,8 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
1718
1731
ofs = pack_pos_to_offset (pack , pos );
1719
1732
}
1720
1733
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 ) {
1722
1736
struct object_id oid ;
1723
1737
nth_bitmap_object_oid (bitmap_git , & oid ,
1724
1738
pack_pos_to_index (pack , pos ));
@@ -1727,7 +1741,8 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
1727
1741
} else {
1728
1742
struct eindex * eindex = & bitmap_git -> ext_index ;
1729
1743
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 )
1731
1746
die (_ ("unable to get size of %s" ), oid_to_hex (& obj -> oid ));
1732
1747
}
1733
1748
@@ -1889,7 +1904,8 @@ static void filter_packed_objects_from_bitmap(struct bitmap_index *bitmap_git,
1889
1904
bitmap_unset (result , i );
1890
1905
1891
1906
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 ))
1893
1909
bitmap_unset (result , objects_nr + i );
1894
1910
}
1895
1911
}
@@ -1907,6 +1923,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
1907
1923
struct bitmap * haves_bitmap = NULL ;
1908
1924
1909
1925
struct bitmap_index * bitmap_git ;
1926
+ struct repository * repo ;
1910
1927
1911
1928
/*
1912
1929
* We can't do pathspec limiting with bitmaps, because we don't know
@@ -1980,18 +1997,20 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
1980
1997
if (!use_boundary_traversal )
1981
1998
object_array_clear (& revs -> pending );
1982
1999
2000
+ repo = bitmap_repo (bitmap_git );
2001
+
1983
2002
if (haves ) {
1984
2003
if (use_boundary_traversal ) {
1985
- trace2_region_enter ("pack-bitmap" , "haves/boundary" , the_repository );
2004
+ trace2_region_enter ("pack-bitmap" , "haves/boundary" , repo );
1986
2005
haves_bitmap = find_boundary_objects (bitmap_git , revs , haves );
1987
- trace2_region_leave ("pack-bitmap" , "haves/boundary" , the_repository );
2006
+ trace2_region_leave ("pack-bitmap" , "haves/boundary" , repo );
1988
2007
} else {
1989
- trace2_region_enter ("pack-bitmap" , "haves/classic" , the_repository );
2008
+ trace2_region_enter ("pack-bitmap" , "haves/classic" , repo );
1990
2009
revs -> ignore_missing_links = 1 ;
1991
2010
haves_bitmap = find_objects (bitmap_git , revs , haves , NULL );
1992
2011
reset_revision_walk ();
1993
2012
revs -> ignore_missing_links = 0 ;
1994
- trace2_region_leave ("pack-bitmap" , "haves/classic" , the_repository );
2013
+ trace2_region_leave ("pack-bitmap" , "haves/classic" , repo );
1995
2014
}
1996
2015
1997
2016
if (!haves_bitmap )
@@ -2025,17 +2044,17 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
2025
2044
object_list_free (& wants );
2026
2045
object_list_free (& haves );
2027
2046
2028
- trace2_data_intmax ("bitmap" , the_repository , "pseudo_merges_satisfied" ,
2047
+ trace2_data_intmax ("bitmap" , repo , "pseudo_merges_satisfied" ,
2029
2048
pseudo_merges_satisfied_nr );
2030
- trace2_data_intmax ("bitmap" , the_repository , "pseudo_merges_cascades" ,
2049
+ trace2_data_intmax ("bitmap" , repo , "pseudo_merges_cascades" ,
2031
2050
pseudo_merges_cascades_nr );
2032
- trace2_data_intmax ("bitmap" , the_repository , "bitmap/hits" ,
2051
+ trace2_data_intmax ("bitmap" , repo , "bitmap/hits" ,
2033
2052
existing_bitmaps_hits_nr );
2034
- trace2_data_intmax ("bitmap" , the_repository , "bitmap/misses" ,
2053
+ trace2_data_intmax ("bitmap" , repo , "bitmap/misses" ,
2035
2054
existing_bitmaps_misses_nr );
2036
- trace2_data_intmax ("bitmap" , the_repository , "bitmap/roots_with_bitmap" ,
2055
+ trace2_data_intmax ("bitmap" , repo , "bitmap/roots_with_bitmap" ,
2037
2056
roots_with_bitmaps_nr );
2038
- trace2_data_intmax ("bitmap" , the_repository , "bitmap/roots_without_bitmap" ,
2057
+ trace2_data_intmax ("bitmap" , repo , "bitmap/roots_without_bitmap" ,
2039
2058
roots_without_bitmaps_nr );
2040
2059
2041
2060
return bitmap_git ;
@@ -2256,7 +2275,7 @@ void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
2256
2275
struct bitmap * * reuse_out ,
2257
2276
int multi_pack_reuse )
2258
2277
{
2259
- struct repository * r = the_repository ;
2278
+ struct repository * r = bitmap_repo ( bitmap_git ) ;
2260
2279
struct bitmapped_pack * packs = NULL ;
2261
2280
struct bitmap * result = bitmap_git -> result ;
2262
2281
struct bitmap * reuse ;
@@ -2792,7 +2811,7 @@ int rebuild_bitmap(const uint32_t *reposition,
2792
2811
uint32_t * create_bitmap_mapping (struct bitmap_index * bitmap_git ,
2793
2812
struct packing_data * mapping )
2794
2813
{
2795
- struct repository * r = the_repository ;
2814
+ struct repository * r = bitmap_repo ( bitmap_git ) ;
2796
2815
uint32_t i , num_objects ;
2797
2816
uint32_t * reposition ;
2798
2817
@@ -2948,7 +2967,8 @@ static off_t get_disk_usage_for_extended(struct bitmap_index *bitmap_git)
2948
2967
st_add (bitmap_num_objects (bitmap_git ), i )))
2949
2968
continue ;
2950
2969
2951
- if (oid_object_info_extended (the_repository , & obj -> oid , & oi , 0 ) < 0 )
2970
+ if (oid_object_info_extended (bitmap_repo (bitmap_git ), & obj -> oid ,
2971
+ & oi , 0 ) < 0 )
2952
2972
die (_ ("unable to get disk usage of '%s'" ),
2953
2973
oid_to_hex (& obj -> oid ));
2954
2974
0 commit comments