nikivdev/code · error
git {} failed: {}
Error message
git {} failed: {} What it means
Error "git {} failed: {}" thrown in nikivdev/code.
Source
Thrown at src/changes.rs:92
let root = String::from_utf8_lossy(&output.stdout).trim().to_string();
if root.is_empty() {
bail!("Unable to resolve git root.");
}
trace(&format!("repo root: {}", root));
Ok(PathBuf::from(root))
}
fn git_output_in(repo_root: &Path, args: &[&str]) -> Result<(String, bool)> {
let output = Command::new("git")
.current_dir(repo_root)
.args(args)
.output()
.with_context(|| format!("failed to run git {}", args.join(" ")))?;
let stdout = String::from_utf8_lossy(&output.stdout).to_string();
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
let ok = output.status.success();
if !ok && stdout.is_empty() {
bail!("git {} failed: {}", args.join(" "), stderr.trim());
}
Ok((stdout, ok))
}
fn git_ref_exists(repo_root: &Path, reference: &str) -> Result<bool> {
let full_ref = format!("{}^{{commit}}", reference);
let output = Command::new("git")
.current_dir(repo_root)
.args(["rev-parse", "--verify", &full_ref])
.output()
.with_context(|| format!("failed to verify git ref {}", reference))?;
Ok(output.status.success())
}
fn resolve_base_ref(repo_root: &Path) -> Result<String> {
let candidates = ["main", "origin/main", "master", "origin/master"];
for candidate in candidates {
if git_ref_exists(repo_root, candidate)? {View on GitHub (pinned to a747e741ae)
When it happens
Trigger: Thrown at src/changes.rs:92 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/1ef69ea16b6911b7.
Report an issue: GitHub.