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

Function open_pack_bitmap_1

pack-bitmap.c:542–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

540}
541
542static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git *packfile)
543{
544 int fd;
545 struct stat st;
546 char *bitmap_name;
547
548 bitmap_name = pack_bitmap_filename(packfile);
549 fd = git_open(bitmap_name);
550
551 if (fd < 0) {
552 if (errno != ENOENT)
553 warning_errno("cannot open '%s'", bitmap_name);
554 free(bitmap_name);
555 return -1;
556 }
557 free(bitmap_name);
558
559 if (fstat(fd, &st)) {
560 error_errno(_("cannot fstat bitmap file"));
561 close(fd);
562 return -1;
563 }
564
565 if (bitmap_git->pack || bitmap_git->midx) {
566 trace2_data_string("bitmap", bitmap_repo(bitmap_git),
567 "ignoring extra bitmap file",
568 packfile->pack_name);
569 close(fd);
570 return -1;
571 }
572
573 if (!is_pack_valid(packfile)) {
574 close(fd);
575 return -1;
576 }
577
578 bitmap_git->pack = packfile;
579 bitmap_git->map_size = xsize_t(st.st_size);
580 bitmap_git->map = xmmap(NULL, bitmap_git->map_size, PROT_READ, MAP_PRIVATE, fd, 0);
581 bitmap_git->map_pos = 0;
582 bitmap_git->base_nr = 0;
583 close(fd);
584
585 if (load_bitmap_header(bitmap_git) < 0) {
586 munmap(bitmap_git->map, bitmap_git->map_size);
587 bitmap_git->map = NULL;
588 bitmap_git->map_size = 0;
589 bitmap_git->map_pos = 0;
590 bitmap_git->pack = NULL;
591 return -1;
592 }
593
594 trace2_data_string("bitmap", bitmap_repo(bitmap_git),
595 "opened bitmap file", packfile->pack_name);
596 return 0;
597}
598
599static int load_reverse_index(struct repository *r, struct bitmap_index *bitmap_git)

Callers 1

open_pack_bitmapFunction · 0.85

Calls 8

pack_bitmap_filenameFunction · 0.85
warning_errnoFunction · 0.85
error_errnoFunction · 0.85
bitmap_repoFunction · 0.85
is_pack_validFunction · 0.85
xsize_tFunction · 0.85
xmmapFunction · 0.85
load_bitmap_headerFunction · 0.85

Tested by

no test coverage detected