Re: [PATCH 3/3] connected: search promisor objects generically
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 22, 2026, 17:57 UTC
- Message-ID
- <xmqq4iiu1mrt.fsf@gitster.g>
- In-Reply-To
- <20260622-pks-connected-generic-promisor-checks-v1-3-25eba2698202@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 14 quoted lines
> When performing connectivity checks we have to figure out whether any of > the new objects are promisor objects, as we cannot assume full > connectivity if so. > > This check is performed by iterating through all packfiles in the > repository and searching each of them for the given object. Of course, > this mechanism is quite specific to implementation details of the object > database, as we assume that it uses packfiles in the first place. > > Refactor the logic so that we instead use `odb_for_each_object_ext()` > with an object prefix filter and the `ODB_FOR_EACH_OBJECT_PROMISOR_ONLY` > flag. This will yield all objects that have the exact object name and > that are part of a promisor pack in a generic way. > ...
Show 5 quoted lines
> - * > - * Before checking for promisor packs, be sure we have the > - * latest pack-files loaded into memory. > */ > - odb_reprepare(the_repository->objects);
Hmph?
Show 19 quoted lines
> do {
> - struct packed_git *p;
> -
> - repo_for_each_pack(the_repository, p) {
> - if (!p->pack_promisor)
> - continue;
> - if (find_pack_entry_one(oid, p))
> - goto promisor_pack_found;
> + opts.prefix = oid;
> +
> + err = odb_for_each_object_ext(the_repository->objects,
> + NULL, promised_object_cb,
> + NULL, &opts);
> + if (err < 0)
> + break;
> + if (err > 0) {
> + err = 0;
> + continue;
> }So we used to manually iterate and stop when we have a matching pack entry, but now "stop when we find" is done by promisor_object_cb callback that returns 1.
What is the reason why we no longer odb_(re)prepare() upfront before going into the loop? Would it make us miss a newly added promisor packs? We will fall back to rev-list for correctness, so it may not matter, though.
Show 17 quoted lines
> + > /* > * Fallback to rev-list with oid and the rest of the > * object IDs provided by fn. > */ > goto no_promisor_pack_found; > -promisor_pack_found: > - ; > } while ((oid = fn(cb_data)) != NULL); > + > if (opt->err_fd) > close(opt->err_fd); > - return 0; > + return err; > } > > no_promisor_pack_found: