Documentation
¶
Overview ¶
Package watcher monitors Git-internal state files for changes and notifies the TUI to refresh. Unlike naive approaches that recursively watch the entire working tree, this package watches only the ~5 files/directories inside .git that change on meaningful Git operations. This makes it safe for monorepos with 100k+ files where inotify/kqueue watches would be exhausted instantly.
Watched paths:
- .git/index → staging changes (git add/reset)
- .git/HEAD → branch switches, commits
- .git/refs/heads → local branch updates
- .git/refs/tags → tag creation/deletion
- .git/refs/remotes → fetch/pull updates
- .git/MERGE_HEAD → merge starts/ends
- .git/REBASE_HEAD → rebase starts/ends
- .git/FETCH_HEAD → fetch completions
For working-tree changes (file edits), we rely on the user pressing 'r' (refresh) or on the debounced index-change event that git add/status triggers, which is the same strategy Lazygit uses.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Watch ¶
Watch monitors critical Git-internal paths at repoRoot for state changes and sends Event values on the returned channel. Rapid bursts are coalesced via the debounce window.
gitDir should be the absolute path to the .git directory (handles worktrees where .git is a file pointing elsewhere).
Call the returned stop function to tear down the watcher.