Skip to main content

resolve_ref_to_commit

Function resolve_ref_to_commit 

Source
pub fn resolve_ref_to_commit(repo_path: &Path, git_ref: &str) -> Result<String>
Expand description

Resolves a git ref (commit, branch, tag) to its full commit SHA.

Equivalent to git -C <repo> rev-parse <ref>^{commit}. Used by diff callers to short-circuit when both refs resolve to the same commit (the worktree-build + graph-build pipeline is expensive on large repositories — HEAD HEAD against a kernel-scale tree blew the 90s CLI / 120s MCP deadlines before this helper was wired in).

§Errors

Returns GitError::NotFound if git is not in PATH, GitError::CommandFailed if the ref cannot be resolved (unknown ref, or a tag that does not point at a commit), and GitError::InvalidOutput if git returned non-UTF-8 or empty stdout.