| 286 | } |
| 287 | |
| 288 | static uint32_t find_object_pos(struct bitmap_writer *writer, |
| 289 | const struct object_id *oid, int *found) |
| 290 | { |
| 291 | struct object_entry *entry; |
| 292 | uint32_t pos; |
| 293 | |
| 294 | bitmap_writer_init_pos_cache(writer); |
| 295 | |
| 296 | if (find_cached_object_pos(writer, oid, &pos)) { |
| 297 | if (found) |
| 298 | *found = 1; |
| 299 | return pos; |
| 300 | } |
| 301 | |
| 302 | entry = packlist_find(writer->to_pack, oid); |
| 303 | if (entry) { |
| 304 | uint32_t base_objects = 0; |
| 305 | |
| 306 | if (writer->midx) |
| 307 | base_objects = writer->midx->num_objects + |
| 308 | writer->midx->num_objects_in_base; |
| 309 | pos = oe_in_pack_pos(writer->to_pack, entry) + base_objects; |
| 310 | } else if (writer->midx) { |
| 311 | uint32_t at; |
| 312 | |
| 313 | if (!bsearch_midx(oid, writer->midx, &at)) |
| 314 | goto missing; |
| 315 | if (midx_to_pack_pos(writer->midx, at, &pos) < 0) |
| 316 | goto missing; |
| 317 | } else { |
| 318 | goto missing; |
| 319 | } |
| 320 | |
| 321 | if (found) |
| 322 | *found = 1; |
| 323 | return store_cached_object_pos(writer, oid, pos); |
| 324 | |
| 325 | missing: |
| 326 | if (found) |
| 327 | *found = 0; |
| 328 | warning("Failed to write bitmap index. Packfile doesn't have full closure " |
| 329 | "(object %s is missing)", oid_to_hex(oid)); |
| 330 | return 0; |
| 331 | } |
| 332 | |
| 333 | static int bitmapped_commit_date_cmp(const void *_a, const void *_b) |
| 334 | { |
no test coverage detected