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

Re: [PATCH] diff-lib: skip leading path check for fsmonitor-valid entries

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 18, 2026, 19:01 UTC
Message-ID
<xmqqse0y55gp.fsf@gitster.g>
In-Reply-To
<pull.2318.git.1795026168007.gitgitgadget@gmail.com>
"Maik Riechert via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 19 quoted lines
> diff --git a/diff-lib.c b/diff-lib.c
> index 086476bd77..3730e04149 100644
> --- a/diff-lib.c
> +++ b/diff-lib.c
> @@ -43,10 +43,10 @@ static int check_removed(const struct cache_entry *ce, struct stat *st)
>  {
>  	int stat_err;
>  
> -	if (!(ce->ce_flags & CE_FSMONITOR_VALID))
> -		stat_err = lstat(ce->name, st);
> -	else
> -		stat_err = fake_lstat(ce, st);
> +	if (ce->ce_flags & CE_FSMONITOR_VALID)
> +		return fake_lstat(ce, st);
> +
> +	stat_err = lstat(ce->name, st);
>  	if (stat_err < 0) {
>  		if (!is_missing_file_error(errno))
>  			return -1;

Now that stat_err is used only once, we can retire the variable and inline the lstat() call inside the if() condition.

Other than that, assuming that the CE_FSMONITOR_VALID bit is trustworthy, the change looks OK. has_symlink_leading_path() would be fairly expensive and being able to avoid it is a big plus, which is done in other code paths like read-cache.c:refresh_cache_ent() and preload-index.c:preload_thread() already.

Previous: Maik Riechert via GitGitGadgetNext: Maik Riechert via GitGitGadget
Message 2 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.