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

Function unpack_entry

packfile.c:1784–2000  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1782};
1783
1784void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
1785 enum object_type *final_type, size_t *final_size)
1786{
1787 struct pack_window *w_curs = NULL;
1788 off_t curpos = obj_offset;
1789 void *data = NULL;
1790 size_t size;
1791 enum object_type type;
1792 struct unpack_entry_stack_ent small_delta_stack[UNPACK_ENTRY_STACK_PREALLOC];
1793 struct unpack_entry_stack_ent *delta_stack = small_delta_stack;
1794 int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
1795 int base_from_cache = 0;
1796
1797 prepare_repo_settings(p->repo);
1798
1799 write_pack_access_log(p, obj_offset);
1800
1801 /* PHASE 1: drill down to the innermost base object */
1802 for (;;) {
1803 off_t base_offset;
1804 int i;
1805 struct delta_base_cache_entry *ent;
1806
1807 ent = get_delta_base_cache_entry(p, curpos);
1808 if (ent) {
1809 type = ent->type;
1810 data = ent->data;
1811 size = ent->size;
1812 detach_delta_base_cache_entry(ent);
1813 base_from_cache = 1;
1814 break;
1815 }
1816
1817 if (do_check_packed_object_crc && p->index_version > 1) {
1818 uint32_t pack_pos, index_pos;
1819 off_t len;
1820
1821 if (offset_to_pack_pos(p, obj_offset, &pack_pos) < 0) {
1822 error("could not find object at offset %"PRIuMAX" in pack %s",
1823 (uintmax_t)obj_offset, p->pack_name);
1824 data = NULL;
1825 goto out;
1826 }
1827
1828 len = pack_pos_to_offset(p, pack_pos + 1) - obj_offset;
1829 index_pos = pack_pos_to_index(p, pack_pos);
1830 if (check_pack_crc(p, &w_curs, obj_offset, len, index_pos)) {
1831 struct object_id oid;
1832 nth_packed_object_id(&oid, p, index_pos);
1833 error("bad packed object CRC for %s",
1834 oid_to_hex(&oid));
1835 mark_bad_packed_object(p, &oid);
1836 data = NULL;
1837 goto out;
1838 }
1839 }
1840
1841 type = unpack_object_header(p, &w_curs, &curpos, &size);

Callers 3

verify_packfileFunction · 0.85
cache_or_unpack_entryFunction · 0.85
gfi_unpack_entryFunction · 0.85

Calls 15

prepare_repo_settingsFunction · 0.85
write_pack_access_logFunction · 0.85
offset_to_pack_posFunction · 0.85
errorFunction · 0.85
pack_pos_to_offsetFunction · 0.85
pack_pos_to_indexFunction · 0.85
check_pack_crcFunction · 0.85
nth_packed_object_idFunction · 0.85
oid_to_hexFunction · 0.85
mark_bad_packed_objectFunction · 0.85

Tested by

no test coverage detected