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

Re: [RFC PATCH 1/2] refs: make _advance() check struct repo, not flag

From
Han-Wen Nienhuys <hanwen@google.com>
Date
Sep 15, 2021, 07:35 UTC
Message-ID
<CAFQ2z_ML_g6DTiG92srq8UCCu_D8bi6z1mP_znt24TJagVfi2g@mail.gmail.com>
In-Reply-To
<YUElL3RI0VTnjE5C@chooglen-macbookpro.roam.corp.google.com>
On Wed, Sep 15, 2021 at 12:41 AM Glen Choo <chooglen@google.com> wrote:
Show 7 quoted lines
> In the current state of affairs, the files ref store and the packed ref
> store seem to behave as a single logical ref database. An example of
> this (that I care about in particular) is in refs/files-backend.c where
> the files backend validates oids using the_repository's odb.
> refs/packed-backend.c doesn't do any such validation, and presumably
> just relies on the correctness of refs/files-backend.c. I assume that
> this also explains why some functions in refs_be_packed are stubs.

The loose/packed storage is implemented in terms of files backend (the public entry point) that defers to a packed backend in some cases. The latter is implemented as a ref backend, but for no good reason.

Show 10 quoted lines
> The answer to whether or not a ref store should refer to a certain
> object store seems unresolved because a ref store is trying to do two
> separate things. Perhaps it is reasonable to associate a ref database
> with an object store (so that it can validate its refs), but we would
> prefer to dissociate the physical ref storage layer from the object
> store. (I'm paraphrasing Johnathan Nieder here, this isn't an original
> thought).
>
> Perhaps this is a question we want to resolve when considering reftable
> and other ref databases.

Work on reftable shows that there are more egregious breaks of abstraction boundaries. For example, there are still parts of the code that equate

  (file under .git/ == ref)

you can find a good part of them if you run GIT_TEST_REFTABLE=1 with the reftable support switched on. Another place where API contracts are unclear is resolving symrefs: on first sight, you'd think that a ref backend should just provide storage for a refname => {symref, commit SHA-1, tag + commit SHA-1} mapping. However, in some places it is currently necessary for the ref backend to resolve symrefs. You can find these places by grepping for refs_resolve_ref_unsafe() in the files backend.

I think Jonathan is right, but I also think that teasing apart the ref backend and the ODB is premature until the ref backend itself is a strongly enforced abstraction boundary.

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Previous: Glen ChooNext: Jonathan Tan
Message 6 of 11 in “First steps towards iterating over submodule refs”
  1. 0/2 First steps towards iterating over submodule refsJonathan Tan, Aug 25, 2021
  2. 1/2 refs: make _advance() check struct repo, not flagJonathan Tan, Aug 25, 2021
  3. Han-Wen NienhuysAug 26, 2021
  4. Jonathan TanAug 26, 2021
  5. Glen ChooSep 14, 2021
  6. Han-Wen NienhuysSep 15, 2021
  7. Jonathan TanSep 16, 2021
  8. Junio C HamanoSep 16, 2021
  9. Jonathan TanSep 16, 2021
  10. Jonathan TanSep 16, 2021
  11. 2/2 refs: add repo paramater to _iterator_peel()Jonathan Tan, Aug 25, 2021

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.