MCPcopy Create free account
hub / github.com/git/git / load_bitmap_entries_v1

Function load_bitmap_entries_v1

pack-bitmap.c:392–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390}
391
392static int load_bitmap_entries_v1(struct bitmap_index *index)
393{
394 uint32_t i;
395 struct stored_bitmap *recent_bitmaps[MAX_XOR_OFFSET] = { NULL };
396
397 for (i = 0; i < index->entry_count; ++i) {
398 int xor_offset, flags;
399 struct ewah_bitmap *bitmap = NULL;
400 struct stored_bitmap *xor_bitmap = NULL;
401 uint32_t commit_idx_pos;
402 struct object_id oid;
403 size_t entry_map_pos;
404
405 if (index->map_size - index->map_pos < 6)
406 return error(_("corrupt ewah bitmap: truncated header for entry %d"), i);
407
408 entry_map_pos = index->map_pos;
409 commit_idx_pos = read_be32(index->map, &index->map_pos);
410 xor_offset = read_u8(index->map, &index->map_pos);
411 flags = read_u8(index->map, &index->map_pos);
412
413 if (nth_bitmap_object_oid(index, &oid, commit_idx_pos) < 0)
414 return error(_("corrupt ewah bitmap: commit index %u out of range"),
415 (unsigned)commit_idx_pos);
416
417 if (xor_offset > MAX_XOR_OFFSET || xor_offset > i)
418 return error(_("corrupted bitmap pack index"));
419
420 if (xor_offset > 0) {
421 xor_bitmap = recent_bitmaps[(i - xor_offset) % MAX_XOR_OFFSET];
422
423 if (!xor_bitmap)
424 return error(_("invalid XOR offset in bitmap pack index"));
425 }
426
427 bitmap = read_bitmap_1(index);
428 if (!bitmap)
429 return -1;
430
431 recent_bitmaps[i % MAX_XOR_OFFSET] =
432 store_bitmap(index, bitmap, &oid, xor_bitmap, flags,
433 entry_map_pos);
434 }
435
436 return 0;
437}
438
439char *midx_bitmap_filename(struct multi_pack_index *midx)
440{

Callers 3

load_bitmapFunction · 0.85
test_bitmap_commitsFunction · 0.85

Calls 6

errorFunction · 0.85
read_be32Function · 0.85
read_u8Function · 0.85
nth_bitmap_object_oidFunction · 0.85
read_bitmap_1Function · 0.85
store_bitmapFunction · 0.85

Tested by 2

test_bitmap_commitsFunction · 0.68