{"record":{"id":"31c59c565538b01c","repo":"GitoxideLabs/gitoxide","slug":"amending-requires-exactly-one-selected-path","errorCode":null,"errorMessage":"amending requires exactly one selected path","messagePattern":"amending requires exactly one selected path","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/head.rs","lineNumber":89,"sourceCode":"        .context(\"could not find HEAD commit\")?\n        .decode()\n        .context(\"could not decode HEAD commit\")?\n        .into_owned()\n        .context(\"could not own HEAD commit\")?;\n    repo.workdir().context(\"editing HEAD requires a worktree\")?;\n    repo.commit_signing_options_if_enabled()\n        .context(\"could not resolve commit signing configuration\")?;\n    repo = repo.with_object_memory();\n    let old_tree = commit.tree;\n    let pending = rebase::is_pending(&commit);\n    let review = super::review::is_review(&commit);\n    let parent_tree = match commit.parents.first().copied() {\n        Some(parent) => repo.find_commit(parent)?.tree_id()?.detach(),\n        None => repo.empty_tree().id,\n    };\n    let selected_amend_path = match (kind, selected_paths) {\n        (Kind::Amend, Some(([path], _))) => Some(path),\n        (Kind::Amend, Some(_)) => anyhow::bail!(\"amending requires exactly one selected path\"),\n        _ => None,\n    };\n    let tree = match kind {\n        Kind::Spill => match selected_paths {\n            Some((paths, selected_parent)) => {\n                spill_paths_tree(&repo, old_tree, selected_parent.unwrap_or(parent_tree), paths)?\n            }\n            None => parent_tree,\n        },\n        Kind::Amend => {\n            let index = repo.index_or_empty().context(\"could not load the index\")?;\n            if index\n                .entries()\n                .iter()\n                .any(|entry| entry.stage() != gix::index::entry::Stage::Unconflicted)\n            {\n                anyhow::bail!(\"cannot amend with unresolved index conflicts\");\n            }","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/head.rs#L71-L107","documentation":"Amending the head commit via `perform_inner` accepts exactly one selected path; if `Kind::Amend` is combined with a `selected_paths` list containing any number of paths other than one, the operation is rejected. This enforces that amend-with-paths is a single-path operation in tix.","triggerScenarios":"Calling `perform`/`perform_with_changes`/`perform_reporting`/`amend_index`/`amend_index_reporting` with `kind == Kind::Amend` and `selected_paths = Some((paths, _))` where `paths.len() != 1` (zero or multiple paths).","commonSituations":"Selecting several changed paths in the UI/script and issuing an amend; passing an empty selection with amend; CLI plumbing that forwards the wrong selection kind.","solutions":["Select exactly one path when amending, or drop the path selection to amend the whole staged tree.","Use the spill operation (`Kind::Spill`) if the intent is to move multiple paths.","Perform multiple amend operations, one per path, if each path must be folded separately."],"exampleFix":"// before (two paths selected)\nhead::perform(&repo, Kind::Amend, Some((&[path_a, path_b], group)), ...)?;\n// after\nhead::perform(&repo, Kind::Amend, Some((&[path_a], group)), ...)?;","handlingStrategy":"validation","validationCode":"if kind == Kind::Amend {\n    match selected_paths {\n        Some((paths, _)) if paths.len() != 1 => {\n            anyhow::bail!(\"amend takes exactly one selected path (got {})\", paths.len());\n        }\n        _ => {}\n    }\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"amending requires exactly one selected path\") => {\n        eprintln!(\"select a single path, or use spill for multiple paths\");\n    }\n    other => other?,\n}","preventionTips":["Enforce single-path selection in UI/scripts that drive amend.","Use `Kind::Spill` when multiple paths need to move.","Write a thin wrapper around perform() that validates kind/path-count invariants."],"tags":["git","cli","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}