All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH] use repo_get_oid_with_flags()
Date: Mon, 15 Sep 2025 08:16:44 +0200	[thread overview]
Message-ID: <aMevTM6YESMDdWPh@pks.im> (raw)
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.

> 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

      reply	other threads:[~2025-09-15  6:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-10 17:16 [PATCH] use repo_get_oid_with_flags() René Scharfe
2025-09-15  6:16 ` Patrick Steinhardt [this message]

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=aMevTM6YESMDdWPh@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=l.s.r@web.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.