{"record":{"id":"6adf169f0980be7a","repo":"nikivdev/code","slug":"git-failed-6adf16","errorCode":null,"errorMessage":"git {} failed: {}","messagePattern":"git (.+?) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sync.rs","lineNumber":5135,"sourceCode":"    let output = Command::new(\"git\")\n        .current_dir(repo_root)\n        .args(args)\n        .output()\n        .context(\"failed to run git\")?;\n\n    if output.status.success() {\n        return Ok(());\n    }\n\n    let stdout = String::from_utf8_lossy(&output.stdout);\n    let stderr = String::from_utf8_lossy(&output.stderr);\n    let detail = format!(\"{}\\n{}\", stdout.trim(), stderr.trim())\n        .trim()\n        .to_string();\n    if detail.is_empty() {\n        bail!(\"git {} failed\", args.join(\" \"));\n    }\n    bail!(\"git {} failed: {}\", args.join(\" \"), detail);\n}\n\nfn restore_stash_result(\n    repo_root: &Path,\n    auto_stash_state: &AutoStashState,\n    allow_autofix: bool,\n) -> Result<()> {\n    restore_stash_result_with_packet_dir(repo_root, auto_stash_state, allow_autofix, None)\n}\n\nfn restore_stash_result_with_packet_dir(\n    repo_root: &Path,\n    auto_stash_state: &AutoStashState,\n    allow_autofix: bool,\n    packet_dir_override: Option<&Path>,\n) -> Result<()> {\n    if !auto_stash_state.stashed {\n        return Ok(());","sourceCodeStart":5117,"sourceCodeEnd":5153,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/sync.rs#L5117-L5153","documentation":"Raised by a git helper in src/sync.rs when a git command fails and stderr/stdout produced a non-empty diagnostic. The message is `git <args> failed: <detail>` where detail is the trimmed combined stdout and stderr, giving the developer the actual git error text. This is the detail-bearing variant of the git failure error (918).","triggerScenarios":"A git invocation in the sync flow exits non-zero with at least one non-empty stdout/stderr line; that line becomes `detail` in the error message.","commonSituations":"Merge conflicts, missing refs/branches, detached or dirty state blocking operations, authentication failures on fetch/push, or bad arguments constructed by sync code.","solutions":["Read the embedded `detail` text to identify the exact git error","Run the failing `git <args>` command manually for full context","Fix the underlying git issue (resolve conflicts, fetch missing refs, fix credentials) and retry the sync","Check repo state with `git status` before re-running the sync"],"exampleFix":"// before: failing state, e.g. missing remote ref\n$ git fetch origin nonexistent-branch\n// error: git fetch origin nonexistent-branch failed: fatal: ...\n// after: use an existing ref\n$ git fetch origin main","handlingStrategy":"try-catch","validationCode":"// preflight: clean, connected repo reduces git failures\nlet st = std::process::Command::new(\"git\").args([\"status\", \"--porcelain\"]).output()?;\nif !String::from_utf8_lossy(&st.stdout).is_empty() {\n    eprintln!(\"Working tree dirty; commit or stash before sync\");\n}\nlet remote = std::process::Command::new(\"git\").args([\"remote\"]).output()?;\nif String::from_utf8_lossy(&remote.stdout).is_empty() {\n    eprintln!(\"No git remote configured; fetch/pull-based sync will fail\");\n}","typeGuard":null,"tryCatchPattern":"match sync_result {\n    Err(e) if e.to_string().contains(\"failed: \") && e.to_string().starts_with(\"git \") => {\n        // detail after 'failed: ' is git's own stderr/stdout\n        eprintln!(\"{e}\");\n    }\n    other => other?,\n}","preventionTips":["Read the embedded detail line first; it usually names the exact git problem","Ensure remotes and credentials are configured before syncing","Keep the working tree clean to avoid operation refusals","Run the failing git command manually for full diagnostics"],"tags":["git","command-failure","stderr","sync"],"backgroundTag":"git-command-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}