std.git — Lilush API

←index

← std

Overview

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.

Functions

NameSignature
configureconfigure(opts)
find_git_dirfind_git_dir(start_path) -> git_dir, worktree
prompt_statusprompt_status(start_path) -> status
invalidate_prompt_cacheinvalidate_prompt_cache()

configure(opts)

Configure the git module's cache sizes and skip thresholds

Updates internal configuration from a table of options. Valid keys:

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