Ray's Knowledge Base
Unlock

rgit TUI watcher never refreshed on .git changes because libgit2 ignores .git paths

PitfallVerified 13 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

The rgit TUI does not refresh after a commit, stage or unstage made outside it, for example rgit commit in another terminal.

Cause#

spawn_watcher in crates/rgit-tui/src/runtime.rs kept .git/index, .git/HEAD and .git/refs/* events, then sent them to backend.paths_ignored. That calls libgit2 is_path_ignored. libgit2 has .git in its default ignore rules (GIT_IGNORE_DEFAULT_RULES), so it returns true for every path under .git. These events never sent Msg::AutoRefresh.

Fix#

Sort each debounced event in a pure function (sort_watch_paths). Git state (.git/index, .git/HEAD, .git/packed-refs, anything under .git/refs/) sends Msg::AutoRefresh with no ignore check. Other .git paths are dropped. Worktree paths keep the batched paths_ignored check. Never run libgit2 ignore checks on paths under .git. Cover the sorting with watch_git_state* unit tests that need no watcher.

Evidence#

Fixed on branch fix/tui-git-refresh (change CHG-4m59st, task TSK-5hybeb). The 4 watch_git_state tests pass and rvow prove TSK-5hybeb proved the task.