From: Junio C Hamano Date: Wed, 25 Nov 2026 22:47:38 GMT Subject: Re: [PATCH v2] pack-objects: handle missing promisor objects Message-ID: In-Reply-To: "Alessio Attilio via GitGitGadget" writes: > From: Alessio Attilio > > Objects missing from a partial clone are expected to be absent. > When checking whether an object is in a promisor pack, do not BUG() > if its object info cannot be read. Such an object cannot be included > in the pack, so skip it. > > Pass OBJECT_INFO_SKIP_FETCH_OBJECT explicitly so the lookup does not > trigger a lazy fetch. > > Test filtered --unshallow and --deepen fetches, as well as a subsequent > fetch that repacks links to promisor commits with missing trees. What is missing from the above is when this loose assumption is activated and why it is safe to "assume it is a promisor object" without actually validating. To help that, I would imagine that starting the description by stepping back further and describe what the end user would does to trigger the code path and what the effects visible to the end user is that comes from the affected code paths. Such a descriptoin may start like this, perhaps (I do not claim what you are trying to fix, so it may be way off---take it as a way to explain why a good commit log message is important by demonstrating what kind of misunderstanding can result if the message is not written clearly ;-): If you try "git repack" in a partial clone, it may try to fetch objects from the promisor remote when it tries see if they are not packed (and needs packing), and ... > diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c > index 65c2ad9a86..0b40b23b33 100644 > --- a/builtin/pack-objects.c > +++ b/builtin/pack-objects.c > @@ -5091,8 +5091,11 @@ static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED) > .source_infop = &source_info, > }; > > - if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0)) > - BUG("should_include_obj should only be called on existing objects"); > + if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, > + OBJECT_INFO_SKIP_FETCH_OBJECT)) { > + /* Missing; assume it is a promisor object. */ > + return 0; > + } > return source_info.source->type != ODB_SOURCE_PACKED || !source_info.u.packed.pack->pack_promisor; > } This function is called only when pack-objects is run with the (undocumented) "--exclude-promisor-objects-best-effort" option that was introduced by c08589efdc (index-pack: repack local links into promisor packs, 2024-11-01), and it is given only when index-pack is running with the "--promisor" option. In a repository that is not a lazy clone, such a loose assumption will not get in the picture, which may be what makes this change less risky. It is also something worth documenting in the commit log message. Whenever you write "assume X" in an in-code comment, you should be careful to say why making such an assumption is safe, and what the implications are when the assumption turns out to be incorrect. Thanks.