MCPcopy Index your code
hub / github.com/git/git / lazy_bitmap_for_commit

Function lazy_bitmap_for_commit

pack-bitmap.c:883–1018  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

881}
882
883static struct stored_bitmap *lazy_bitmap_for_commit(struct bitmap_index *bitmap_git,
884 struct commit *commit)
885{
886 uint32_t commit_pos, xor_row;
887 uint64_t offset;
888 int flags;
889 struct bitmap_lookup_table_triplet triplet;
890 struct object_id *oid = &commit->object.oid;
891 struct ewah_bitmap *bitmap;
892 struct stored_bitmap *xor_bitmap = NULL;
893 const int bitmap_header_size = 6;
894 static struct bitmap_lookup_table_xor_item *xor_items = NULL;
895 static size_t xor_items_nr = 0, xor_items_alloc = 0;
896 static int is_corrupt = 0;
897 int xor_flags;
898 khiter_t hash_pos;
899 struct bitmap_lookup_table_xor_item *xor_item;
900 size_t entry_map_pos;
901
902 if (is_corrupt)
903 return NULL;
904
905 if (!bitmap_bsearch_pos(bitmap_git, oid, &commit_pos))
906 return NULL;
907
908 if (bitmap_bsearch_triplet_by_pos(commit_pos, bitmap_git, &triplet) < 0)
909 return NULL;
910
911 xor_items_nr = 0;
912 offset = triplet.offset;
913 xor_row = triplet.xor_row;
914
915 while (xor_row != 0xffffffff) {
916 ALLOC_GROW(xor_items, xor_items_nr + 1, xor_items_alloc);
917
918 if (xor_items_nr + 1 >= bitmap_git->entry_count) {
919 error(_("corrupt bitmap lookup table: xor chain exceeds entry count"));
920 goto corrupt;
921 }
922
923 if (bitmap_lookup_table_get_triplet(bitmap_git, xor_row, &triplet) < 0)
924 goto corrupt;
925
926 xor_item = &xor_items[xor_items_nr];
927 xor_item->offset = triplet.offset;
928
929 if (nth_bitmap_object_oid(bitmap_git, &xor_item->oid, triplet.commit_pos) < 0) {
930 error(_("corrupt bitmap lookup table: commit index %u out of range"),
931 triplet.commit_pos);
932 goto corrupt;
933 }
934
935 hash_pos = kh_get_oid_map(bitmap_git->bitmaps, xor_item->oid);
936
937 /*
938 * If desired bitmap is already stored, we don't need
939 * to iterate further. Because we know that bitmaps
940 * that are needed to be parsed to parse this bitmap

Callers 1

find_bitmap_for_commitFunction · 0.85

Calls 9

bitmap_bsearch_posFunction · 0.85
errorFunction · 0.85
nth_bitmap_object_oidFunction · 0.85
oid_to_hexFunction · 0.85
read_u8Function · 0.85
read_bitmap_1Function · 0.85
store_bitmapFunction · 0.85

Tested by

no test coverage detected