Skip to main content

Module vcs

Module vcs 

Source
Expand description

Version control for the environment snapshot: branch, head, upstream, how far ahead and behind, and what is dirty — from one git status --porcelain=v2 --branch.

One call, because this runs on every cd. The obvious implementation asks git seven times (rev-parse, symbolic-ref, rev-list --count, status, …) and pays seven process spawns for facts a single porcelain-v2 report already carries. crate::git keeps its own narrow calls for the index build, which asks different questions at a different moment; this is the one the hot path uses.

Nothing here writes: status is read-only, --no-optional-locks keeps it from taking the index lock to refresh stat information, so a snapshot taken while a rebase is in flight cannot interfere with it.

Structs§

GitWorkingTree
The state of one work tree, as porcelain v2 reports it.

Enums§

VcsState
What version control says about the checkout, or why it could not be asked.

Constants§

SOURCE
The command every fact in this module comes from. Named so that a snapshot’s provenance can quote what produced it rather than saying “git”.

Functions§

inspect
Ask git about root with one call. Never fails: a missing git, a directory that is not a work tree, or a report this cannot parse all become VcsState::Unavailable with the reason.
parse
Parse a git status --porcelain=v2 --branch -z report.