mbox series

[0/4] refs: improve handling of special refs

Message ID cover.1701243201.git.ps@pks.im (mailing list archive)
Headers show
Series refs: improve handling of special refs | expand

Message

Patrick Steinhardt Nov. 29, 2023, 8:14 a.m. UTC
Hi,

there are a bunch of "special" refs in Git that sometimes behave like a
normal reference and sometimes they don't. These references are written
to directly via the filesystem without going through the reference
backend, but the expectation is that those references can then be read
by things like git-rev-parse(1).

We do not currently have a single source of truth for what those special
refs are, and we also don't have clear rules for how they should be
written to. This works in the context of the files backend, because it
is able to read back such manually-written loose references just fine.
But once the reftable backend lands this will stop working.

This patch series tries to improve this state by doing two things:

    1. We explicitly mark these references as special by introducing a
       new `is_special_ref()` function. This serves as documentation,
       but will also cause us to explicitly read all of these special
       refs via loose files regardless of the actual backend.

    2. We document a new rule around writing refs. Namely, normal
       references are _always_ written via the reference backend,
       whereas special references are _always_ written directly via the
       filesystem. This rule is not enforced anywhere, but at least it's
       now made more explicit.

The last patch fixes one of the instances where we treat a reference
inconsistently by converting it to a normal reference. We can eventually
migrate more of the special refs to become normal refs as we deem fit,
but I consider this to be out of scope for this patch series.

These patches improve compatibility with the new reftable backend.

Patrick

Patrick Steinhardt (4):
  wt-status: read HEAD and ORIG_HEAD via the refdb
  refs: propagate errno when reading special refs fails
  refs: complete list of special refs
  bisect: consistently write BISECT_EXPECTED_REV via the refdb

 bisect.c                    | 25 +++------------
 builtin/bisect.c            |  8 ++---
 refs.c                      | 64 +++++++++++++++++++++++++++++++++++--
 t/t1403-show-ref.sh         |  9 ++++++
 t/t6030-bisect-porcelain.sh |  2 +-
 wt-status.c                 | 17 +++++-----
 6 files changed, 86 insertions(+), 39 deletions(-)

Comments

Taylor Blau Nov. 29, 2023, 10:14 p.m. UTC | #1
On Wed, Nov 29, 2023 at 09:14:07AM +0100, Patrick Steinhardt wrote:
> Patrick Steinhardt (4):
>   wt-status: read HEAD and ORIG_HEAD via the refdb
>   refs: propagate errno when reading special refs fails
>   refs: complete list of special refs
>   bisect: consistently write BISECT_EXPECTED_REV via the refdb
>
>  bisect.c                    | 25 +++------------
>  builtin/bisect.c            |  8 ++---
>  refs.c                      | 64 +++++++++++++++++++++++++++++++++++--
>  t/t1403-show-ref.sh         |  9 ++++++
>  t/t6030-bisect-porcelain.sh |  2 +-
>  wt-status.c                 | 17 +++++-----
>  6 files changed, 86 insertions(+), 39 deletions(-)

These all look pretty good to me. I had a few minor questions on the
first three patches, but I don't think they necessarily require a
reroll.

Thanks,
Taylor
Patrick Steinhardt Nov. 30, 2023, 7:46 a.m. UTC | #2
On Wed, Nov 29, 2023 at 05:14:39PM -0500, Taylor Blau wrote:
> On Wed, Nov 29, 2023 at 09:14:07AM +0100, Patrick Steinhardt wrote:
> > Patrick Steinhardt (4):
> >   wt-status: read HEAD and ORIG_HEAD via the refdb
> >   refs: propagate errno when reading special refs fails
> >   refs: complete list of special refs
> >   bisect: consistently write BISECT_EXPECTED_REV via the refdb
> >
> >  bisect.c                    | 25 +++------------
> >  builtin/bisect.c            |  8 ++---
> >  refs.c                      | 64 +++++++++++++++++++++++++++++++++++--
> >  t/t1403-show-ref.sh         |  9 ++++++
> >  t/t6030-bisect-porcelain.sh |  2 +-
> >  wt-status.c                 | 17 +++++-----
> >  6 files changed, 86 insertions(+), 39 deletions(-)
> 
> These all look pretty good to me. I had a few minor questions on the
> first three patches, but I don't think they necessarily require a
> reroll.

I agree that none of the comments really require a reroll, but I'll
address them if there will be another iteration of this patch series.

Thanks for your review! 

Patrick
Taylor Blau Nov. 30, 2023, 5:35 p.m. UTC | #3
On Thu, Nov 30, 2023 at 08:46:54AM +0100, Patrick Steinhardt wrote:
> On Wed, Nov 29, 2023 at 05:14:39PM -0500, Taylor Blau wrote:
> > These all look pretty good to me. I had a few minor questions on the
> > first three patches, but I don't think they necessarily require a
> > reroll.
>
> I agree that none of the comments really require a reroll, but I'll
> address them if there will be another iteration of this patch series.
>
> Thanks for your review!

No problem on either. I doubt that there will be another iteration of
this series since it is already good, so no need to worry too much about
these changes.

Thanks,
Taylor