{"record":{"id":"190886d8339bdfcc","repo":"nikivdev/code","slug":"git-failed-190886","errorCode":null,"errorMessage":"git {} failed","messagePattern":"git (.+?) failed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/repos.rs","lineNumber":1520,"sourceCode":"fn git_ref_exists_in(repo_root: &Path, reference: &str) -> bool {\n    Command::new(\"git\")\n        .current_dir(repo_root)\n        .args([\"rev-parse\", \"--verify\", reference])\n        .stdout(Stdio::null())\n        .stderr(Stdio::null())\n        .status()\n        .map(|status| status.success())\n        .unwrap_or(false)\n}\n\nfn git_capture_in(repo_root: &Path, args: &[&str]) -> Result<String> {\n    let output = Command::new(\"git\")\n        .current_dir(repo_root)\n        .args(args)\n        .output()\n        .with_context(|| format!(\"failed to run git {}\", args.join(\" \")))?;\n    if !output.status.success() {\n        bail!(\"git {} failed\", args.join(\" \"));\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())\n}\n\nfn git_config_get(repo_root: &Path, key: &str) -> Option<String> {\n    git_capture_in(repo_root, &[\"config\", \"--get\", key])\n        .ok()\n        .map(|value| value.trim().to_string())\n        .filter(|value| !value.is_empty())\n}\n\nfn git_run_in(repo_root: &Path, args: &[&str], quiet: bool) -> Result<()> {\n    let mut command = Command::new(\"git\");\n    command\n        .current_dir(repo_root)\n        .args(args)\n        .stdin(Stdio::inherit());\n    if quiet {","sourceCodeStart":1502,"sourceCodeEnd":1538,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/repos.rs#L1502-L1538","documentation":"This error is raised by git_capture_in when a spawned git command (run in a given repo root, capturing stdout) exits with a non-zero status. It means the git subcommand itself failed — e.g. bad arguments, not a git repository, or the queried key/config does not resolve. The message intentionally omits git's stderr because output is captured and not inherited.","triggerScenarios":"Calling git_capture_in (or helpers like git_config_get) with args such as [\"config\",\"--get\",key] when the key is unset, running outside a valid repo (bad repo_root), or passing a subcommand/flag combination the installed git rejects.","commonSituations":"Querying git config for a key that was never set; repo_root pointing at a non-repo directory (e.g. after a failed clone); older git versions lacking a flag the code passes; detached/empty repos where commands like branch --show-current fail.","solutions":["Run the same git command manually inside repo_root and read git's stderr to see the real failure","Verify repo_root is a git repository (check for .git or run git rev-parse --is-inside-work-tree)","Check that the queried key/config actually exists (git config --get <key>) before treating absence as a bug","Confirm the installed git version supports the flags being passed"],"exampleFix":"// before\nlet url = git_config_get(repo_root, \"remote.origin.url\").ok_or_else(|| anyhow!(\"no remote\"))?;\n// after\nlet url = match git_config_get(repo_root, \"remote.origin.url\") {\n    Some(u) => u,\n    None => bail!(\"remote.origin.url is not set in {}\", repo_root.display()),\n};","handlingStrategy":"try-catch","validationCode":"fn ensure_git_repo(root: &Path) -> anyhow::Result<()> {\n    anyhow::ensure!(root.join(\".git\").exists(), \"{} is not a git repository\", root.display());\n    Ok(())\n}","typeGuard":"fn is_git_repo(root: &Path) -> bool {\n    root.join(\".git\").exists()\n}","tryCatchPattern":"match git_config_get(repo_root, \"remote.origin.url\") {\n    Some(url) => url,\n    None => { eprintln!(\"git config failed in {}\", repo_root.display()); fallback() }\n}","preventionTips":["Check the directory is a git repo before invoking git helpers","Treat Option-returning helpers like git_config_get as fallible for absent keys","Pin/verify the git version your flags depend on","Inspect git's stderr by running the command manually when the bare message appears"],"tags":["git","process-exit","cli"],"backgroundTag":"git-command-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}