Pure-Lua git repository reader for shell prompt integration.
Parses .git directory structures directly, avoiding the need
to spawn git processes. Provides prompt_status() which returns
the same status table shape used by the shell prompt git block.
| Name | Signature |
|---|---|
configure | configure(opts) |
find_git_dir | find_git_dir(start_path) -> git_dir, worktree |
prompt_status | prompt_status(start_path) -> status |
invalidate_prompt_cache | invalidate_prompt_cache() |
configure(
opts)
Configure the git module's cache sizes and skip thresholds
Updates internal configuration from a table of options. Valid keys:
max_prompt_cache — LRU size for prompt_status results (default: 3)
max_git_cache — LRU size for parsed git state objects (default: 5)
untracked_skip_threshold — skip untracked-file counting when the
working tree contains more files than this limit (default: 10000)
modified_skip_threshold — same for modified-file counting (default: 50000)
Unknown keys and type mismatches are silently ignored.
find_git_dir(
start_path) ->git_dir,worktree
Discover the .git directory by walking up from a starting path
Walks the directory tree upward from start_path (defaults to cwd)
looking for a .git directory or gitdir file (worktrees/submodules).
Returns the resolved git directory path and the worktree root,
or nil if not inside a git repository.
prompt_status(
start_path) ->status
Get git repository status for shell prompt display
Returns a table with fields: branch, remote_branch, tag,
staged, modified, untracked, ahead, behind, clean.
Returns nil if not inside a git repository.
Results are debounced (at most one full computation per second)
and internally cached by git-object mtimes. Call
invalidate_prompt_cache() to force a fresh computation on the
next call (e.g. after a command finishes).
invalidate_prompt_cache()
Clear the prompt_status debounce cache