| 2247 | } |
| 2248 | |
| 2249 | static void check_object(struct object_entry *entry, uint32_t object_index) |
| 2250 | { |
| 2251 | size_t canonical_size; |
| 2252 | enum object_type type; |
| 2253 | struct object_info oi = {.typep = &type, .sizep = &canonical_size}; |
| 2254 | |
| 2255 | if (IN_PACK(entry)) { |
| 2256 | struct packed_git *p = IN_PACK(entry); |
| 2257 | struct pack_window *w_curs = NULL; |
| 2258 | int have_base = 0; |
| 2259 | struct object_id base_ref; |
| 2260 | struct object_entry *base_entry; |
| 2261 | unsigned long used, used_0; |
| 2262 | unsigned long avail; |
| 2263 | off_t ofs; |
| 2264 | unsigned char *buf, c; |
| 2265 | enum object_type type; |
| 2266 | size_t in_pack_size; |
| 2267 | |
| 2268 | buf = use_pack(p, &w_curs, entry->in_pack_offset, &avail); |
| 2269 | |
| 2270 | /* |
| 2271 | * We want in_pack_type even if we do not reuse delta |
| 2272 | * since non-delta representations could still be reused. |
| 2273 | */ |
| 2274 | used = unpack_object_header_buffer(buf, avail, |
| 2275 | &type, |
| 2276 | &in_pack_size); |
| 2277 | if (used == 0) |
| 2278 | goto give_up; |
| 2279 | |
| 2280 | if (type < 0) |
| 2281 | BUG("invalid type %d", type); |
| 2282 | entry->in_pack_type = type; |
| 2283 | |
| 2284 | /* |
| 2285 | * Determine if this is a delta and if so whether we can |
| 2286 | * reuse it or not. Otherwise let's find out as cheaply as |
| 2287 | * possible what the actual type and size for this object is. |
| 2288 | */ |
| 2289 | switch (entry->in_pack_type) { |
| 2290 | default: |
| 2291 | /* Not a delta hence we've already got all we need. */ |
| 2292 | oe_set_type(entry, entry->in_pack_type); |
| 2293 | SET_SIZE(entry, in_pack_size); |
| 2294 | entry->in_pack_header_size = used; |
| 2295 | if (oe_type(entry) < OBJ_COMMIT || oe_type(entry) > OBJ_BLOB) |
| 2296 | goto give_up; |
| 2297 | unuse_pack(&w_curs); |
| 2298 | return; |
| 2299 | case OBJ_REF_DELTA: |
| 2300 | if (reuse_delta && !entry->preferred_base) { |
| 2301 | oidread(&base_ref, |
| 2302 | use_pack(p, &w_curs, |
| 2303 | entry->in_pack_offset + used, |
| 2304 | NULL), |
| 2305 | the_repository->hash_algo); |
| 2306 | have_base = 1; |
no test coverage detected