{"record":{"id":"cdd2daaae5c80163","repo":"gitbutlerapp/gitbutler","slug":"cannot-compute-diff-specs-for-committed-hunks","errorCode":null,"errorMessage":"Cannot compute diff specs for committed hunks","messagePattern":"Cannot compute diff specs for committed hunks","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/utils/diff_specs.rs","lineNumber":96,"sourceCode":"                commit:\n                    CommitId {\n                        commit_id,\n                        change_id: _,\n                    },\n                id: _,\n            } => self.push_changes_from_commit(*commit_id),\n            CliId::Uncommitted { id: _ } => self.push_changes_from_uncommitted_area(),\n            // A worktree's uncommitted area is expanded into its files during\n            // resolution, so the builder only ever sees hunks that already come from\n            // its own repo. The reference holds no changes at all.\n            CliId::Worktree { name, .. } | CliId::WorktreeUncommitted { name, .. } => {\n                anyhow::bail!(\"Cannot compute diff specs for worktree `{name}`\")\n            }\n            CliId::Stack { .. } => {\n                anyhow::bail!(\"Cannot compute diff specs for stacks\")\n            }\n            CliId::CommittedHunk(_) => {\n                anyhow::bail!(\"Cannot compute diff specs for committed hunks\")\n            }\n        }\n    }\n\n    pub fn push_changes_from_uncommitted(\n        &mut self,\n        uncommitted: &UncommittedHunkOrFile,\n    ) -> anyhow::Result<()> {\n        // Specs are built against one checkout's repository, so a hunk from\n        // another would silently address the wrong files. Operations that support\n        // worktree sources validate the selection and construct the builder via\n        // [`Self::for_change_source`]; the rest read the main worktree and refuse\n        // worktree hunks here.\n        if uncommitted.source != self.source {\n            if let Some(name) = uncommitted.source.worktree_name() {\n                anyhow::bail!(\"Cannot operate on uncommitted changes in worktree {name} yet\");\n            }\n            anyhow::bail!(","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/utils/diff_specs.rs#L78-L114","documentation":"Unsupported-kind guard in push_changes_from_id: a committed-hunk CliId was passed. Hunks from commits are not addressable as diff-spec sources — the builder only handles commits, uncommitted areas, and worktree/file-level IDs — so the caller must reference the commit or file instead of a committed hunk.","triggerScenarios":"Passing a committed-hunk id to a command that resolves ids through `push_changes_from_id`; the operation does not support diffing individual hunks already committed.","commonSituations":"Copying a hunk id from `but show`/log output of a committed change and using it with a command that only accepts whole commits, files, or uncommitted hunks.","solutions":["Use the commit id or file path containing the hunk instead of the committed-hunk id","If partial staging of a committed hunk is intended, use a command that explicitly supports committed-hunk operations","Re-check `but status` output: uncommitted hunk ids may be what the command actually accepts"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if matches!(id, CliId::CommittedHunk(_)) {\n    eprintln!(\"committed hunk ids are not accepted here; use the commit or file id\");\n    return Ok(());\n}","typeGuard":"fn is_committed_hunk(id: &CliId) -> bool { matches!(id, CliId::CommittedHunk(_)) }","tryCatchPattern":"if let Err(e) = cmd() { if e.to_string().contains(\"committed hunks\") { /* retry with parent commit id */ } else { return Err(e); } }","preventionTips":["Use commit or file ids for already-committed changes","Only use hunk ids for uncommitted changes unless the command documents hunk support","Check the command's accepted id kinds before scripting"],"tags":["cli","committed-hunk","diff"],"backgroundTag":"unsupported-operation","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}