gitbutlerapp/gitbutler · error
Cannot compute diff specs for branch
Error message
Cannot compute diff specs for branch `{}` What it means
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.
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
Example fix
// before but <op> main # branch id -> error // after but <op> abc123f # use a commit id from the branch instead
Defensive patterns
Strategy: validation
Validate before calling
// ensure the id is not a branch id before invoking the operation
if let CliId::Branch(b) = &id {
eprintln!("{} is a branch; pass a commit/file/hunk id instead", b.name);
return Ok(());
} Type guard
fn is_branch(id: &CliId) -> bool { matches!(id, CliId::Branch(_)) } Try / catch
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 } Prevention
- 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
When it happens
Trigger: 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`.
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cannot compute diff specs for committed hunks
- Cannot compute diff specs for stacks
- Cannot compute diff specs for worktree
- {}
- No diffs to show.
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/46936165c04d6baa.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/utils/diff_specs.rs:72
CliId::UncommittedHunkOrFile(uncommitted) => {
self.push_changes_from_uncommitted(uncommitted)
}
CliId::PathPrefix {
id: _,
hunks,
source: _,
} => self.push_changes_from_path_prefix(hunks),
CliId::CommittedFile {
committed_file:
CommittedFileId {
commit_id,
path,
change_id: _,
},
id: _,
} => self.push_changes_from_committed_file(*commit_id, path.as_ref()),
CliId::Branch(branch) => {
anyhow::bail!("Cannot compute diff specs for branch `{}`", branch.name)
}
CliId::AnonymousSegment(segment) => {
anyhow::bail!("{}", anonymous_segment_error(&segment.id))
}
CliId::Commit {
commit:
CommitId {
commit_id,
change_id: _,
},
id: _,
} => self.push_changes_from_commit(*commit_id),
CliId::Uncommitted { id: _ } => self.push_changes_from_uncommitted_area(),
// A worktree's uncommitted area is expanded into its files during
// resolution, so the builder only ever sees hunks that already come from
// its own repo. The reference holds no changes at all.
CliId::Worktree { name, .. } | CliId::WorktreeUncommitted { name, .. } => {
anyhow::bail!("Cannot compute diff specs for worktree `{name}`")View on GitHub (pinned to 58e5313667)