gitbutlerapp/gitbutler · error

line : invalid merge commit

Error message

line {line_number}: invalid merge commit: {err}

What it means

Thrown while parsing an edited interactive integration script when a 'merge' line names a commit that cannot be resolved against the allowed candidate commits. Like the pick case, resolve_commit must map the token unambiguously to one of the commits eligible for integration.

Solutions

  1. Fix the merge line's commit argument to an unambiguous hash of an allowed candidate commit.
  2. Copy the exact hash from the original rendered script instead of retyping it.
  3. Delete the invalid merge line if the merge is not wanted.
  4. Pre-validate the edited script with parse_integration_steps_script before accepting the editor buffer.

Example fix

// before
merge 9f2c   // ambiguous
// after
merge 9f2c8d41e5b34f0a9c1d2e3f4a5b6c7d8e9f0a1b  // full hash from rendered script
Defensive patterns

Strategy: validation

Validate before calling

// validate merge lines before saving the edited script
fn valid_merge(line: &str, allowed: &HashSet<String>) -> bool {
    let tok = line.split_whitespace().nth(1).unwrap_or("");
    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 merge commit") => {
        reopen_editor_with_error_note(&e.to_string())?;
    }
    other => other?,
}

Prevention

When it happens

Trigger: parse_integration_steps_script encountering a line 'merge <commit>' where resolve_commit fails: unknown or ambiguous hash, or a hash that is not among the editable candidate commits of the divergence.

Common situations: Hand-editing the integration todo and mangling a hash; using an abbreviation that matches multiple candidates; referencing an upstream commit that is not part of the current integration candidate set; pasting merge lines from another todo file.

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


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/2c0ab4e88b8e0f1d. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-workspace/src/branch/integrate_branch_upstream/parsing.rs:73

                    commit_id: resolve_commit(commit, &allowed_commits).map_err(|err| {
                        anyhow::anyhow!("line {line_number}: invalid pick commit: {err}")
                    })?,
                }
            }
            "merge" => {
                if message_part.is_some() {
                    bail!("line {line_number}: merge does not accept a message clause");
                }
                if arguments.len() != 1 {
                    bail!("line {line_number}: merge requires exactly one commit");
                }
                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 {

View on GitHub (pinned to 58e5313667)