git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] use repo_get_oid_with_flags()

From
Patrick Steinhardt <ps@pks.im>
Date
Sep 15, 2025, 06:16 UTC
Message-ID
<aMevTM6YESMDdWPh@pks.im>
In-Reply-To
<906196ac-2fd7-4c07-9e8f-22d67b0b64f9@web.de>
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.
Show 5 quoted lines
> 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.

Show 15 quoted lines
> 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
Previous: René Scharfe
Message 2 of 2 in “use repo_get_oid_with_flags()”
  1. use repo_get_oid_with_flags()René Scharfe, Sep 10, 2025
  2. Patrick SteinhardtSep 15, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.