{
struct packed_ref_store *refs = packed_downcast(ref_store,
REF_STORE_READ, "fsck");
- struct strbuf packed_ref_content = STRBUF_INIT;
+ struct snapshot snapshot = { 0 };
unsigned int sorted = 0;
struct stat st;
int ret = 0;
goto cleanup;
}
- if (!st.st_size) {
+ if (!allocate_snapshot_buffer(&snapshot, fd, &st)) {
struct fsck_ref_report report = { 0 };
report.path = "packed-refs";
ret = fsck_report_ref(o, &report,
goto cleanup;
}
- if (strbuf_read(&packed_ref_content, fd, 0) < 0) {
- ret = error_errno(_("unable to read '%s'"), refs->path);
- goto cleanup;
- }
-
- ret = packed_fsck_ref_content(o, ref_store, &sorted, packed_ref_content.buf,
- packed_ref_content.buf + packed_ref_content.len);
+ ret = packed_fsck_ref_content(o, ref_store, &sorted, snapshot.start,
+ snapshot.eof);
if (!ret && sorted)
- ret = packed_fsck_ref_sorted(o, ref_store, packed_ref_content.buf,
- packed_ref_content.buf + packed_ref_content.len);
+ ret = packed_fsck_ref_sorted(o, ref_store, snapshot.start,
+ snapshot.eof);
cleanup:
if (fd >= 0)
close(fd);
- strbuf_release(&packed_ref_content);
+ clear_snapshot_buffer(&snapshot);
return ret;
}