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

Function load_contents

refs/packed-backend.c:557–588  ·  view source on GitHub ↗

* Depending on `mmap_strategy`, either mmap or read the contents of * the `packed-refs` file into the snapshot. Return 1 if the file * existed and was read, or 0 if the file was absent or empty. Die on * errors. */

Source from the content-addressed store, hash-verified

555 * errors.
556 */
557static int load_contents(struct snapshot *snapshot)
558{
559 struct stat st;
560 int ret;
561 int fd;
562
563 fd = open(snapshot->refs->path, O_RDONLY);
564 if (fd < 0) {
565 if (errno == ENOENT) {
566 /*
567 * This is OK; it just means that no
568 * "packed-refs" file has been written yet,
569 * which is equivalent to it being empty,
570 * which is its state when initialized with
571 * zeros.
572 */
573 return 0;
574 } else {
575 die_errno("couldn't read %s", snapshot->refs->path);
576 }
577 }
578
579 stat_validity_update(&snapshot->validity, fd);
580
581 if (fstat(fd, &st) < 0)
582 die_errno("couldn't stat %s", snapshot->refs->path);
583
584 ret = allocate_snapshot_buffer(snapshot, fd, &st);
585
586 close(fd);
587 return ret;
588}
589
590static const char *find_reference_location_1(struct snapshot *snapshot,
591 const char *refname, int mustexist,

Callers 1

create_snapshotFunction · 0.85

Calls 3

die_errnoFunction · 0.85
stat_validity_updateFunction · 0.85
allocate_snapshot_bufferFunction · 0.85

Tested by

no test coverage detected