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

Re: [PATCH] commit-reach: do not parse and iterate minima

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 23, 2022, 23:30 UTC
Message-ID
<xmqqbkxwp7qp.fsf@gitster.g>
In-Reply-To
<20220323210803.1130790-1-jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 29 quoted lines
> When a commit is parsed, it pretends to have a different (possibly
> empty) list of parents if there is graft information for that commit.
> But there is a bug that could occur when a commit is parsed, the graft
> information is updated (for example, when a shallow file is rewritten),
> and the same commit is subsequently used: the parents of the commit do
> not conform to the updated graft information, but the information at the
> time of parsing.
>
> This is usually not an issue, as a commit is usually introduced into the
> repository at the same time as its graft information. That means that
> when we try to parse that commit, we already have its graft information.
>
> However, this is not the case when fetching with --update-shallow. In
> post_assign_shallow() in shallow.c, a revision walk is done that also
> parses commits at the shallow boundary before updating the shallow
> information (and hence, the graft information). (This revision walk
> needs to be done before the update because the nature of the update
> depends on the outcome of the revision walk.) If we were to
> revision-walk such a commit (at the shallow boundary), we would end up
> trying and failing to parse its parents because its list of parents is
> not empty (since it was parsed before there was any graft information
> telling us to conceal its parents). This revision walk will happen if
> the client has submodules, as it will revision-walk the fetched commits
> to check for new submodules, triggering this bug.
>
> This revision walk in post_assign_shallow() actually does not need to go
> beyond the shallow boundaries, so the solution is twofold: (1) do not
> iterate beyond such commits, and (2) in doing so, we no longer need to
> parse them, so do not parse them.

This sounds quite tricky. In this case we may know which commit we need to avoid (re)parsing to avoid the bug, but would it always be the case? It feels almost like we want to unparse the commit objects when we clear the grafts information in the previous patch, doesn't it?

Previous: Jonathan TanNext: Derrick Stolee
Message 2 of 16 in “commit-reach: do not parse and iterate minima”
  1. commit-reach: do not parse and iterate minimaJonathan Tan, Mar 23, 2022
  2. Junio C HamanoMar 23, 2022
  3. Derrick StoleeMar 24, 2022
  4. Taylor BlauMar 24, 2022
  5. Derrick StoleeMar 25, 2022
  6. Jonathan TanMar 24, 2022
  7. Bagas SanjayaMar 24, 2022
  8. Jonathan TanMar 24, 2022
  9. Derrick StoleeMar 24, 2022
  10. Jonathan TanMar 24, 2022
  11. commit,shallow: unparse commits if grafts changedJonathan Tan, Jun 2, 2022
  12. Ævar Arnfjörð BjarmasonJun 3, 2022
  13. Derrick StoleeJun 3, 2022
  14. Jonathan TanJun 3, 2022
  15. Jonathan TanJun 3, 2022
  16. commit,shallow: unparse commits if grafts changedJonathan Tan, Jun 6, 2022

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.