Re: [PATCH v5 3/3] core: convert build-time USE_NSEC into runtime core.useNanosec
From: D. Ben Knoble <hidden>
Date: 2026-08-31 00:27:25
On Sun, Aug 30, 2026 at 5:15 PM Junio C Hamano [off-list ref] wrote:
"D. Ben Knoble" [off-list ref] writes:quoted
+ /* nanosecond timestamped files can also be racy! */ + (repo_config_values(istate->repo)->use_nanosec + ? (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)); }Currently this is probably fine, but the use of repo_config_values() here means that the order in which we can transition/libify two unrelated things are forced on us: * We'd first need to make sure repo_config_values() can work on an instance of repository that is not the_repository, * And until the above happens, we cannot do a --recurse-submodule option that loads the index in a submodule and operate on it in the same process (e.g., "git diff --resurse-submodules"), because immediately at this step, istate taken from a submodule would have its .repo member pointing at something that is not the_repository and we will hit a BUG(). And after writing all of the above, I realized that I am mostly repeating what Patric already said in the upstream, e.g., https://lore.kernel.org/git/an720tZnot07HYiK@pks.im/ (local)
Yep---just so I'm clear, we don't currently have such an option, right? I mean, there is no --recurse-submodules for git-diff(1), and I tweaked t4060 to run "git -c core.useNanosec=true diff --submodule=diff" without any issue. I would happily prove that at least none of our existing tests fail with core.useNanosec=true, but I'm not really sure how to shove configuration into every test invocation of git. Even if we could, I'm not sure we necessarily want to add another CI job for that (though that's a separate matter). In particular, (among others) I have not received any concrete comments for
Comments welcome: I haven't touched any tests; I saw a bunch of hits for "git grep racy t" but wasn't sure how to fit this particular change in, especially since it won't be equally valid on all systems? Advice welcome.
so if there's at least a way to exercise this path on all the tests on my system (which should support it), that would probably be a good thing.
Other than that, this looks good to me.
Thank -- D. Ben Knoble