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

Re: [PATCH] shallow: reset commit grafts when shallow is reset

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 18, 2022, 00:50 UTC
Message-ID
<xmqqsfrgcccz.fsf@gitster.g>
In-Reply-To
<20220317182448.1633847-1-jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 14 quoted lines
> When reset_repository_shallow() is called, Git clears its cache of
> shallow information, so that if shallow information is re-requested, Git
> will read fresh data from disk instead of reusing its stale cached data.
> However, the cache of commit grafts is not likewise cleared, even though
> there are commit grafts created from shallow information.
>
> This means that if on-disk shallow information were to be updated and
> then a commit-graft-using codepath were run (for example, a revision
> walk), Git would be using stale commit graft information. This can be
> seen from the test in this patch, in which Git performs a revision walk
> (to check for changed submodules) after a fetch with --update-shallow.
>
> Therefore, clear the cache of commit grafts whenever
> reset_repository_shallow() is called.

Because this helper function resets not just grafts_nr, but commit_graft_prepared member, the next time prepare_commit_graft() is called, we'd recover the grafts (not derived from shallows, but read locally from "info/grafts") from the file, too, which makes it sound right ;-)

And the implementation looks quite straight-forward.
Will queue.  Thanks.
Previous: Glen Choo
Message 3 of 3 in “shallow: reset commit grafts when shallow is reset”
  1. shallow: reset commit grafts when shallow is resetJonathan Tan, Mar 17, 2022
  2. Glen ChooMar 17, 2022
  3. Junio C HamanoMar 18, 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.