gitbutlerapp/gitbutler · error
commit ' ' is not part of the editable divergence
Error message
commit '{spec}' is not part of the editable divergence What it means
`resolve_commit` validates that every commit hash referenced in the script belongs to the set of editable commits derived from the integration divergence: local-only commits that are `NotIntegrated`, plus all upstream-only commits. This error is raised when no allowed commit's hex string starts with the given spec — the commit either does not exist, was already integrated, or the hash was mistyped. It surfaces wrapped as `line N: invalid pick/merge/squash commit: ...`.
Solutions
- Check the hash against the divergence listing shown in the UI; only listed commits are editable.
- Correct typos in the hash — specs are matched as hex string prefixes, so any wrong character makes it unresolvable.
- If the commit is a historically-integrated local commit, it cannot be picked; work with its upstream counterpart instead.
- Re-fetch the divergence (refresh the integration view) if the branch changed since the script was rendered, then update hashes.
Example fix
// before (script text — 9999999 is not in the divergence) pick 9999999 // after pick 3333333
Defensive patterns
Strategy: validation
Validate before calling
function validateCommitsExist(script: string, allowedShortIds: string[]): string[] {
const cmds = script.split('\n').filter(l => /^(pick|merge|squash)\b/.test(l.trim()));
return cmds.flatMap((line, i) => {
const [cmd, ...args] = line.split('|')[0].trim().split(/\s+/).filter(Boolean);
return args.filter(a => !allowedShortIds.some(id => id.startsWith(a)))
.map(a => `line ${i + 1}: commit '${a}' is not part of the editable divergence`);
});
} Type guard
const commitIsEditable = (spec: string, allowedShortIds: string[]): boolean => allowedShortIds.some(id => id.startsWith(spec));
Try / catch
try {
const steps = await parseIntegrationScript(script, divergence);
} catch (err) {
const m = /line (\d+): invalid \w+ commit: commit '([^']+)' is not part/.exec(String(err));
if (m) showEditorErrorAtLine(Number(m[1]), `commit ${m[2]} is not editable; pick from the divergence list`);
else throw err;
} Prevention
- Copy hashes only from the divergence listing rendered next to the script.
- Do not reuse scripts after the branch diverged further — refresh and re-render first.
- Remember historically-integrated local commits are excluded from the editable set.
When it happens
Trigger: Calling parse_integration_steps_script with a hash that matches no editable divergence commit: a nonexistent hash, a commit from another branch, a historically-integrated local commit (e.g. `pick 1111111` in the test fixture), or a full hash of a commit outside the divergence.
Common situations: The user copies a hash from `git log` of a different branch or from an older divergence listing after new commits changed the picture; or references a local commit that the target relation marks as already integrated and therefore not editable.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- commit prefix ' ' is ambiguous
- line : invalid merge commit
- line : invalid pick commit
- line : invalid squash commit
- Aborting due to empty branch name
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/72b2d380a7eef885.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-workspace/src/branch/integrate_branch_upstream/parsing.rs:159
.filter(|commit| {
matches!(
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)
}View on GitHub (pinned to 58e5313667)