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

Re: [PATCH] rev-list: allow cached objects in existence check

From
Jeff King <peff@peff.net>
Date
Mar 4, 2019, 21:17 UTC
Message-ID
<20190304211749.GA3020@sigill.intra.peff.net>
In-Reply-To
<20190304191932.105204-1-jonathantanmy@google.com>
On Mon, Mar 04, 2019 at 11:19:32AM -0800, Jonathan Tan wrote:
Show 14 quoted lines
> >   - some callers of has_sha1_file() might care about durability between
> >     processes. Because it's baked in, the empty tree is safe for that
> >     (whatever follow-on process runs, it will also be baked in there).
> >     But that's not necessarily true for other "cached" objects. I'm not
> >     really that worried about it because we use it sparingly (the only
> >     call to pretend_sha1_file() is in git-blame, and if it ever did ask
> >     "do we have this object", I actually think the right answer would be
> >     "yes").
> > 
> >     But if this is a concern, we could perhaps have two levels of flags:
> >     SKIP_CACHED and SKIP_INTERNAL.
> 
> Or teach git-blame to have its own pretend mechanism, and remove the
> pretend mechanism from sha1-file.c.

I think that would be ideal, but I'm not sure if it's feasible due to the layering of the various modules. IOW, the blame code isn't just pretending a fake object file for _itself_, it needs to then call into the diff code, which must be able to then find that content in order to produce a diff.

But maybe it is not so bad. Our diff_filespec struct does represent working-tree files (as it must, since we diff them!). So it may be possible to feed it to the diff code at the right spot.

I haven't looked closely enough to say for sure whether it's feasible or not. But it does imply to me that we should go with this regression fix in the near-term and think about building bigger changes separately on master.

Show 9 quoted lines
> The last time I deeply thought of this was during the partial clone
> implementation, so I am probably not completely up-to-date, but it seems
> to me that ideally, for reading, we would remove SKIP_CACHED completely
> (and always consult the cache), and also remove completely the ability
> to pretend (blame will have to do it by itself); and for writing, we
> would write the empty tree whenever we do now (for backwards
> compatibility with old versions of Git that read what we write). Both
> the approach in this patch and making has_object_file() respect cached
> objects are steps in that direction, so I'm OK with both.
Yeah, I think our world-views are in accord. :)
-Peff
Previous: Jonathan TanNext: Junio C Hamano
Message 3 of 6 in “rev-list: allow cached objects in existence check”
  1. rev-list: allow cached objects in existence checkJeff King, Mar 4, 2019
  2. Jonathan TanMar 4, 2019
  3. Jeff KingMar 4, 2019
  4. Junio C HamanoMar 5, 2019
  5. Jeff KingMar 5, 2019
  6. Junio C HamanoMar 5, 2019

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.