From: Junio C Hamano Date: Wed, 18 Nov 2026 19:01:42 GMT Subject: Re: [PATCH] diff-lib: skip leading path check for fsmonitor-valid entries Message-ID: In-Reply-To: "Maik Riechert via GitGitGadget" 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.