{"record":{"id":"46936165c04d6baa","repo":"gitbutlerapp/gitbutler","slug":"cannot-compute-diff-specs-for-branch","errorCode":null,"errorMessage":"Cannot compute diff specs for branch `{}`","messagePattern":"Cannot compute diff specs for branch `(.+?)`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/utils/diff_specs.rs","lineNumber":72,"sourceCode":"            CliId::UncommittedHunkOrFile(uncommitted) => {\n                self.push_changes_from_uncommitted(uncommitted)\n            }\n            CliId::PathPrefix {\n                id: _,\n                hunks,\n                source: _,\n            } => self.push_changes_from_path_prefix(hunks),\n            CliId::CommittedFile {\n                committed_file:\n                    CommittedFileId {\n                        commit_id,\n                        path,\n                        change_id: _,\n                    },\n                id: _,\n            } => self.push_changes_from_committed_file(*commit_id, path.as_ref()),\n            CliId::Branch(branch) => {\n                anyhow::bail!(\"Cannot compute diff specs for branch `{}`\", branch.name)\n            }\n            CliId::AnonymousSegment(segment) => {\n                anyhow::bail!(\"{}\", anonymous_segment_error(&segment.id))\n            }\n            CliId::Commit {\n                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}`\")","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/utils/diff_specs.rs#L54-L90","documentation":"The diff-specs builder can only expand ids that map to concrete changes (commits, files, hunks, uncommitted area). A `CliId::Branch` refers to a whole branch reference, which has no single diff, so `push_changes_from_id` bails out rather than guessing a base for the comparison.","triggerScenarios":"Passing a branch CLI id (e.g. from `but status` output like `main` or a stack branch name) to an operation that builds diff specs via `push_changes_from_id`.","commonSituations":"User supplies a branch name where a commit/hunk/file id is expected, e.g. `but <op> main`; scripting against `but` output and picking a branch id by mistake.","solutions":["Pass the id of a commit, hunk, file, or the uncommitted changes instead of the branch id","List the branch's commits first (e.g. via `but log`) and use one of those ids","If a branch-wide diff is intended, use the command/flag designed for branch comparisons"],"exampleFix":"// before\nbut <op> main        # branch id -> error\n// after\nbut <op> abc123f     # use a commit id from the branch instead","handlingStrategy":"validation","validationCode":"// ensure the id is not a branch id before invoking the operation\nif let CliId::Branch(b) = &id {\n    eprintln!(\"{} is a branch; pass a commit/file/hunk id instead\", b.name);\n    return Ok(());\n}","typeGuard":"fn is_branch(id: &CliId) -> bool { matches!(id, CliId::Branch(_)) }","tryCatchPattern":"match result { Err(e) if e.to_string().contains(\"Cannot compute diff specs for branch\") => { /* prompt for a commit id */ }, Err(e) => return Err(e), Ok(v) => v }","preventionTips":["Only pass commit/file/hunk/uncommitted ids to diff-spec-backed commands","Inspect `but status` output to distinguish branch ids from change ids","Script against machine-readable output and filter by id kind"],"tags":["cli","unsupported-input","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"}