gitbutlerapp/gitbutler · error
commit prefix ' ' is ambiguous
Error message
commit prefix '{spec}' is ambiguous What it means
Commit specs in the integration script are resolved by hex-prefix matching against the editable divergence commits. If the given prefix matches two or more commits, resolution is impossible and this error is raised rather than guessing. It surfaces wrapped as `line N: invalid pick/merge/squash commit: commit prefix '<spec>' is ambiguous`.
Solutions
- Lengthen the hash until it is unique — the rendered script uses 7-character short ids; use at least that many, or the full 40-char hash.
- Copy the exact short id from the rendered script rather than typing an abbreviation by hand.
- Use the full commit hash, which the parser explicitly accepts (`accepts_full_hashes`).
Example fix
// before (script text — 'abcdef' matches two commits) pick abcdef // after pick abcdef0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Defensive patterns
Strategy: validation
Validate before calling
function validateUnambiguous(script: string, allowedIds: string[]): string[] {
return script.split('\n').flatMap((line, i) => {
const [cmd, ...args] = line.split('|')[0].trim().split(/\s+/).filter(Boolean);
if (!['pick', 'merge', 'squash'].includes(cmd)) return [];
return args
.filter(a => allowedIds.filter(id => id.startsWith(a)).length > 1)
.map(a => `line ${i + 1}: commit prefix '${a}' is ambiguous`);
});
} Type guard
const prefixIsUnique = (spec: string, allowedIds: string[]): boolean => allowedIds.filter(id => id.startsWith(spec)).length === 1;
Try / catch
try {
const steps = await parseIntegrationScript(script, divergence);
} catch (err) {
const m = /line (\d+): invalid \w+ commit: commit prefix '([^']+)' is ambiguous/.exec(String(err));
if (m) showEditorErrorAtLine(Number(m[1]), `lengthen hash '${m[2]}' to make it unique`);
else throw err;
} Prevention
- Use at least 7 hex characters, matching the rendered short-id length.
- Copy-paste short ids from the rendered script instead of typing abbreviations.
- Full 40-character hashes are always unambiguous and accepted.
When it happens
Trigger: Calling parse_integration_steps_script with an abbreviated hash that is a prefix of multiple allowed commit ids — e.g. `pick abcdef` when both `abcdef0aaa...` and `abcdef1aaa...` are in the divergence.
Common situations: Users type very short hashes (4–6 chars) while a divergence contains many nearby commits, or scripts written against one divergence state are reused after upstream changes introduced new commits sharing a prefix.
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
- commit ' ' is not part of the editable divergence
- Failed to parse branch_ref_bytes
- Found multiple matches for
- line : invalid merge commit
- line : invalid pick commit
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/e7c53bc0f648c92b.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-workspace/src/branch/integrate_branch_upstream/parsing.rs:161
commit.target_relation,
IntegrationDivergenceTargetRelation::NotIntegrated
)
})
.map(|commit| commit.id)
.chain(divergence.upstream_only.iter().map(|commit| commit.id))
.collect()
}
fn resolve_commit(spec: &str, allowed_commits: &HashSet<gix::ObjectId>) -> Result<gix::ObjectId> {
let matches = allowed_commits
.iter()
.copied()
.filter(|commit_id| commit_id.to_string().starts_with(spec))
.collect::<Vec<_>>();
match matches.as_slice() {
[] => bail!("commit '{spec}' is not part of the editable divergence"),
[commit_id] => Ok(*commit_id),
_ => bail!("commit prefix '{spec}' is ambiguous"),
}
}
fn split_message_clause(line: &str) -> Result<(&str, Option<&str>)> {
let Some((command_part, message_part)) = line.split_once('|') else {
return Ok((line, None));
};
Ok((command_part.trim_end(), Some(message_part.trim_start())))
}
fn parse_message_clause(clause: &str) -> Result<String> {
let value = clause
.strip_prefix("message=")
.context("expected `message=` after `|`")?;
parse_quoted_string(value)
}
fn parse_quoted_string(input: &str) -> Result<String> {View on GitHub (pinned to 58e5313667)