Skip to main content

resolve_committish

Function resolve_committish 

Source
pub fn resolve_committish(repo: &Path, ref_name: &str) -> Result<String>
Expand description

Resolve a user-facing ref name to a concrete commit SHA the worktree/scan commands accept. A clone only materialises a local branch for the repository’s default branch; every other branch exists solely as a remote-tracking ref (refs/remotes/origin/<name>). Ref listing strips the origin/ prefix for display, so a bare branch name like “test” won’t resolve directly — we fall back to the remote-tracking form. Tags and raw SHAs resolve on the first candidate. Peeling with ^{commit} also dereferences annotated tags.

§Errors

Returns an error if none of the candidate spellings resolve to a commit.