Re: [PATCH] rev-list: allow cached objects in existence check
- Date: Mon, 4 Mar 2019 16:17:49 -0500
- From: Jeff King <peff@xxxxxxxx>
- Subject: Re: [PATCH] rev-list: allow cached objects in existence check
On Mon, Mar 04, 2019 at 11:19:32AM -0800, Jonathan Tan wrote:
> > - 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
> 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. :)