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

Function packed_object_info_with_index_pos

packfile.c:1595–1715  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1593}
1594
1595static int packed_object_info_with_index_pos(struct packed_git *p, off_t obj_offset,
1596 uint32_t *maybe_index_pos, struct object_info *oi)
1597{
1598 struct pack_window *w_curs = NULL;
1599 size_t size;
1600 off_t curpos = obj_offset;
1601 enum object_type type = OBJ_NONE;
1602 uint32_t pack_pos;
1603 int ret;
1604
1605 /*
1606 * We always get the representation type, but only convert it to
1607 * a "real" type later if the caller is interested.
1608 */
1609 if (oi->contentp) {
1610 *oi->contentp = cache_or_unpack_entry(p->repo, p, obj_offset,
1611 oi->sizep, &type);
1612 if (!*oi->contentp)
1613 type = OBJ_BAD;
1614 } else if (oi->sizep || oi->typep || oi->delta_base_oid) {
1615 type = unpack_object_header(p, &w_curs, &curpos, &size);
1616 }
1617
1618 if (!oi->contentp && oi->sizep) {
1619 if (type == OBJ_OFS_DELTA || type == OBJ_REF_DELTA) {
1620 off_t tmp_pos = curpos;
1621 off_t base_offset = get_delta_base(p, &w_curs, &tmp_pos,
1622 type, obj_offset);
1623 if (!base_offset) {
1624 ret = -1;
1625 goto out;
1626 }
1627 size = get_size_from_delta(p, &w_curs, tmp_pos);
1628 if (size == 0) {
1629 ret = -1;
1630 goto out;
1631 }
1632 }
1633 *oi->sizep = size;
1634 }
1635
1636 if (oi->disk_sizep || (oi->mtimep && p->is_cruft)) {
1637 if (offset_to_pack_pos(p, obj_offset, &pack_pos) < 0) {
1638 error("could not find object at offset %"PRIuMAX" "
1639 "in pack %s", (uintmax_t)obj_offset, p->pack_name);
1640 ret = -1;
1641 goto out;
1642 }
1643 }
1644
1645 if (oi->disk_sizep)
1646 *oi->disk_sizep = pack_pos_to_offset(p, pack_pos + 1) - obj_offset;
1647
1648 if (oi->mtimep) {
1649 if (p->is_cruft) {
1650 uint32_t index_pos;
1651
1652 if (load_pack_mtimes(p) < 0)

Callers 2

packed_object_infoFunction · 0.85

Calls 15

cache_or_unpack_entryFunction · 0.85
unpack_object_headerFunction · 0.85
get_delta_baseFunction · 0.85
get_size_from_deltaFunction · 0.85
offset_to_pack_posFunction · 0.85
errorFunction · 0.85
pack_pos_to_offsetFunction · 0.85
load_pack_mtimesFunction · 0.85
pack_basenameFunction · 0.85
pack_pos_to_indexFunction · 0.85
nth_packed_mtimeFunction · 0.85
packed_to_object_typeFunction · 0.85

Tested by

no test coverage detected