Re: [PATCH] fetch: use "quick" has_sha1_file for tag following
- From
Jeff King <peff@peff.net>
- Date
- Oct 18, 2016, 10:28 UTC
- Message-ID
- <20161018102813.mctfmrgljcxujkc7@sigill.intra.peff.net>
- In-Reply-To
- <xmqqeg3ex4qz.fsf@gitster.mtv.corp.google.com>
On Mon, Oct 17, 2016 at 10:30:28AM -0700, Junio C Hamano wrote:
Show 7 quoted lines
> > It looks like I _did_ look into optimizing this into a single stat() > > call in the thread at [1]. 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.
-Peff