{"record":{"id":"dd632354ffc35575","repo":"GitoxideLabs/gitoxide","slug":"a-tree-change-cannot-be-amended-from-the-worktree","errorCode":null,"errorMessage":"a tree change cannot be amended from the worktree","messagePattern":"a tree change cannot be amended from the worktree","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/head.rs","lineNumber":217,"sourceCode":"    index: &gix::index::File,\n) -> Result<ObjectId> {\n    match change.group {\n        crate::ChangeGroup::Staged => {\n            let index_tree = create::index_tree(repo, index)?;\n            apply_path_from_tree(repo, commit_tree, index_tree, change)\n        }\n        crate::ChangeGroup::Unstaged => {\n            let baseline = repo.find_tree(commit_tree)?;\n            create::worktree_tree_with_changes(\n                repo,\n                &baseline,\n                &crate::Changes {\n                    paths: vec![change.clone()],\n                    ..crate::Changes::default()\n                },\n            )\n        }\n        crate::ChangeGroup::Tree => anyhow::bail!(\"a tree change cannot be amended from the worktree\"),\n    }\n}\n\nfn apply_path_from_tree(\n    repo: &gix::Repository,\n    commit_tree: ObjectId,\n    source_tree: ObjectId,\n    change: &PathChange,\n) -> Result<ObjectId> {\n    let mut editor = repo.find_tree(commit_tree)?.edit()?;\n    if change.kind == ChangeKind::Renamed\n        && let Some(source) = &change.source\n    {\n        editor.remove(source)?;\n    }\n    if change.kind == ChangeKind::Deleted {\n        editor.remove(&change.path)?;\n    } else {","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/head.rs#L199-L235","documentation":"During an amend, `amend_path_tree` can apply a single path change taken from the index or the worktree, but a `ChangeGroup::Tree` change is a whole-tree (submodule/tree-entry) change that cannot be reproduced by rebuilding trees from worktree state. The library intentionally refuses rather than silently producing a wrong tree. Callers must re-run the operation without amending, or handle tree changes separately.","triggerScenarios":"Calling the tix amend path so that `perform_inner` dispatches `amend_path_tree` with a `PathChange` whose `group` is `crate::ChangeGroup::Tree` — i.e. the selected change is a tree (e.g. submodule pointer) change rather than a staged or unstaged file change.","commonSituations":"Amending a commit that changed a submodule pointer or other gitlink/tree entry; selecting a tree-type entry in the interactive change list and asking tix to fold it into the head commit.","solutions":["Amend only file (blob) changes; leave tree changes such as submodule pointer updates to a new commit or to `git submodule update`.","Update the submodule to a recorded state so the change stops appearing as a tree change, then retry the amend.","If support for amending tree changes is desired, implement it via tree editors (apply_path_from_tree) instead of the worktree path."],"exampleFix":"// before: selecting a submodule change and amending\ntix amend  # ChangeGroup::Tree -> bail\n\n// after: stage only file changes, or commit the submodule bump separately\nlet changes: Vec<_> = changes.into_iter().filter(|c| c.group != ChangeGroup::Tree).collect();","handlingStrategy":"validation","validationCode":"// Rust: check the change group before amending\nif change.group == crate::ChangeGroup::Tree {\n    eprintln!(\"skip amend: tree change {:?}\", change.path);\n} else {\n    amend(repo, change)?;\n}","typeGuard":"fn is_amendable(change: &PathChange) -> bool {\n    matches!(change.group, crate::ChangeGroup::Staged | crate::ChangeGroup::Unstaged)\n}","tryCatchPattern":null,"preventionTips":["Filter the change list to blob/file changes before invoking amend.","Handle submodule pointer updates through `git submodule` workflows, not worktree amends."],"tags":["git","worktree","submodule","amend","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}