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

Function open_midx_bitmap_1

pack-bitmap.c:463–540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461}
462
463static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
464 struct multi_pack_index *midx)
465{
466 struct stat st;
467 char *bitmap_name = midx_bitmap_filename(midx);
468 int fd = git_open(bitmap_name);
469 uint32_t i;
470
471 if (fd < 0) {
472 if (errno != ENOENT)
473 warning_errno("cannot open '%s'", bitmap_name);
474 free(bitmap_name);
475 return -1;
476 }
477 free(bitmap_name);
478
479 if (fstat(fd, &st)) {
480 error_errno(_("cannot fstat bitmap file"));
481 close(fd);
482 return -1;
483 }
484
485 if (bitmap_git->pack || bitmap_git->midx) {
486 struct strbuf buf = STRBUF_INIT;
487 get_midx_filename(midx->source, &buf);
488 trace2_data_string("bitmap", bitmap_repo(bitmap_git),
489 "ignoring extra midx bitmap file", buf.buf);
490 close(fd);
491 strbuf_release(&buf);
492 return -1;
493 }
494
495 bitmap_git->midx = midx;
496 bitmap_git->map_size = xsize_t(st.st_size);
497 bitmap_git->map_pos = 0;
498 bitmap_git->map = xmmap(NULL, bitmap_git->map_size, PROT_READ,
499 MAP_PRIVATE, fd, 0);
500 close(fd);
501
502 if (load_bitmap_header(bitmap_git) < 0)
503 goto cleanup;
504
505 if (!hasheq(midx_get_checksum_hash(bitmap_git->midx), bitmap_git->checksum,
506 bitmap_repo(bitmap_git)->hash_algo)) {
507 error(_("checksum doesn't match in MIDX and bitmap"));
508 goto cleanup;
509 }
510
511 if (load_midx_revindex(bitmap_git->midx)) {
512 warning(_("multi-pack bitmap is missing required reverse index"));
513 goto cleanup;
514 }
515
516 for (i = 0; i < bitmap_git->midx->num_packs + bitmap_git->midx->num_packs_in_base; i++) {
517 if (prepare_midx_pack(bitmap_git->midx, i)) {
518 warning(_("could not open pack %s"),
519 bitmap_git->midx->pack_names[i]);
520 goto cleanup;

Callers 2

open_midx_bitmapFunction · 0.85
prepare_midx_bitmap_gitFunction · 0.85

Calls 15

midx_bitmap_filenameFunction · 0.85
warning_errnoFunction · 0.85
error_errnoFunction · 0.85
get_midx_filenameFunction · 0.85
bitmap_repoFunction · 0.85
strbuf_releaseFunction · 0.85
xsize_tFunction · 0.85
xmmapFunction · 0.85
load_bitmap_headerFunction · 0.85
hasheqFunction · 0.85
midx_get_checksum_hashFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected