Skip to content

Commit 2da40a8

Browse files
ttaylorrgitster
authored andcommitted
pack-bitmap.c: teach bitmap_for_commit() about incremental MIDXs
The pack-bitmap machinery uses `bitmap_for_commit()` to locate the EWAH-compressed bitmap corresponding to some given commit object. Teach this function about incremental MIDX bitmaps by teaching it to recur on earlier bitmap layers when it fails to find a given commit in the current layer. The changes to do so are as follows: - Avoid initializing hash_pos at its declaration, since bitmap_for_commit() is now a recursive function and may receive a NULL bitmap_index pointer as its first argument. - In cases where we would previously return NULL (to indicate that a lookup failed and the given bitmap_index does not contain an entry corresponding to the given commit), recursively call the function on the previous bitmap layer. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8a8a015 commit 2da40a8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pack-bitmap.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -946,18 +946,21 @@ static struct stored_bitmap *lazy_bitmap_for_commit(struct bitmap_index *bitmap_
946946
struct ewah_bitmap *bitmap_for_commit(struct bitmap_index *bitmap_git,
947947
struct commit *commit)
948948
{
949-
khiter_t hash_pos = kh_get_oid_map(bitmap_git->bitmaps,
950-
commit->object.oid);
949+
khiter_t hash_pos;
950+
if (!bitmap_git)
951+
return NULL;
952+
953+
hash_pos = kh_get_oid_map(bitmap_git->bitmaps, commit->object.oid);
951954
if (hash_pos >= kh_end(bitmap_git->bitmaps)) {
952955
struct stored_bitmap *bitmap = NULL;
953956
if (!bitmap_git->table_lookup)
954-
return NULL;
957+
return bitmap_for_commit(bitmap_git->base, commit);
955958

956959
/* this is a fairly hot codepath - no trace2_region please */
957960
/* NEEDSWORK: cache misses aren't recorded */
958961
bitmap = lazy_bitmap_for_commit(bitmap_git, commit);
959962
if (!bitmap)
960-
return NULL;
963+
return bitmap_for_commit(bitmap_git->base, commit);
961964
return lookup_stored_bitmap(bitmap);
962965
}
963966
return lookup_stored_bitmap(kh_value(bitmap_git->bitmaps, hash_pos));

0 commit comments

Comments
 (0)