* Like get_delta_base above, but we return the sha1 instead of the pack * offset. This means it is cheaper for REF deltas (we do not have to do * the final object lookup), but more expensive for OFS deltas (we * have to load the revidx to convert the offset back into a sha1). */
| 1318 | * have to load the revidx to convert the offset back into a sha1). |
| 1319 | */ |
| 1320 | static int get_delta_base_oid(struct packed_git *p, |
| 1321 | struct pack_window **w_curs, |
| 1322 | off_t curpos, |
| 1323 | struct object_id *oid, |
| 1324 | enum object_type type, |
| 1325 | off_t delta_obj_offset) |
| 1326 | { |
| 1327 | if (type == OBJ_REF_DELTA) { |
| 1328 | unsigned char *base = use_pack(p, w_curs, curpos, NULL); |
| 1329 | oidread(oid, base, p->repo->hash_algo); |
| 1330 | return 0; |
| 1331 | } else if (type == OBJ_OFS_DELTA) { |
| 1332 | uint32_t base_pos; |
| 1333 | off_t base_offset = get_delta_base(p, w_curs, &curpos, |
| 1334 | type, delta_obj_offset); |
| 1335 | |
| 1336 | if (!base_offset) |
| 1337 | return -1; |
| 1338 | |
| 1339 | if (offset_to_pack_pos(p, base_offset, &base_pos) < 0) |
| 1340 | return -1; |
| 1341 | |
| 1342 | return nth_packed_object_id(oid, p, |
| 1343 | pack_pos_to_index(p, base_pos)); |
| 1344 | } else |
| 1345 | return -1; |
| 1346 | } |
| 1347 | |
| 1348 | static int retry_bad_packed_offset(struct repository *r, |
| 1349 | struct packed_git *p, |
no test coverage detected