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

Re: [PATCH 0/8] fetch: refactor code that prints reference updates

From
Patrick Steinhardt <ps@pks.im>
Date
Mar 20, 2023, 06:57 UTC
Message-ID
<ZBgD3Ux34V/U/Lv5@ncase>
In-Reply-To
<20230317202449.1083635-1-jonathantanmy@google.com>
On Fri, Mar 17, 2023 at 01:24:49PM -0700, Jonathan Tan wrote:
Show 13 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> >     1. We want to take control of the reference updates so that we can
> >        atomically update all or a subset of references that git-fetch
> >        would have updated.
> > 
> >     2. We want to be able to quarantine objects in a fetch so that we
> >        can e.g. perform consistency checks for them before they land in
> >        the main repository.
> 
> If you want to do this, something that might be possible is to change
> the RHS of the refspecs to put the refs in a namespace of your choice
> (e.g. ...:refs/<UUID>/...) and then you can look at what's generated and
> process them as you wish.
There's two major problems with this, unfortunately:
- We want to use the machine-parseable format in our repository
  mirroring functionality, where you can easily end up fetching
  thousands or even hundreds of thousands of references. If you need to
  write all of them anew in a first step then you'll end up slower than
  before.
- Repository mirroring is comparatively flexible in what it allows. Most
  importantly, it gives you the opiton to say that divergent references
  should not be updated at all, which translates into an unforced fetch.
  It's even possible to have fetches with mixed forced and unforced
  reference updates. So if we fetched into a separate namespace first,
  we'd now have to reimplement checks for forced updates in Gitaly so
  that we correctly update only those refs that would have been updated
  by Git. We'd also need to manually figure out deleted references.
  This would be quite a risky change and would duplicate a lot of
  knowledge. Furthermore, merging the two sets of references would
  likely be quite expensive performance-wise.

Also, even if we did have a different RHS, it still wouldn't fix the issue that objects are written into the main object database directly. Ideally, we'd really only accept changes into the repository once we have fully verified all of them. Right now it can happen that we refuse a fetch, but the objects would continue to exist in the repository.

A second motivation for the quarantine directory is so that we can enumerate all objects that are indeed new. This will eventually be used to implement more efficient replication of the repository, where we can theoretically just take all of the fetched objects in the quarantine object directory and copy it to the replicas of that repository.

[snip]
Show 7 quoted lines
> >   fetch: deduplicate handling of per-reference format
> 
> I'm not so sure that this is the correct abstraction. I think that this
> and the last patch might be counterproductive to your stated goal of
> having one more mode of printing the refs, in fact, since when we have
> that new mode, the format would be different but the printing would
> remain (so we should split the format and printing).

I already have the full implementation of the new machine-parseable format available locally, but didn't want to send it as part of this patch series yet to avoid it becoming overly large. But I can say that this change really did make the end goal easier to achieve, due to two reasons:

- If we continued to handle the per-reference format at the different
  callsites, I'd have to also amend each of the callers when introducing
  the new format as we're going to use a different format there. But
  when doing this in `format_display()`, we really only need to have a
  single switch at the beginning to check whether to use the machine
  parseable format or the other one.
- Currently, all reference updates are printed to stderr. As stderr is
  also used to display errors and the progress bar, this really makes it
  not a good fit for the machine-parseable format. Instead, I decided
  that it would make more sense to print the new format to stdout. And
  by having the printing-logic self-contained we again only have a
  single location we need to change.

I realize though that all of this isn't as well-documented in the commit messages as it should be, which is also something that Junio complained about. I'll hopefully do a better job in v2 of this patch series.

Show 12 quoted lines
> >   fetch: deduplicate logic to print remote URL
> 
> Makes sense, although I would need to consider only storing the
> raw URL in the struct display_state and processing it when it needs
> to be emitted (haven't checked if this is feasible, though).
> 
> >   fetch: fix inconsistent summary width for pruned and updated refs
> 
> This changes the behavior in that the summary width, even when printing
> the summary of pruned refs, is computed based only on the updated refs.
> The summary width might need to remain out of the struct display_state
> for now.
Fair, that's a case I didn't yet consider. I'll have another look.
Patrick
Previous: Jonathan TanNext: Patrick Steinhardt
Message 28 of 39 in “fetch: refactor code that prints reference updates”
  1. 0/8 fetch: refactor code that prints reference updatesPatrick Steinhardt, Mar 15, 2023
  2. 1/8 fetch: rename `display` buffer to avoid name conflictPatrick Steinhardt, Mar 15, 2023
  3. 2/8 fetch: move reference width calculation into `display_state`Patrick Steinhardt, Mar 15, 2023
  4. Junio C HamanoMar 15, 2023
  5. Patrick SteinhardtMar 16, 2023
  6. Junio C HamanoMar 16, 2023
  7. Patrick SteinhardtMar 17, 2023
  8. Junio C HamanoMar 16, 2023
  9. 3/8 fetch: move output format into `display_state`Patrick Steinhardt, Mar 15, 2023
  10. 4/8 fetch: pass the full local reference name to `format_display`Patrick Steinhardt, Mar 15, 2023
  11. Junio C HamanoMar 15, 2023
  12. 5/8 fetch: deduplicate handling of per-reference formatPatrick Steinhardt, Mar 15, 2023
  13. Junio C HamanoMar 15, 2023
  14. Patrick SteinhardtMar 16, 2023
  15. Junio C HamanoMar 16, 2023
  16. Patrick SteinhardtMar 17, 2023
  17. Junio C HamanoMar 17, 2023
  18. 7/8 fetch: fix inconsistent summary width for pruned and updated refsPatrick Steinhardt, Mar 15, 2023
  19. Junio C HamanoMar 15, 2023
  20. Patrick SteinhardtMar 16, 2023
  21. Junio C HamanoMar 16, 2023
  22. Patrick SteinhardtMar 17, 2023
  23. 6/8 fetch: deduplicate logic to print remote URLPatrick Steinhardt, Mar 15, 2023
  24. Junio C HamanoMar 15, 2023
  25. Patrick SteinhardtMar 16, 2023
  26. 8/8 fetch: centralize printing of reference updatesPatrick Steinhardt, Mar 15, 2023
  27. Jonathan TanMar 17, 2023
  28. Patrick SteinhardtMar 20, 2023
  29. Patrick SteinhardtMar 20, 2023
  30. 0/6 fetch: refactor code that prints reference updatesPatrick Steinhardt, Mar 20, 2023
  31. 1/6 fetch: move reference width calculation into `display_state`Patrick Steinhardt, Mar 20, 2023
  32. 2/6 fetch: move output format into `display_state`Patrick Steinhardt, Mar 20, 2023
  33. 3/6 fetch: pass the full local reference name to `format_display`Patrick Steinhardt, Mar 20, 2023
  34. 4/6 fetch: centralize handling of per-reference formatPatrick Steinhardt, Mar 20, 2023
  35. 5/6 fetch: centralize logic to print remote URLPatrick Steinhardt, Mar 20, 2023
  36. 6/6 fetch: centralize printing of reference updatesPatrick Steinhardt, Mar 20, 2023
  37. Jonathan TanMar 20, 2023
  38. Patrick SteinhardtMar 22, 2023
  39. Junio C HamanoMar 29, 2023

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.