gitbutlerapp/gitbutler · error
line : invalid squash commit
Error message
line {line_number}: invalid squash commit '{commit}': {err} What it means
Thrown while parsing an edited integration script when one of the two-or-more commits on a 'squash' line cannot be resolved against the allowed candidate commits. Each argument on a squash line is resolved individually, and the failing token is named in the message.
Solutions
- Correct the offending commit token (named in the error) to an unambiguous hash of an allowed commit.
- Re-copy all hashes on the line from the originally rendered script.
- Remove the bad commit from the squash line or split the line if the commit is not needed.
- Validate each hash against editable_candidate_commits before saving the edited script.
Example fix
// before squash 1a2b3c4 1a2b3c // second hash ambiguous // after squash 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b 0f1e2d3c4b5a6978879685949382917060594837
Defensive patterns
Strategy: validation
Validate before calling
// validate every commit token on squash lines before saving
fn valid_squash(line: &str, allowed: &HashSet<String>) -> bool {
line.split_whitespace()
.skip(1)
.all(|tok| tok == "|" || tok.starts_with('"')
|| allowed.iter().any(|c| c.starts_with(tok) && tok.len() >= 4))
} Try / catch
match parse_integration_steps_script(&edited, &divergence) {
Err(e) if e.to_string().contains("invalid squash commit") => {
// the message names the bad token; reopen the editor highlighting it
reopen_editor_with_error_note(&e.to_string())?;
}
other => other?,
} Prevention
- Edit squash lines by duplicating existing hashes rather than typing new ones.
- Use full hashes for every commit in a squash line.
- Verify each added commit belongs to the editable candidate set.
- Parse-validate the script immediately after each edit.
When it happens
Trigger: parse_integration_steps_script encountering a 'squash <c1> <c2> ...' line where any single argument fails resolve_commit (unknown, ambiguous, or not an allowed candidate commit).
Common situations: Hand-editing a squash line and dropping a character from a hash; adding a new commit to a squash line by typing its short hash from memory; referencing commits outside the current divergence's editable set.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- line : invalid merge commit
- line : invalid pick commit
- commit ' ' is not part of the editable divergence
- Integration steps cannot be empty
- line : invalid squash message
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/4cd4a5ee0b1eacc3.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-workspace/src/branch/integrate_branch_upstream/parsing.rs:85
let commit = arguments
.first()
.copied()
.expect("validated merge arity above");
InteractiveIntegrationStep::Merge {
commit_id: resolve_commit(commit, &allowed_commits).map_err(|err| {
anyhow::anyhow!("line {line_number}: invalid merge commit: {err}")
})?,
}
}
"squash" => {
if arguments.len() < 2 {
bail!("line {line_number}: squash requires at least two commits");
}
let commits = arguments
.iter()
.map(|commit| {
resolve_commit(commit, &allowed_commits).map_err(|err| {
anyhow::anyhow!(
"line {line_number}: invalid squash commit '{commit}': {err}"
)
})
})
.collect::<Result<Vec<_>>>()?;
InteractiveIntegrationStep::Squash {
commits,
message: message_part
.map(parse_message_clause)
.transpose()
.map_err(|err| {
anyhow::anyhow!("line {line_number}: invalid squash message: {err}")
})?,
}
}
other => bail!("line {line_number}: unknown command '{other}'"),
};
steps.push(step);View on GitHub (pinned to 58e5313667)