gitbutlerapp/gitbutler · error
' ' resolved to more than one hunk ( )
Error message
'{raw_id}' resolved to more than one hunk ({}) What it means
This error is thrown when a user-supplied hunk CLI id (e.g. an id passed to a `but diff`/`but show` style command) resolves via `id_map.parse_using_context` to more than one hunk instead of exactly one. The id is therefore ambiguous in the current context (the same short id maps to multiple candidate hunks), and the code refuses to guess which one was meant.
Solutions
- Re-run the listing command (e.g. `but status`/hunk output) to see the current ids and use the full, unambiguous id
- Lengthen the id prefix so it matches exactly one hunk
- Re-check whether the intended hunk still exists; if the workspace changed, refresh context before retrying
Example fix
// before but diff abc // after but diff abc123f # use a longer id that resolves to a single hunk
Defensive patterns
Strategy: validation
Validate before calling
// resolve the id first and check cardinality before using it
let ids = id_map.parse_using_context(raw_id, ctx)?;
if ids.len() != 1 {
eprintln!("id '{raw_id}' is ambiguous ({} matches); use a longer id", ids.len());
return Ok(());
} Type guard
fn is_unambiguous(ids: &[CliId]) -> bool { ids.len() == 1 } Prevention
- Copy full ids rather than short prefixes when scripting
- Refresh `but status` output before reusing ids after rebase/edit operations
- Fail fast on ids that resolve to more than one hunk instead of picking one
When it happens
Trigger: Calling a but CLI command that takes a hunk id when `parse_using_context(raw_id, ctx)` returns a Vec with len > 1; typically a short/partial id prefix that matches several hunks in the resolution context.
Common situations: Typing an abbreviated hunk id that is a prefix of (or collides with) multiple hunk ids; referencing a hunk id after rebasing or editing commits so the id map contains multiple matches; using ids from stale output against a changed workspace.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- Aborting due to empty branch name
- Aborting due to empty
- --ai cannot be combined with a resolve subcommand. For one…
- Ambiguous branch ' ', matches multiple items
- Ambiguous branch ' ', matches multiple items
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/6b18661a05236d10.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/utils/diff_rendering.rs:1408
ctx: &'a Context,
id_map: &'a IdMap,
mut filter: F,
) -> anyhow::Result<Vec<(&'a str, Arc<CliId>, &'a UncommittedHunk)>>
where
F: FnMut(&UncommittedHunk) -> bool,
{
let mut uncommitted_hunks = id_map
.uncommitted_hunks
.iter()
.filter(move |(_, hunk)| filter(hunk))
.map(|(raw_id, hunk)| {
let mut cli_ids = id_map.parse_using_context(raw_id, ctx)?;
if cli_ids.len() == 1 {
Ok((&**raw_id, Arc::new(cli_ids.remove(0)), hunk))
} else if cli_ids.is_empty() {
bail!("'{raw_id}' no found")
} else {
bail!(
"'{raw_id}' resolved to more than one hunk ({})",
cli_ids.len()
)
}
})
.collect::<anyhow::Result<Vec<_>>>()?;
uncommitted_hunks.sort_by(|(id_a, _, hunk_a), (id_b, _, hunk_b)| {
(
&hunk_a.hunk.path,
hunk_a
.hunk
.hunk_header
.as_ref()
.map(|header| header.old_start),
id_a,
)
.cmp(&(View on GitHub (pinned to 58e5313667)