On Mon, Oct 17, 2016 at 10:30:28AM -0700, Junio C Hamano wrote:
> > It looks like I _did_ look into optimizing this into a single stat()
> > call in the thread at . I completely forgot about that. I did find
> > there that naively using stat_validity() on a directory is racy, though
> > I wonder if we could do something clever with gettimeofday() instead.
> It feels funny to hear an idea to compare fs timestamp with gettimeofday
> immedately after hearing the word NFS, though ;-).
Yeah, I had a funny feeling in my stomach as I wrote that.
What you really want to know is the current filesystem time. You'd
probably have to do something gross like creating a new file and then
comparing its timestamp. In theory you'd only have to do that _once_,
and then as long as the pack directory wasn't changing, you could say "I
don't know what time it is now, but I know it is at least time X, and I
know that X is greater than Y, the pack directory timestamp, therefore
the pack directory hasn't changed since I last looked".
That assumes monotonic clocks, but we basically already do so for the
racy-git checks, I think.
I dunno. It feels...complicated. And bad to require writing to the
repository for what would otherwise be a read-only operation. But I
don't see any fundamental reason it could not work.