Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Maik Riechert via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Josip Sokcevic <sokcevic@google.com>,
	 Maik Riechert <letmaik@outlook.com>
Subject: Re: [PATCH] diff-lib: skip leading path check for fsmonitor-valid entries
Date: Wed, 18 Nov 2026 11:01:42 -0800	[thread overview]
Message-ID: <xmqqse0y55gp.fsf@gitster.g> (raw)
In-Reply-To: <pull.2318.git.1795026168007.gitgitgadget@gmail.com> (Maik Riechert via GitGitGadget's message of "Wed, 18 Nov 2026 18:22:47 +0000")

"Maik Riechert via GitGitGadget" <gitgitgadget@gmail.com> writes:

> 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.


      reply	other threads:[~2026-11-18 19:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 18:22 [PATCH] diff-lib: skip leading path check for fsmonitor-valid entries Maik Riechert via GitGitGadget
2026-11-18 19:01 ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqse0y55gp.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=letmaik@outlook.com \
    --cc=sokcevic@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox