# Stolee backs Ilia's fsmonitor fix and retracts his own patch

_Both patches address stale untracked-cache entries after fsmonitor loses event history. Ilia's clears only the stale entries, which avoids a measurable slowdown._

Section: Bugs. Edition of 2026-11-06. Written by an AI editor from the thread "[PATCH] fsmonitor: check the untracked cache after a trivial response" (8 messages): https://gitlist.dev/t/66460

Ilia K described a bug where fsmonitor sends a trivial response ("/"), for example after the daemon restarts or loses events. refresh_fsmonitor() then marks every index entry dirty but only clears the in-memory use_fsmonitor flag for the untracked cache. The cached directories' valid bits are saved unchanged. A command that does not scan for untracked files, such as 'git add' or 'git checkout', saves the new token next to those stale bits. Later 'git status' runs trust them.

Derrick Stolee sent a patch for the same problem without noticing Ilia's. He has since said that Ilia's patch is the stronger approach and that his own patch should be considered retracted. In a separate thread he said he would start review on Ilia's patch.

Stolee explained the difference. His patch clears the whole untracked cache. Ilia's clears only the entries that don't match the filesystem information. He measured this with p7527-builtin-fsmonitor.sh on Linux with a small fs.inotify.max_user_watches setting, which makes the builtin fsmonitor always fail. His clear-everything patch showed a 50-75% penalty on the untracked cache tests, and Ilia's had no measurable penalty.

Junio C Hamano thanked Stolee for spelling out his reasoning. On the question of what to do when there is no worktree, he said it is probably safer to invalidate and continue, since untracked cache entries do not matter if there is no worktree. Ilia's patch is not yet queued in the excerpts.
