Skip to content

Commit ae61324

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]> Acked-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f31a17c commit ae61324

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
@@ -941,18 +941,21 @@ static struct stored_bitmap *lazy_bitmap_for_commit(struct bitmap_index *bitmap_
941941
struct ewah_bitmap *bitmap_for_commit(struct bitmap_index *bitmap_git,
942942
struct commit *commit)
943943
{
944-
khiter_t hash_pos = kh_get_oid_map(bitmap_git->bitmaps,
945-
commit->object.oid);
944+
khiter_t hash_pos;
945+
if (!bitmap_git)
946+
return NULL;
947+
948+
hash_pos = kh_get_oid_map(bitmap_git->bitmaps, commit->object.oid);
946949
if (hash_pos >= kh_end(bitmap_git->bitmaps)) {
947950
struct stored_bitmap *bitmap = NULL;
948951
if (!bitmap_git->table_lookup)
949-
return NULL;
952+
return bitmap_for_commit(bitmap_git->base, commit);
950953

951954
/* this is a fairly hot codepath - no trace2_region please */
952955
/* NEEDSWORK: cache misses aren't recorded */
953956
bitmap = lazy_bitmap_for_commit(bitmap_git, commit);
954957
if (!bitmap)
955-
return NULL;
958+
return bitmap_for_commit(bitmap_git->base, commit);
956959
return lookup_stored_bitmap(bitmap);
957960
}
958961
return lookup_stored_bitmap(kh_value(bitmap_git->bitmaps, hash_pos));

0 commit comments

Comments
 (0)