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.