Skip to main content

Module git

Module git 

Source
Expand description

fs.git_status: what git says about the entries of a listed folder, for the Files pane’s markers (modified, untracked, ignored…) and its status line (branch, ahead/behind).

Running git inside a folder the user merely browsed must not run code the folder chose. A repository’s own config can name programs that git status executes: core.fsmonitor, and a filter.<name>.clean (or .process) applied through its .gitattributes whenever a file’s stat data differs from the index. Command-line -c settings win over every config file, so the fsmonitor is turned off and every filter the repository itself defines is blanked; the user’s own system and global filters (Git LFS) are left alone. Submodules, which have configs of their own, are not entered. The status never writes the index (--no-optional-locks), prompts for nothing, and is killed after a few seconds on a huge repository.

Spec: docs/specs/SPEC_FILE_BROWSER_PANE_2026_10_01.md §12 (Phase 2, git decorations).

Structs§

GitRecord
One path git reported, relative to the repository’s top.
Porcelain
What git status --porcelain=v2 -z --branch printed.

Enums§

GitError 🔒
StatusError 🔒
Why safe_status_porcelain gave no status.

Constants§

GIT_TIMEOUT 🔒
A status that takes longer than this is abandoned: the pane shows no markers rather than waiting.
SAFE_CONFIG 🔒
Settings forced on every git run here, ahead of any config file.

Functions§

filter_names
Filter names from git config [--show-scope] --name-only --get-regexp ^filter\. output; with scopes, only those outside system and global.
git_status
fs.git_status for raw (a folder the pane listed).
parse_porcelain_v2
Parse porcelain v2 output (-z: NUL-terminated records; a rename’s original path follows it as its own NUL-terminated field).
repo_filters 🔒
The names of the filters a repository’s own config defines (its .git/config, worktree config, and what they include): every filter.<name>.* key whose scope isn’t the user’s system or global config. An older git without --show-scope gets every filter blanked. Err when the config couldn’t be read: the caller must not run git status then. Only --get-regexp’s exit 1 (“no match”) means none.
run_git 🔒
Run git in dir with the safe settings; its stdout, or a sentence.
safe_git_line 🔒
Run a read-only git command (rev-parse, remote get-url) in dir with the same safe settings and timeout as the status above: its trimmed stdout, or None on any failure.
safe_status_porcelain 🔒
git status --porcelain=v2 -z --branch --untracked-files=normal --ignore-submodules=all <extra> in dir, with the repository’s own filters blanked (see module docs). Shared by the Files pane and the agents’ work facts (backend::work_facts).
state_of_xy 🔒
The state an ordinary (1) or rename/copy (2) record’s XY code means: the most pressing of the staged (X) and unstaged (Y) changes.
summarize
Fold the records under prefix (the listed folder, relative to the repository’s top, /-separated with a trailing /, or empty) into one state per direct child. A folder takes the most pressing state of what’s inside it, except that a folder is only “ignored” when git ignores the folder itself.