| 548 | } |
| 549 | |
| 550 | static int do_oid_object_info_extended(struct object_database *odb, |
| 551 | const struct object_id *oid, |
| 552 | struct object_info *oi, unsigned flags) |
| 553 | { |
| 554 | const struct object_id *real = oid; |
| 555 | int already_retried = 0; |
| 556 | |
| 557 | if (flags & OBJECT_INFO_LOOKUP_REPLACE) |
| 558 | real = lookup_replace_object(odb->repo, oid); |
| 559 | |
| 560 | if (is_null_oid(real)) |
| 561 | return -1; |
| 562 | |
| 563 | if (!odb_source_read_object_info(odb->inmemory_objects, oid, oi, flags)) |
| 564 | return 0; |
| 565 | |
| 566 | odb_prepare_alternates(odb); |
| 567 | |
| 568 | while (1) { |
| 569 | struct odb_source *source; |
| 570 | |
| 571 | for (source = odb->sources; source; source = source->next) |
| 572 | if (!odb_source_read_object_info(source, real, oi, flags)) |
| 573 | return 0; |
| 574 | |
| 575 | /* |
| 576 | * When the object hasn't been found we try a second read and |
| 577 | * tell the sources so. This may cause them to invalidate |
| 578 | * caches or reload on-disk state. |
| 579 | */ |
| 580 | if (!(flags & OBJECT_INFO_QUICK)) { |
| 581 | for (source = odb->sources; source; source = source->next) |
| 582 | if (!odb_source_read_object_info(source, real, oi, |
| 583 | flags | OBJECT_INFO_SECOND_READ)) |
| 584 | return 0; |
| 585 | } |
| 586 | |
| 587 | /* |
| 588 | * This might be an attempt at accessing a submodule object as |
| 589 | * if it were in main object store (having called |
| 590 | * `odb_add_submodule_source_by_path()` on that submodule's |
| 591 | * ODB). If any such ODBs exist, register them and try again. |
| 592 | */ |
| 593 | if (register_all_submodule_sources(odb)) |
| 594 | /* We added some alternates; retry */ |
| 595 | continue; |
| 596 | |
| 597 | /* Check if it is a missing object */ |
| 598 | if (fetch_if_missing && repo_has_promisor_remote(odb->repo) && |
| 599 | !already_retried && |
| 600 | !(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) { |
| 601 | promisor_remote_get_direct(odb->repo, real, 1); |
| 602 | already_retried = 1; |
| 603 | continue; |
| 604 | } |
| 605 | |
| 606 | if (flags & OBJECT_INFO_DIE_IF_CORRUPT) { |
| 607 | const struct packed_git *p; |
no test coverage detected