@@ -380,6 +380,16 @@ struct include_data {
380
380
struct bitmap * seen ;
381
381
};
382
382
383
+ struct ewah_bitmap * bitmap_for_commit (struct bitmap_index * bitmap_git ,
384
+ struct commit * commit )
385
+ {
386
+ khiter_t hash_pos = kh_get_oid_map (bitmap_git -> bitmaps ,
387
+ commit -> object .oid );
388
+ if (hash_pos >= kh_end (bitmap_git -> bitmaps ))
389
+ return NULL ;
390
+ return lookup_stored_bitmap (kh_value (bitmap_git -> bitmaps , hash_pos ));
391
+ }
392
+
383
393
static inline int bitmap_position_extended (struct bitmap_index * bitmap_git ,
384
394
const struct object_id * oid )
385
395
{
@@ -465,21 +475,20 @@ static void show_commit(struct commit *commit, void *data)
465
475
466
476
static int add_to_include_set (struct bitmap_index * bitmap_git ,
467
477
struct include_data * data ,
468
- const struct object_id * oid ,
478
+ struct commit * commit ,
469
479
int bitmap_pos )
470
480
{
471
- khiter_t hash_pos ;
481
+ struct ewah_bitmap * partial ;
472
482
473
483
if (data -> seen && bitmap_get (data -> seen , bitmap_pos ))
474
484
return 0 ;
475
485
476
486
if (bitmap_get (data -> base , bitmap_pos ))
477
487
return 0 ;
478
488
479
- hash_pos = kh_get_oid_map (bitmap_git -> bitmaps , * oid );
480
- if (hash_pos < kh_end (bitmap_git -> bitmaps )) {
481
- struct stored_bitmap * st = kh_value (bitmap_git -> bitmaps , hash_pos );
482
- bitmap_or_ewah (data -> base , lookup_stored_bitmap (st ));
489
+ partial = bitmap_for_commit (bitmap_git , commit );
490
+ if (partial ) {
491
+ bitmap_or_ewah (data -> base , partial );
483
492
return 0 ;
484
493
}
485
494
@@ -498,8 +507,7 @@ static int should_include(struct commit *commit, void *_data)
498
507
(struct object * )commit ,
499
508
NULL );
500
509
501
- if (!add_to_include_set (data -> bitmap_git , data , & commit -> object .oid ,
502
- bitmap_pos )) {
510
+ if (!add_to_include_set (data -> bitmap_git , data , commit , bitmap_pos )) {
503
511
struct commit_list * parent = commit -> parents ;
504
512
505
513
while (parent ) {
@@ -1282,10 +1290,10 @@ void test_bitmap_walk(struct rev_info *revs)
1282
1290
{
1283
1291
struct object * root ;
1284
1292
struct bitmap * result = NULL ;
1285
- khiter_t pos ;
1286
1293
size_t result_popcnt ;
1287
1294
struct bitmap_test_data tdata ;
1288
1295
struct bitmap_index * bitmap_git ;
1296
+ struct ewah_bitmap * bm ;
1289
1297
1290
1298
if (!(bitmap_git = prepare_bitmap_git (revs -> repo )))
1291
1299
die ("failed to load bitmap indexes" );
@@ -1297,12 +1305,9 @@ void test_bitmap_walk(struct rev_info *revs)
1297
1305
bitmap_git -> version , bitmap_git -> entry_count );
1298
1306
1299
1307
root = revs -> pending .objects [0 ].item ;
1300
- pos = kh_get_oid_map (bitmap_git -> bitmaps , root -> oid );
1301
-
1302
- if (pos < kh_end (bitmap_git -> bitmaps )) {
1303
- struct stored_bitmap * st = kh_value (bitmap_git -> bitmaps , pos );
1304
- struct ewah_bitmap * bm = lookup_stored_bitmap (st );
1308
+ bm = bitmap_for_commit (bitmap_git , (struct commit * )root );
1305
1309
1310
+ if (bm ) {
1306
1311
fprintf (stderr , "Found bitmap for %s. %d bits / %08x checksum\n" ,
1307
1312
oid_to_hex (& root -> oid ), (int )bm -> bit_size , ewah_checksum (bm ));
1308
1313
0 commit comments