git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org,
	Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>,
	Karthik Nayak <karthik.188@gmail.com>,
	Taylor Blau <me@ttaylorr.com>, Junio C Hamano <gitster@pobox.com>,
	Justin Tobler <jltobler@gmail.com>
Subject: Re: [PATCH v2 00/14] refs: improvements and fixes for peeling tags
Date: Thu, 9 Oct 2025 09:24:35 +0200	[thread overview]
Message-ID: <aOdjM8F6WvTEBIo_@pks.im> (raw)
In-Reply-To: <20251009063956.GA1622884@coredump.intra.peff.net>

On Thu, Oct 09, 2025 at 02:39:56AM -0400, Jeff King wrote:
> On Thu, Oct 09, 2025 at 08:09:53AM +0200, Patrick Steinhardt wrote:
> 
> > > I do have one minor complaint, though: the name of that struct. I have a
> > > feeling that the name "struct reference" may cause confusion down the
> > > road because it's so generic, and because "references" and "refs" are so
> > > common in the code. From the names, when would I know when to use
> > > "struct reference" and when "struct ref"?
> > > 
> > > Could we give it a name that ties it to the iteration interface?
> > > Something like iterated_ref, each_ref_data, etc?
> > > 
> > > I know this is minor (and will be annoying to adjust your series), but
> > > I'd rather raise the point now than realize later that it's confusing
> > > and try to change it then.
> > 
> > It is puzzling indeed. I would claim that in this case it is not `struct
> > reference` that is misnamed: what it contains is as close as you get to
> > a representation of a reference. It's rather `struct ref` that is
> > misnamed, as it carries a lot of data that is only valid in the context
> > of a remote.
> > 
> > Another approach could thus be to rename `struct ref` to `struct
> > remote_ref`, which I would claim would be a clear win for better semantics.
> > It's used in lots of places though, which is a valid counter argument.
> 
> I am not so much arguing that "struct reference" is misnamed, as that it
> is sufficiently generic that people will reach for it when it is not the
> appropriate tool. It is for passing the ref data to the iterator
> callback, but it probably doesn't make sense in other contexts. Would we
> ever expect anybody to declare their own "struct reference" in a local
> function? I don't think so.

Hm. The thing is: if `struct reference` is established in our code base,
and if it is a simple representation of a reference, then I think it
might even be a good thing to having it. I could for example see that we
gain more interfaces over time that use it.

For example, functions like `refs_read_ref()` could totally be adapted
to use the same struct, and I would claim that this is a good thing.
We'd basically have a single central structure that allows us to get a
reference out of the "refs" subsystem with metadata.

This would for example allow us to make the peeling infrastructure
available in contexts where we don't use an iterator, which is something
that we cannot do right now. In the end, what this would enable is to
have higher-level interfaces for references.

So yes, `struct reference` is rather generic. But if it's the ref system
owning it I think it's sensible, because references are basically what
this subsystem is all about. This is somewhat equivalent to `struct
object`: the struct name is generic, but it's the basic building block
for our object subsystem.

> And yes, "struct ref" suffers somewhat from the same problem. It is
> mostly about using refs in one specific space, but the name does not
> really help clarify that. I wouldn't mind seeing that improved, but yes,
> it would be a noisy patch. I don't know if remote_ref is the right name,
> though (the "peer_ref" links mean we store both local and remote refs in
> it, IIRC).

If we decide to do it it should definitely be a standalone patch (or
patch series). I'm also open for different naming suggestions, but for
now this is the best I could come up with.

Thanks!

Patrick

  reply	other threads:[~2025-10-09  7:24 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07 10:58 [PATCH 00/13] refs: improvements and fixes for peeling tags Patrick Steinhardt
2025-10-07 10:58 ` [PATCH 01/13] refs: introduce wrapper struct for `each_ref_fn` Patrick Steinhardt
2025-10-07 18:05   ` Justin Tobler
2025-10-08 13:42     ` Patrick Steinhardt
2025-10-07 21:56   ` Taylor Blau
2025-10-08 15:52   ` shejialuo
2025-10-09  6:03     ` Patrick Steinhardt
2025-10-07 10:58 ` [PATCH 02/13] refs: introduce `.ref` field for the base iterator Patrick Steinhardt
2025-10-07 14:24   ` Karthik Nayak
2025-10-08 13:44     ` Patrick Steinhardt
2025-10-08 15:03       ` Patrick Steinhardt
2025-10-07 20:19   ` Justin Tobler
2025-10-07 21:57   ` Taylor Blau
2025-10-07 10:58 ` [PATCH 03/13] refs: refactor reference status flags Patrick Steinhardt
2025-10-07 14:27   ` Karthik Nayak
2025-10-08 13:44     ` Patrick Steinhardt
2025-10-07 10:58 ` [PATCH 04/13] refs: expose peeled object ID via the iterator Patrick Steinhardt
2025-10-07 14:52   ` Karthik Nayak
2025-10-08 13:45     ` Patrick Steinhardt
2025-10-15  8:28       ` Karthik Nayak
2025-10-07 10:58 ` [PATCH 05/13] upload-pack: convert to use `reference_get_peeled_oid()` Patrick Steinhardt
2025-10-07 16:18   ` Karthik Nayak
2025-10-08 13:45     ` Patrick Steinhardt
2025-10-07 10:58 ` [PATCH 06/13] ref-filter: propagate peeled object ID Patrick Steinhardt
2025-10-07 10:58 ` [PATCH 07/13] builtin/show-ref: convert to use `reference_get_peeled_oid()` Patrick Steinhardt
2025-10-07 10:58 ` [PATCH 08/13] refs: drop `current_ref_iter` hack Patrick Steinhardt
2025-10-07 10:58 ` [PATCH 09/13] refs: drop infrastructure to peel via iterators Patrick Steinhardt
2025-10-07 10:58 ` [PATCH 10/13] object: add flag to `peel_object()` to verify object type Patrick Steinhardt
2025-10-08 11:04   ` Kristoffer Haugsbakk
2025-10-07 10:58 ` [PATCH 11/13] refs: don't store peeled object IDs for invalid tags Patrick Steinhardt
2025-10-07 10:58 ` [PATCH 12/13] ref-filter: detect broken tags when dereferencing them Patrick Steinhardt
2025-10-07 10:58 ` [PATCH 13/13] ref-filter: parse objects on demand Patrick Steinhardt
2025-10-08 11:05   ` Kristoffer Haugsbakk
2025-10-08 13:45     ` Patrick Steinhardt
2025-10-07 21:00 ` [PATCH 00/13] refs: improvements and fixes for peeling tags Junio C Hamano
2025-10-07 21:49   ` Taylor Blau
2025-10-07 23:01 ` Junio C Hamano
2025-10-08 15:50 ` [PATCH v2 00/14] " Patrick Steinhardt
2025-10-08 15:50   ` [PATCH v2 01/14] refs: introduce wrapper struct for `each_ref_fn` Patrick Steinhardt
2025-10-08 15:50   ` [PATCH v2 02/14] refs: introduce `.ref` field for the base iterator Patrick Steinhardt
2025-10-08 15:50   ` [PATCH v2 03/14] refs: fully reset `struct ref_iterator::ref` on iteration Patrick Steinhardt
2025-10-08 15:50   ` [PATCH v2 04/14] refs: refactor reference status flags Patrick Steinhardt
2025-10-08 15:50   ` [PATCH v2 05/14] refs: expose peeled object ID via the iterator Patrick Steinhardt
2025-10-08 15:50   ` [PATCH v2 06/14] upload-pack: convert to use `reference_get_peeled_oid()` Patrick Steinhardt
2025-10-08 15:50   ` [PATCH v2 07/14] ref-filter: propagate peeled object ID Patrick Steinhardt
2025-10-08 15:50   ` [PATCH v2 08/14] builtin/show-ref: convert to use `reference_get_peeled_oid()` Patrick Steinhardt
2025-10-08 15:50   ` [PATCH v2 09/14] refs: drop `current_ref_iter` hack Patrick Steinhardt
2025-10-08 15:50   ` [PATCH v2 10/14] refs: drop infrastructure to peel via iterators Patrick Steinhardt
2025-10-08 15:50   ` [PATCH v2 11/14] object: add flag to `peel_object()` to verify object type Patrick Steinhardt
2025-10-08 15:50   ` [PATCH v2 12/14] refs: don't store peeled object IDs for invalid tags Patrick Steinhardt
2025-10-08 16:27     ` shejialuo
2025-10-09  5:22       ` Patrick Steinhardt
2025-10-08 15:50   ` [PATCH v2 13/14] ref-filter: detect broken tags when dereferencing them Patrick Steinhardt
2025-10-08 15:50   ` [PATCH v2 14/14] ref-filter: parse objects on demand Patrick Steinhardt
2025-10-09  5:38   ` [PATCH v2 00/14] refs: improvements and fixes for peeling tags Jeff King
2025-10-09  6:09     ` Patrick Steinhardt
2025-10-09  6:39       ` Jeff King
2025-10-09  7:24         ` Patrick Steinhardt [this message]
2025-10-10  5:12           ` Jeff King
2025-10-10  5:22             ` Patrick Steinhardt
2025-10-10  6:26               ` Jeff King
2025-10-10 15:29               ` Junio C Hamano
2025-10-14  6:31                 ` Patrick Steinhardt
2025-10-14 16:52                   ` Junio C Hamano
2025-10-09 10:11         ` Toon Claes
2025-10-09 19:37     ` Junio C Hamano
2025-10-22  6:41 ` [PATCH v3 " Patrick Steinhardt
2025-10-22  6:41   ` [PATCH v3 01/14] refs: introduce wrapper struct for `each_ref_fn` Patrick Steinhardt
2025-10-22  6:41   ` [PATCH v3 02/14] refs: introduce `.ref` field for the base iterator Patrick Steinhardt
2025-10-22  6:41   ` [PATCH v3 03/14] refs: fully reset `struct ref_iterator::ref` on iteration Patrick Steinhardt
2025-10-22  6:41   ` [PATCH v3 04/14] refs: refactor reference status flags Patrick Steinhardt
2025-10-22  6:41   ` [PATCH v3 05/14] refs: expose peeled object ID via the iterator Patrick Steinhardt
2025-10-22  6:41   ` [PATCH v3 06/14] upload-pack: convert to use `reference_get_peeled_oid()` Patrick Steinhardt
2025-10-22  6:41   ` [PATCH v3 07/14] ref-filter: propagate peeled object ID Patrick Steinhardt
2025-10-22  6:41   ` [PATCH v3 08/14] builtin/show-ref: convert to use `reference_get_peeled_oid()` Patrick Steinhardt
2025-10-22  6:41   ` [PATCH v3 09/14] refs: drop `current_ref_iter` hack Patrick Steinhardt
2025-10-22  6:41   ` [PATCH v3 10/14] refs: drop infrastructure to peel via iterators Patrick Steinhardt
2025-10-22  6:41   ` [PATCH v3 11/14] object: add flag to `peel_object()` to verify object type Patrick Steinhardt
2025-10-22  6:41   ` [PATCH v3 12/14] refs: don't store peeled object IDs for invalid tags Patrick Steinhardt
2025-10-22  6:41   ` [PATCH v3 13/14] ref-filter: detect broken tags when dereferencing them Patrick Steinhardt
2025-10-22  6:41   ` [PATCH v3 14/14] ref-filter: parse objects on demand Patrick Steinhardt
2025-10-22 15:27     ` Junio C Hamano
2025-10-23  6:00       ` Patrick Steinhardt
2025-10-22 10:57   ` [PATCH v3 00/14] refs: improvements and fixes for peeling tags Karthik Nayak
2025-10-22 14:47   ` Junio C Hamano
2025-10-23  5:52     ` Patrick Steinhardt
2025-10-23  7:16 ` [PATCH v4 " Patrick Steinhardt
2025-10-23  7:16   ` [PATCH v4 01/14] refs: introduce wrapper struct for `each_ref_fn` Patrick Steinhardt
2025-10-23  7:16   ` [PATCH v4 02/14] refs: introduce `.ref` field for the base iterator Patrick Steinhardt
2025-10-23  7:16   ` [PATCH v4 03/14] refs: fully reset `struct ref_iterator::ref` on iteration Patrick Steinhardt
2025-10-23  7:16   ` [PATCH v4 04/14] refs: refactor reference status flags Patrick Steinhardt
2025-10-23  7:16   ` [PATCH v4 05/14] refs: expose peeled object ID via the iterator Patrick Steinhardt
2025-10-23  7:16   ` [PATCH v4 06/14] upload-pack: convert to use `reference_get_peeled_oid()` Patrick Steinhardt
2025-10-23  7:16   ` [PATCH v4 07/14] ref-filter: propagate peeled object ID Patrick Steinhardt
2025-10-23  7:16   ` [PATCH v4 08/14] builtin/show-ref: convert to use `reference_get_peeled_oid()` Patrick Steinhardt
2025-10-23  7:16   ` [PATCH v4 09/14] refs: drop `current_ref_iter` hack Patrick Steinhardt
2025-10-23  7:16   ` [PATCH v4 10/14] refs: drop infrastructure to peel via iterators Patrick Steinhardt
2025-10-23  7:16   ` [PATCH v4 11/14] object: add flag to `peel_object()` to verify object type Patrick Steinhardt
2025-10-23  7:16   ` [PATCH v4 12/14] refs: don't store peeled object IDs for invalid tags Patrick Steinhardt
2025-10-23  7:16   ` [PATCH v4 13/14] ref-filter: detect broken tags when dereferencing them Patrick Steinhardt
2025-10-23  7:16   ` [PATCH v4 14/14] ref-filter: parse objects on demand Patrick Steinhardt
2025-11-04 22:07     ` Jeff King
2025-11-04 23:40       ` Junio C Hamano
2025-11-04 23:54         ` Jeff King
2025-10-23 23:06   ` [PATCH v4 00/14] refs: improvements and fixes for peeling tags Junio C Hamano
2025-10-24  5:12     ` Patrick Steinhardt

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=aOdjM8F6WvTEBIo_@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jltobler@gmail.com \
    --cc=karthik.188@gmail.com \
    --cc=kristofferhaugsbakk@fastmail.com \
    --cc=me@ttaylorr.com \
    --cc=peff@peff.net \
    /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;
as well as URLs for NNTP newsgroup(s).