{"record":{"id":"ff9224c12becfef1","repo":"GitoxideLabs/gitoxide","slug":"git-add-for-resolved-paths-failed-with-stderr","errorCode":null,"errorMessage":"git add for resolved paths failed with {}: {stderr}","messagePattern":"git add for resolved paths failed with (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"gix-tix/src/lib.rs","lineNumber":5644,"sourceCode":"        .context(\"cannot resolve a conflict without a worktree\")?;\n    let mut command = Command::new(\"git\");\n    command\n        .arg(\"--literal-pathspecs\")\n        .arg(\"-C\")\n        .arg(workdir)\n        .args([\"add\", \"-A\", \"--\"]);\n    for path in &paths {\n        command.arg(gix::path::from_bstr(path.as_bstr()).as_ref());\n    }\n    let output = command\n        .output()\n        .context(\"could not launch git add for resolved paths\")?;\n    if !output.status.success() {\n        let stderr = output.stderr.trim().to_str_lossy();\n        if stderr.is_empty() {\n            anyhow::bail!(\"git add for resolved paths failed with {}\", output.status);\n        }\n        anyhow::bail!(\"git add for resolved paths failed with {}: {stderr}\", output.status);\n    }\n\n    let index = repository\n        .open_index()\n        .context(\"could not verify the resolved conflict index\")?;\n    if index\n        .entries()\n        .iter()\n        .any(|entry| entry.stage() != gix::index::entry::Stage::Unconflicted)\n    {\n        anyhow::bail!(\"the conflict index still has unresolved entries\");\n    }\n    Ok(())\n}\n\nfn preview_todo_rebase_conflict(\n    app: &mut App,\n    conflict: &edit::rebase::PlanConflict,","sourceCodeStart":5626,"sourceCodeEnd":5662,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/lib.rs#L5626-L5662","documentation":"Same as the bare variant: the external `git add` for resolved paths failed, but here stderr was non-empty and is appended to the message so the git CLI's own diagnostic is shown. It surfaces the underlying reason `git add` rejected the paths.","triggerScenarios":"Spawned `git add -- <resolved paths>` exits non-zero and prints a diagnostic, e.g. 'pathspec did not match any files', index.lock contention, or permission errors on the index.","commonSituations":"Resolved path no longer exists on disk when staging; concurrent git operation holding .git/index.lock; pathspec quoting issues with special characters in filenames.","solutions":["Read the stderr portion of the message and fix the underlying git add cause it names.","Remove a stale .git/index.lock if no git process is running.","Re-check that the resolved paths still exist before staging.","Run the identical `git add` command manually in the repo to reproduce and diagnose."],"exampleFix":"// before\nanyhow::bail!(\"git add for resolved paths failed with {}: {stderr}\", output.status);\n// after\nanyhow::bail!(\"git add for resolved paths failed with {}: {stderr}\", output.status)\n    .context(format!(\"paths: {:?}\", resolved_paths));","handlingStrategy":"try-catch","validationCode":"for p in &resolved_paths { if !p.exists() { bail!(\"path missing: {}\", p.display()); } }","typeGuard":null,"tryCatchPattern":"match stage_resolved_paths(repo, &paths) {\n    Err(err) => {\n        let msg = err.to_string();\n        if let Some(stderr) = msg.split(\"failed with \").nth(1) {\n            eprintln!(\"git said: {stderr}\");\n        }\n        return Err(err);\n    }\n}","preventionTips":["Confirm each resolved path still exists right before `git add`.","Avoid concurrent git processes touching the index.","Quote/escape paths with special characters when constructing the command."],"tags":["git","subprocess","staging","cli"],"backgroundTag":"git-command-failed","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}