@@ -81,6 +81,23 @@ struct bitmap_index {
81
81
struct ewah_bitmap * blobs ;
82
82
struct ewah_bitmap * tags ;
83
83
84
+ /*
85
+ * Type index arrays when this bitmap is associated with an
86
+ * incremental multi-pack index chain.
87
+ *
88
+ * If n is the number of unique layers in the MIDX chain, then
89
+ * commits_all[n-1] is this structs 'commits' field,
90
+ * commits_all[n-2] is the commits field of this bitmap's
91
+ * 'base', and so on.
92
+ *
93
+ * When associated either with a non-incremental MIDX or a
94
+ * single packfile, these arrays each contain a single element.
95
+ */
96
+ struct ewah_bitmap * * commits_all ;
97
+ struct ewah_bitmap * * trees_all ;
98
+ struct ewah_bitmap * * blobs_all ;
99
+ struct ewah_bitmap * * tags_all ;
100
+
84
101
/* Map from object ID -> `stored_bitmap` for all the bitmapped commits */
85
102
kh_oid_map_t * bitmaps ;
86
103
@@ -581,7 +598,32 @@ static int load_reverse_index(struct repository *r, struct bitmap_index *bitmap_
581
598
return load_pack_revindex (r , bitmap_git -> pack );
582
599
}
583
600
584
- static int load_bitmap (struct repository * r , struct bitmap_index * bitmap_git )
601
+ static void load_all_type_bitmaps (struct bitmap_index * bitmap_git )
602
+ {
603
+ struct bitmap_index * curr = bitmap_git ;
604
+ size_t i = bitmap_git -> base_nr ;
605
+
606
+ ALLOC_ARRAY (bitmap_git -> commits_all , bitmap_git -> base_nr + 1 );
607
+ ALLOC_ARRAY (bitmap_git -> trees_all , bitmap_git -> base_nr + 1 );
608
+ ALLOC_ARRAY (bitmap_git -> blobs_all , bitmap_git -> base_nr + 1 );
609
+ ALLOC_ARRAY (bitmap_git -> tags_all , bitmap_git -> base_nr + 1 );
610
+
611
+ while (curr ) {
612
+ bitmap_git -> commits_all [i ] = curr -> commits ;
613
+ bitmap_git -> trees_all [i ] = curr -> trees ;
614
+ bitmap_git -> blobs_all [i ] = curr -> blobs ;
615
+ bitmap_git -> tags_all [i ] = curr -> tags ;
616
+
617
+ curr = curr -> base ;
618
+ if (curr && !i )
619
+ BUG ("unexpected number of bitmap layers, expected %" PRIu32 ,
620
+ bitmap_git -> base_nr + 1 );
621
+ i -= 1 ;
622
+ }
623
+ }
624
+
625
+ static int load_bitmap (struct repository * r , struct bitmap_index * bitmap_git ,
626
+ int recursing )
585
627
{
586
628
assert (bitmap_git -> map );
587
629
@@ -603,10 +645,13 @@ static int load_bitmap(struct repository *r, struct bitmap_index *bitmap_git)
603
645
if (bitmap_git -> base ) {
604
646
if (!bitmap_is_midx (bitmap_git ))
605
647
BUG ("non-MIDX bitmap has non-NULL base bitmap index" );
606
- if (load_bitmap (r , bitmap_git -> base ) < 0 )
648
+ if (load_bitmap (r , bitmap_git -> base , 1 ) < 0 )
607
649
goto failed ;
608
650
}
609
651
652
+ if (!recursing )
653
+ load_all_type_bitmaps (bitmap_git );
654
+
610
655
return 0 ;
611
656
612
657
failed :
@@ -682,7 +727,7 @@ struct bitmap_index *prepare_bitmap_git(struct repository *r)
682
727
{
683
728
struct bitmap_index * bitmap_git = xcalloc (1 , sizeof (* bitmap_git ));
684
729
685
- if (!open_bitmap (r , bitmap_git ) && !load_bitmap (r , bitmap_git ))
730
+ if (!open_bitmap (r , bitmap_git ) && !load_bitmap (r , bitmap_git , 0 ))
686
731
return bitmap_git ;
687
732
688
733
free_bitmap_index (bitmap_git );
@@ -2052,7 +2097,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
2052
2097
* from disk. this is the point of no return; after this the rev_list
2053
2098
* becomes invalidated and we must perform the revwalk through bitmaps
2054
2099
*/
2055
- if (load_bitmap (revs -> repo , bitmap_git ) < 0 )
2100
+ if (load_bitmap (revs -> repo , bitmap_git , 0 ) < 0 )
2056
2101
goto cleanup ;
2057
2102
2058
2103
if (!use_boundary_traversal )
@@ -2985,6 +3030,10 @@ void free_bitmap_index(struct bitmap_index *b)
2985
3030
ewah_pool_free (b -> trees );
2986
3031
ewah_pool_free (b -> blobs );
2987
3032
ewah_pool_free (b -> tags );
3033
+ free (b -> commits_all );
3034
+ free (b -> trees_all );
3035
+ free (b -> blobs_all );
3036
+ free (b -> tags_all );
2988
3037
if (b -> bitmaps ) {
2989
3038
struct stored_bitmap * sb ;
2990
3039
kh_foreach_value (b -> bitmaps , sb , {
0 commit comments