@@ -78,6 +78,24 @@ struct bitmap_index {
78
78
struct ewah_bitmap * blobs ;
79
79
struct ewah_bitmap * tags ;
80
80
81
+ /*
82
+ * Type index arrays when this bitmap is associated with an
83
+ * incremental multi-pack index chain.
84
+ *
85
+ * If n is the number of unique layers in the MIDX chain, then
86
+ * commits_all[n-1] is this structs 'commits' field,
87
+ * commits_all[n-2] is the commits field of this bitmap's
88
+ * 'base', and so on.
89
+ *
90
+ * When either associated either with a non-incremental MIDX, or
91
+ * a single packfile, these arrays each contain a single
92
+ * element.
93
+ */
94
+ struct ewah_bitmap * * commits_all ;
95
+ struct ewah_bitmap * * trees_all ;
96
+ struct ewah_bitmap * * blobs_all ;
97
+ struct ewah_bitmap * * tags_all ;
98
+
81
99
/* Map from object ID -> `stored_bitmap` for all the bitmapped commits */
82
100
kh_oid_map_t * bitmaps ;
83
101
@@ -586,7 +604,29 @@ static int load_reverse_index(struct repository *r, struct bitmap_index *bitmap_
586
604
return load_pack_revindex (r , bitmap_git -> pack );
587
605
}
588
606
589
- static int load_bitmap (struct repository * r , struct bitmap_index * bitmap_git )
607
+ static void load_all_type_bitmaps (struct bitmap_index * bitmap_git )
608
+ {
609
+ struct bitmap_index * curr = bitmap_git ;
610
+ size_t i = bitmap_git -> base_nr - 1 ;
611
+
612
+ ALLOC_ARRAY (bitmap_git -> commits_all , bitmap_git -> base_nr );
613
+ ALLOC_ARRAY (bitmap_git -> trees_all , bitmap_git -> base_nr );
614
+ ALLOC_ARRAY (bitmap_git -> blobs_all , bitmap_git -> base_nr );
615
+ ALLOC_ARRAY (bitmap_git -> tags_all , bitmap_git -> base_nr );
616
+
617
+ while (curr ) {
618
+ bitmap_git -> commits_all [i ] = curr -> commits ;
619
+ bitmap_git -> trees_all [i ] = curr -> trees ;
620
+ bitmap_git -> blobs_all [i ] = curr -> blobs ;
621
+ bitmap_git -> tags_all [i ] = curr -> tags ;
622
+
623
+ curr = curr -> base ;
624
+ i -= 1 ;
625
+ }
626
+ }
627
+
628
+ static int load_bitmap (struct repository * r , struct bitmap_index * bitmap_git ,
629
+ int recursing )
590
630
{
591
631
assert (bitmap_git -> map );
592
632
@@ -608,10 +648,13 @@ static int load_bitmap(struct repository *r, struct bitmap_index *bitmap_git)
608
648
if (bitmap_git -> base ) {
609
649
if (!bitmap_is_midx (bitmap_git ))
610
650
BUG ("non-MIDX bitmap has non-NULL base bitmap index" );
611
- if (load_bitmap (r , bitmap_git -> base ) < 0 )
651
+ if (load_bitmap (r , bitmap_git -> base , 1 ) < 0 )
612
652
goto failed ;
613
653
}
614
654
655
+ if (!recursing )
656
+ load_all_type_bitmaps (bitmap_git );
657
+
615
658
return 0 ;
616
659
617
660
failed :
@@ -687,7 +730,7 @@ struct bitmap_index *prepare_bitmap_git(struct repository *r)
687
730
{
688
731
struct bitmap_index * bitmap_git = xcalloc (1 , sizeof (* bitmap_git ));
689
732
690
- if (!open_bitmap (r , bitmap_git ) && !load_bitmap (r , bitmap_git ))
733
+ if (!open_bitmap (r , bitmap_git ) && !load_bitmap (r , bitmap_git , 0 ))
691
734
return bitmap_git ;
692
735
693
736
free_bitmap_index (bitmap_git );
@@ -2042,7 +2085,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
2042
2085
* from disk. this is the point of no return; after this the rev_list
2043
2086
* becomes invalidated and we must perform the revwalk through bitmaps
2044
2087
*/
2045
- if (load_bitmap (revs -> repo , bitmap_git ) < 0 )
2088
+ if (load_bitmap (revs -> repo , bitmap_git , 0 ) < 0 )
2046
2089
goto cleanup ;
2047
2090
2048
2091
if (!use_boundary_traversal )
@@ -2957,6 +3000,10 @@ void free_bitmap_index(struct bitmap_index *b)
2957
3000
ewah_pool_free (b -> trees );
2958
3001
ewah_pool_free (b -> blobs );
2959
3002
ewah_pool_free (b -> tags );
3003
+ free (b -> commits_all );
3004
+ free (b -> trees_all );
3005
+ free (b -> blobs_all );
3006
+ free (b -> tags_all );
2960
3007
if (b -> bitmaps ) {
2961
3008
struct stored_bitmap * sb ;
2962
3009
kh_foreach_value (b -> bitmaps , sb , {
0 commit comments