Subject: Re: [PATCH] use repo_get_oid_with_flags()

From: Patrick Steinhardt <[email-masked]>
Date: Mon, 15 Sep 2025 08:16:44 +0200

On Wed, Sep 10, 2025 at 07:16:30PM +0200, René Scharfe wrote:

Nit: it would probably make sense to add something like a `treewide: `
prefix to the patch subject.

> get_oid_with_context() allows specifying flags and reports object
> details via a passed-in struct object_context.  Some callers just want
> to specify flags, but don't need any details back.  Convert them to
> repo_get_oid_with_flags(), which provides just that and frees them from
> dealing with the context structure.

Makes sense. `repo_get_oid_with_flags()` is a mere wrapper around
`get_oid_with_context()` with an object context. So these two would be
equivalent to one another.

One thing that is a bit weird though is that `repo_get_oid_with_flags()`
returns an `int` even though it directly returns the result from
`get_oid_with_context()`, which returns an `enum get_oid_result`. That
shouldn't impact correctness though, and it's not a new problem.

> diff --git a/object-name.c b/object-name.c
> index 732056ff5e..52d87348d1 100644
> --- a/object-name.c
> +++ b/object-name.c
> @@ -1858,55 +1858,35 @@ int repo_get_oid_committish(struct repository *r,
>  			    const char *name,
>  			    struct object_id *oid)
>  {
> -	struct object_context unused;
> -	int ret = get_oid_with_context(r, name, GET_OID_COMMITTISH,
> -				       oid, &unused);
> -	object_context_release(&unused);
> -	return ret;
> +	return repo_get_oid_with_flags(r, name, oid, GET_OID_COMMITTISH);
>  }

The same is true for all these functions. It would feel more sensible if
those all returned `enum get_oid_result`. But as said, that's not a new
problem and doesn't need fixing in your patch.

Other than that all the conversions look correct to me, thanks!

Patrick