Subject: Re: [PATCH v2 09/13] refs: don't fetch promisor objects in `ref_resolves_to_object()`

From: Junio C Hamano <[email-masked]>
Date: Mon, 28 Apr 2025 14:53:23 -0700

Patrick Steinhardt <[email-masked]> writes:

> Similar to the preceding commit, don't try to fetch objects pointed to
> by references. Any reference whose object does not exist is broken by
> definition, so we should report it accordingly.

It has always been correct that any reference whose object does not
exist is broken by definition.

But didn't "does not exist" use to mean "not in this repository,
and cannot be obtained from our promisor remotes", but with this
series, its meaning has changed to mean "not in this repository
right now---it does not matter if our promisor has it"?

So with this change, aren't we changing that statement to "any
reference whose object does not exist may be broken, but we do not
know it until we consult our promisor remotes, if any"?

> Signed-off-by: Patrick Steinhardt <[email-masked]>
> ---
>  refs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/refs.c b/refs.c
> index 6559db37890..0492cf0d13a 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -376,7 +376,7 @@ int ref_resolves_to_object(const char *refname,
>  {
>  	if (flags & REF_ISBROKEN)
>  		return 0;
> -	if (!repo_has_object_file(repo, oid)) {
> +	if (!has_object(repo, oid, HAS_OBJECT_RECHECK_PACKED)) {
>  		error(_("%s does not point to a valid object!"), refname);
>  		return 0;
>  	}