gitbutlerapp/gitbutler · error

cannot currently handle more than 1 parent

Error message

cannot currently handle more than 1 parent

What it means

create_commit supports at most one parent commit unless the destination is an amend operation, which legitimately inherits a commit's parents. Creating a new commit with more than one parent (a merge) is not implemented, so the function bails to avoid silently dropping merge semantics.

Solutions

  1. Amend the merge commit instead (Destination::AmendCommit), which supports multi-parent
  2. Create the new commit without inheriting the merge parents, or rebase the workspace to remove the merge first
  3. Wait for/ask for merge-commit support in create_commit; do not work around by crafting raw git commits inconsistently with workspace state

Example fix

// before
but.create_commit(Destination::NewCommit { parent_commit_id: Some(merge_commit) }, ...); // bails
// after
but.create_commit(Destination::AmendCommit { commit_id: merge_commit }, ...);
Defensive patterns

Strategy: validation

Validate before calling

let parents = commit.parent_ids().count();
if parents > 1 && !matches!(destination, Destination::AmendCommit { .. }) {
    // use amend or avoid the merge commit as parent
}

Type guard

fn supports_destination(destination: &Destination, parent_count: usize) -> bool {
    parent_count <= 1 || matches!(destination, Destination::AmendCommit { .. })
}

Try / catch

match result {
    Err(e) if e.to_string().contains("more than 1 parent") => {
        // fall back to Destination::AmendCommit on the merge commit
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling create_commit with Destination::NewCommit (or a non-Amend destination) when the reference commit has 2+ parents — i.e. attempting to create a child of a merge commit.

Common situations: Building commits on top of merge commits in the workspace; automation that naively uses HEAD (a merge commit) as the parent; operations triggered while the workspace head is a merge.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at crates/but-workspace/src/commit_engine/mod.rs:148

        Destination::NewCommit {
            parent_commit_id: None,
            ..
        } => Vec::new(),
        Destination::NewCommit {
            parent_commit_id: Some(parent),
            ..
        } => vec![*parent],
        Destination::AmendCommit { commit_id, .. } => commit_id
            .attach(repo)
            .object()?
            .peel_to_commit()?
            .parent_ids()
            .map(|id| id.detach())
            .collect(),
    };

    if !matches!(destination, Destination::AmendCommit { .. }) && parents.len() > 1 {
        bail!("cannot currently handle more than 1 parent")
    }

    let target_tree = match &destination {
        Destination::NewCommit {
            parent_commit_id: None,
            ..
        } => gix::ObjectId::empty_tree(repo.object_hash()),
        Destination::NewCommit {
            parent_commit_id: Some(base_commit),
            ..
        }
        | Destination::AmendCommit {
            commit_id: base_commit,
            ..
        } => but_core::Commit::from_id(base_commit.attach(repo))?
            .tree_id_or_auto_resolution()?
            .detach(),
    };

View on GitHub (pinned to 58e5313667)