GitoxideLabs/gitoxide · error · anyhow::Error
git add for resolved paths failed with
Error message
git add for resolved paths failed with {} What it means
An external `git add` invocation used to stage conflict-resolved paths exited with a non-zero status, and its stderr was empty, so only the exit status is reported. This relies on the git CLI as a subprocess to stage resolutions; failure means staging did not happen.
Solutions
- Re-run with the captured ExitStatus inspected (`git add` manually on the same paths) to see the real cause.
- Check that `git` in PATH is a compatible version and the repository index is writable.
- Check for hooks or global config (core.hooksPath) interfering with `git add`.
- Verify disk space and index.lock absence (.git/index.lock stale file).
Defensive patterns
Strategy: try-catch
Validate before calling
let ok = std::process::Command::new("git").arg("--version").output().map(|o| o.status.success()).unwrap_or(false);
let index_writable = !repo_git_dir.join("index.lock").exists(); Try / catch
match stage_resolved_paths(repo, &paths) {
Err(err) if err.to_string().starts_with("git add for resolved paths failed") => {
eprintln!("git add failed; run it manually to diagnose");
}
other => other?,
} Prevention
- Verify a compatible git binary is in PATH before spawning.
- Check for .git/index.lock before staging.
- Capture and log stderr and exit status for every git subprocess.
When it happens
Trigger: Running the resolve/stage flow where the spawned `git add -- <paths>` process fails without writing anything to stderr (e.g. git not behaving, fatal error swallowed, signal).
Common situations: Mismatched git version in PATH; read-only index; git config hooks (pre-add hooks) failing silently; disk-full conditions producing no stderr output.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- git add for resolved paths failed with
- Cannot run without any task to perform on the repositories
- At least one operation failed
- No commits to process
- Refusing to checkout index into existing directory
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/0e3cad5e88653a1c.
Report an issue: GitHub.
Appendix: source
Thrown at gix-tix/src/lib.rs:5642
let workdir = repository
.workdir()
.context("cannot resolve a conflict without a worktree")?;
let mut command = Command::new("git");
command
.arg("--literal-pathspecs")
.arg("-C")
.arg(workdir)
.args(["add", "-A", "--"]);
for path in &paths {
command.arg(gix::path::from_bstr(path.as_bstr()).as_ref());
}
let output = command
.output()
.context("could not launch git add for resolved paths")?;
if !output.status.success() {
let stderr = output.stderr.trim().to_str_lossy();
if stderr.is_empty() {
anyhow::bail!("git add for resolved paths failed with {}", output.status);
}
anyhow::bail!("git add for resolved paths failed with {}: {stderr}", output.status);
}
let index = repository
.open_index()
.context("could not verify the resolved conflict index")?;
if index
.entries()
.iter()
.any(|entry| entry.stage() != gix::index::entry::Stage::Unconflicted)
{
anyhow::bail!("the conflict index still has unresolved entries");
}
Ok(())
}
fn preview_todo_rebase_conflict(View on GitHub (pinned to e73179060b)