Re: [PATCH v2] diff-lib: skip leading path check for fsmonitor-valid entries
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 19, 2026, 22:06 UTC
- Message-ID
- <xmqqv75sv5li.fsf@gitster.g>
- In-Reply-To
- <pull.2318.v2.git.1795067037014.gitgitgadget@gmail.com>
"Maik Riechert via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 16 quoted lines
> From: Maik Riechert <letmaik@outlook.com> > > Since 4f3d6d0261 (fsmonitor: skip lstat deletion check during git > diff-index, 2021-03-17), check_removed() does not lstat() entries > that fsmonitor says are unchanged. But it still calls > has_symlink_leading_path() for them, which lstat()s the directories > leading up to each path. > > That check is there to notice a leading directory that was replaced > by a symlink. fsmonitor would have reported such a change, and > refresh_fsmonitor() would have cleared CE_FSMONITOR_VALID for every > entry below it, so we would not get here. preload_index() already > trusts the flag this way and skips these entries altogether. > > The S_ISDIR() check that follows cannot trigger either: the mode > comes from the index, and gitlinks are never marked valid.
This is slightly misleading. S_IFGITLINK is given S_IFDIR | 0755 by st_mode_from_ce() that is called by fake_lstat(), so S_ISDIR() check *does* trigger. We have an extra S_ISGITLINK() guard in there, preventing us from calling repo_resolve_gitlink_ref().
It does not change the conclusion, though.
Show 13 quoted lines
> So return as soon as fake_lstat() has filled in the stat data. > > The first new test checks the shortcut itself by replacing a parent > directory with a symlink without telling fsmonitor. The other two make > sure we still notice when fsmonitor does report that directory, with > and without a trailing slash, since nothing else checks for it now. > > On Linux, with 100,000 files (ten per directory), a hook that > reports nothing and a warm cache, "git diff HEAD" goes from 57ms to > 26ms. > > Signed-off-by: Maik Riechert <letmaik@outlook.com> > ---
Will queue. Thanks.