{"record":{"id":"130b9bbd50131fba","repo":"nikivdev/code","slug":"git-failed-130b9b","errorCode":null,"errorMessage":"git {} failed: {}","messagePattern":"git (.+?) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/jj.rs","lineNumber":3404,"sourceCode":"        .current_dir(repo_root)\n        .args(args)\n        .output()\n        .with_context(|| format!(\"failed to run jj {}\", args.join(\" \")))?;\n    if !output.status.success() {\n        bail!(\"jj {} failed\", args.join(\" \"));\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).to_string())\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        let stderr = String::from_utf8_lossy(&output.stderr);\n        bail!(\"git {} failed: {}\", args.join(\" \"), stderr.trim());\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).to_string())\n}\n\nfn jj_read_in(repo_root: &Path, args: &[&str]) -> Result<String> {\n    let output = Command::new(\"jj\")\n        .current_dir(repo_root)\n        .args([\"--at-op=@\", \"--ignore-working-copy\"])\n        .args(args)\n        .output()\n        .with_context(|| format!(\"failed to run jj {}\", args.join(\" \")))?;\n    if !output.status.success() {\n        let stderr = String::from_utf8_lossy(&output.stderr);\n        bail!(\"jj {} failed: {}\", args.join(\" \"), stderr.trim());\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).to_string())\n}\n","sourceCodeStart":3386,"sourceCodeEnd":3422,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/jj.rs#L3386-L3422","documentation":"git_capture_in runs a git command and captures stdout; on failure it bails with 'git <args> failed: <stderr>', appending git's trimmed stderr so the root cause is visible. Used by helpers that read git state from the colocated repo.","triggerScenarios":"Any git invocation via git_capture_in (e.g. rev-parse, status plumbing, for-each-ref) exits non-zero — run outside a git repo, unknown ref/object, or corrupted index.","commonSituations":"Running the tool outside a git/jj colocated repo; referencing a branch deleted on the remote; git hooks or fsck issues corrupting operations.","solutions":["Read the appended stderr to identify the failing git operation and fix that cause.","Confirm you are inside the repo: `git rev-parse --git-dir` succeeds from the working directory.","If the repo is mid-operation or corrupt, run `f git-repair` or `git status` to diagnose."],"exampleFix":"// before\nflow fetch  # git for-each-ref fails on bad refspec\n// after\ngit rev-parse --git-dir   # verify repo\nf git-repair              # if mid-operation\nflow fetch","handlingStrategy":"try-catch","validationCode":"// shell\ngit rev-parse --git-dir >/dev/null 2>&1 || { echo \"not inside a git repo\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"match flow_command() {\n  Err(e) if e.starts_with(\"git \") && e.contains(\"failed: \") => {\n    let stderr = e.split(\"failed: \").nth(1).unwrap_or(\"\");\n    eprintln(\"git failed: {stderr}\");\n    Err(e)\n  }\n  other => other,\n}","preventionTips":["Run flow commands from inside the repo working tree.","Keep git installed and on PATH; check `git --version` in CI images.","Resolve interrupted git operations before running flow."],"tags":["git","process-exit","subprocess","capture"],"backgroundTag":"subprocess-nonzero-exit","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}