Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Alessio Attilio via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Alessio Attilio <attilio.alessio@protonmail.com>
Subject: Re: [PATCH v2] pack-objects: handle missing promisor objects
Date: Wed, 25 Nov 2026 14:47:38 -0800	[thread overview]
Message-ID: <xmqqzeuwwmt1.fsf@gitster.g> (raw)
In-Reply-To: <pull.2333.v2.git.1795636170423.gitgitgadget@gmail.com> (Alessio Attilio via GitGitGadget's message of "Wed, 25 Nov 2026 19:49:30 +0000")

"Alessio Attilio via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Alessio Attilio <attilio.alessio@protonmail.com>
>
> 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.

  reply	other threads:[~2026-11-25 22:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 19:40 [PATCH] pack-objects: handle missing promisor objects Alessio Attilio via GitGitGadget
2026-11-25 19:49 ` [PATCH v2] " Alessio Attilio via GitGitGadget
2026-11-25 22:47   ` Junio C Hamano [this message]
2026-11-25 23:11 ` [PATCH v3] " Alessio Attilio via GitGitGadget
2026-11-26  1:10   ` Junio C Hamano
2026-11-26 10:48     ` ATTILIO ALESSIO
2026-11-25 23:22 ` [PATCH v4] " Alessio Attilio via GitGitGadget
2026-11-25 23:42 ` [PATCH v5] " Alessio Attilio via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqzeuwwmt1.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=attilio.alessio@protonmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox