git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jonathan Tan <jonathantanmy@google.com>
To: hanwen@google.com
Cc: jonathantanmy@google.com, git@vger.kernel.org
Subject: Re: [RFC PATCH 1/2] refs: make _advance() check struct repo, not flag
Date: Thu, 26 Aug 2021 15:24:39 -0700	[thread overview]
Message-ID: <20210826222439.3915402-1-jonathantanmy@google.com> (raw)
In-Reply-To: <CAFQ2z_PKKZJY1kC1QJo8Zwq_yNh5QNGc3S5bq1jBfSfK3vQwRQ@mail.gmail.com>

> from a design perspective, it would be nice if the ref backend
> wouldn't need to know about the object store. Can't this be hidden in
> the layer in refs.c that calls into the backends?

Thanks for taking a look.

The answer requires additional context, so I'll answer this at the end
of this email.

> If they have to know about the object store, have you considered
> passing the repository pointer
> in xxx_ref_store_create() ? Then there is no possibliity to mismatch
> the repository pointers and with the ref store.

I thought about that, but didn't want to make things worse - the effort
in this patch set is, after all, to attempt to increase the dissociation
between the ref stores and a certain object store (that is,
the_repository's object store), and I thought that reintroducing an
association (albeit to arbitrary object stores instead of a hardcoded
object store) would be a step back.

But this may be the way to go - the ref stores already have a gitdir
field that we could replace with a struct repository field.

> > - Making all ref stores not access the object store during their
> >   _advance() callbacks, and making ref_iterator_advance() be responsible
> >   for checking the object store - thus, simplifying the code in that the
> >   logic of checking for the flag (current) or the pointer (after the
> >   equivalent of this commit) is only in one place instead of in every
> >   ref store's callback. However, the ref stores already make use of this
> >   flag for another reason - for determining if refs are resolvable when
> >   writing (search for "REF_STORE_ODB"). Thus, I decided to retain each
> 
> I looked, but I couldn't figure out how this flag is used.

I was thinking of files_ref_iterator_begin() setting a local variable
required_flags. Somehow I thought that files_pack_refs() relied on
files_ref_iterator_begin() setting that variable, but now I see that
that's not true - both functions are independently checking that the
underlying ref store supports ODB access, so I can remove ODB from
files_ref_iterator_begin() if I want to.

To go back to the question at the top, now I agree that hiding the ODB
access in _advance() in the layer in refs.c is possible. The last part
still accessing the ODB is files_pack_refs(), I think. Refactoring that
is possible, but I'll leave that to another patch set.

If you or anyone else has more questions or comments, please reply - and
in the meantime, I'll update this patch set to move the ODB access in
_advance() to the layer in refs.c.

  reply	other threads:[~2021-08-26 22:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25 23:23 [RFC PATCH 0/2] First steps towards iterating over submodule refs Jonathan Tan
2021-08-25 23:23 ` [RFC PATCH 1/2] refs: make _advance() check struct repo, not flag Jonathan Tan
2021-08-26 16:39   ` Han-Wen Nienhuys
2021-08-26 22:24     ` Jonathan Tan [this message]
2021-09-14 22:41       ` Glen Choo
2021-09-15  7:35         ` Han-Wen Nienhuys
2021-09-16 17:26           ` Jonathan Tan
2021-09-16 21:56             ` Junio C Hamano
2021-09-16 22:05               ` Jonathan Tan
2021-09-16 17:24         ` Jonathan Tan
2021-08-25 23:23 ` [RFC PATCH 2/2] refs: add repo paramater to _iterator_peel() Jonathan Tan

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210826222439.3915402-1-jonathantanmy@google.com \
    --to=jonathantanmy@google.com \
    --cc=git@vger.kernel.org \
    --cc=hanwen@google.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).