Re: [PATCH v3 3/3] core: convert build-time USE_NSEC into runtime core.useNanosec
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Aug 20, 2026, 05:24 UTC
- Message-ID
- <aoaPn0gaHIa9Utwu@pks.im>
- In-Reply-To
- <CALnO6CDgfT+VXaBqSmStB8vNOwBpr5XMjvmxhMdc7v-ma-YwXg@mail.gmail.com>
On Wed, Aug 19, 2026 at 09:09:59AM -0400, D. Ben Knoble wrote:
Show 37 quoted lines
> On Wed, Aug 19, 2026 at 4:24 AM Patrick Steinhardt <ps@pks.im> wrote:
> > On Tue, Aug 18, 2026 at 10:59:47AM -0400, D. Ben Knoble wrote:
> > > diff --git a/read-cache.c b/read-cache.c
> > > index 6c449f393d..31888f77ee 100644
> > > --- a/read-cache.c
> > > +++ b/read-cache.c
> > > @@ -353,12 +353,18 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
> > > static int is_racy_stat(const struct index_state *istate,
> > > const struct stat_data *sd)
> > > {
> > > +#ifndef NO_NSEC
> > > + int use_nsec = repo_config_values(istate->repo)->use_nanosec;
> > > +#endif
> > > +
> > > return (istate->timestamp.sec &&
> > > -#ifdef USE_NSEC
> > > - /* nanosecond timestamped files can also be racy! */
> > > - (istate->timestamp.sec < sd->sd_mtime.sec ||
> > > - (istate->timestamp.sec == sd->sd_mtime.sec &&
> > > - istate->timestamp.nsec <= sd->sd_mtime.nsec))
> > > +#ifndef NO_NSEC
> > > + /* nanosecond timestamped files can also be racy! */
> > > + use_nsec
> > > + ? (istate->timestamp.sec < sd->sd_mtime.sec ||
> > > + (istate->timestamp.sec == sd->sd_mtime.sec &&
> > > + istate->timestamp.nsec <= sd->sd_mtime.nsec))
> > > + : istate->timestamp.sec <= sd->sd_mtime.sec
> > > #else
> > > istate->timestamp.sec <= sd->sd_mtime.sec
> > > #endif
> >
> > I think this would be a bit more readable if we had a single NO_NSEC
> > block.
>
> I'm not sure what "single block" means here, but I think the plan (see
> reply to Junio) is to make this more readable by not needing
> pre-processor directives at all.That'd be quite welcome indeed. The less ifdeffery the bettery. :)
Show 8 quoted lines
> > There's one more site in "builtin/update-index.c" where we mention > > USE_NSEC that wasn't updated as part of this patch. > > Oh, did I miss one? The only spot I saw in builtin/update-index.c that > mentions USE_NSEC is a comment that I'm sure patch 3 updated. Maybe > you were thinking of that, or maybe you know of something I left out? > (That is, locally on this branch, "git grep USE_NSEC" returns one hit > in Documentation/RelNotes/2.5.0.adoc.)
Oh, I guess I just missed it because I already trimmed context of this mail. Never mind then.
Patrick