Skip to main content

repo_presence

Function repo_presence 

Source
async fn repo_presence(cwd: &Path) -> RepoPresence
Expand description

Ask whether cwd sits inside a git repo with rev-parse --git-dir, whose exit status answers repo-existence alone: zero inside any work tree including one with no commits, non-zero outside one and for a path that does not exist. Matching git’s fatal: prose would not work here even setting version drift aside - a deleted .git/HEAD and a plain non-repo emit the same line.

A non-zero exit is then refined by whether .git is on disk: a pruned worktree entry, a deleted HEAD and a corrupt gitfile all exit 128 with .git still present, and each is a fault to report rather than an absent repo. Undeterminable biases to Unusable, so a broken checkout is never silently suppressed.

Not routed through run_git: a non-zero exit is the answer here rather than a fault, so it must neither be logged as a failure nor collapsed with “git would not run”, which the caller has already logged with git’s stderr.