Files
sausage/userland/git/src/head.inc
T
surma 4b27e9afd5 userland/git: git-compatible CLI on v2's gix code (T10)
Local workflow, smart-HTTP clone/fetch/push and public HTTPS clone/fetch match
native git in stdout and exit codes. Only WASI imports (wasi:http, exit-with-code).
2026-11-06 16:07:57 +00:00

9 lines
405 B
C++

/// Read HEAD without mistaking an unborn branch for an I/O error.
fn head_info(repo: &gix::Repository) -> Result<HeadInfo> {
let head = repo.head().map_err(|e| error("HEAD", e))?;
Ok(HeadInfo { detached: head.is_detached(), unborn: head.is_unborn(),
branch: head.referent_name().map(|name| name.as_bstr().to_str_lossy().into_owned()),
id: head.id().map(|id| id.to_string()) })
}