git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: Maik Riechert via GitGitGadget
Message 4 of 4 in “diff-lib: skip leading path check for fsmonitor-valid entries”
  1. diff-lib: skip leading path check for fsmonitor-valid entriesMaik Riechert via GitGitGadget, Nov 18, 2026
  2. Junio C HamanoNov 18, 2026
  3. diff-lib: skip leading path check for fsmonitor-valid entriesMaik Riechert via GitGitGadget, Nov 19, 2026
  4. Junio C HamanoNov 19, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.