]> git.ipfire.org Git - thirdparty/git.git/commit
diff-lib: fix check_removed() when fsmonitor is active
authorJunio C Hamano <gitster@pobox.com>
Thu, 14 Sep 2023 22:00:43 +0000 (15:00 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 16 Sep 2023 00:13:14 +0000 (17:13 -0700)
commit811c9c210265a16514fd1b5a513d4b028d711410
treecb7f492efef466fef4c3a1446a10476099094773
parent9510fe8940d48fdacabea543c83b9f74181bd077
diff-lib: fix check_removed() when fsmonitor is active

`git diff-index` may return incorrect deleted entries when fsmonitor
is used in a repository with git submodules. This can be observed on
Mac machines, but it can affect all other supported platforms too.

If fsmonitor is used, `stat *st` is left uninitialied if cache_entry
has CE_FSMONITOR_VALID bit set.  But, there are three call sites
that rely on stat afterwards, which can result in incorrect results.

We can fill members of "struct stat" that matters well enough using
the information we have in "struct cache_entry" that fsmonitor told
us is up-to-date to solve this.

Helped-by: Josip Sokcevic <sokcevic@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff-lib.c