When calling read_dir during status and the directory is found to be
eligible for caching (see code comments), write the directory’s mtime to the
dirstate. The presence of a directory mtime in the dirstate is meaningful
and indicates eligibility.
When an eligible directory mtime is found in the dirstate and stat() shows
that the mtime has not changed, status can skip calling read_dir again
and instead rely on the names of child nodes in the dirstate tree.
The tempfile crate is used to create a temporary file in order to use its
modification time as "current time" with the same truncation as other files
and directories would have in their own modification time.
I would point to the ambiguity resolution due to insufficient granularity in this comment so that we don't get the impression that this is naive too fast.