gitbutlerapp/gitbutler · error

No commits were provided to squash

Error message

No commits were provided to squash

What it means

Squashing combines the changes of multiple commits into a target commit; it needs at least one source commit. `commit_squash_only_with_perm` checks the input list upfront and bails if empty, since a squash of zero commits has no meaningful outcome.

Solutions

  1. Populate `subject_commit_ids` with at least one commit ID before calling squash
  2. Guard the call site: if the list is empty, skip the operation and inform the user
  3. Verify the commit-selection query (e.g. UI state) is correctly populated before dispatching the action

Example fix

// before
let result = squash(ctx, target_id, selected, strategy, dry_run)?;
// after
anyhow::ensure!(!selected.is_empty(), "Select at least one commit to squash");
let result = squash(ctx, target_id, selected, strategy, dry_run)?;
Defensive patterns

Strategy: validation

Validate before calling

anyhow::ensure!(!subject_commit_ids.is_empty(), "select at least one commit to squash");

Try / catch

if let Err(e) = api.commit_squash_only(ctx, ids, target, strategy, dry_run) {
    if e.to_string().contains("No commits were provided") { show_empty_selection_hint(); }
    else { return Err(e); }
}

Prevention

When it happens

Trigger: Calling `commit_squash_only` / `commit_squash_with_perm` with an empty `subject_commit_ids` vector, e.g. when the UI sends no selected commits to squash into `target_commit_id`.

Common situations: User clicks 'squash' with no sibling commits selected; automated tooling computing the set of commits to squash via a query that returned nothing.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at crates/but-api/src/commit/squash.rs:54

        guard.write_permission(),
    )
}

/// Squash `subject_commit_ids` into `target_commit_id` under caller-held
/// exclusive repository access.
///
/// This variant does not create an oplog entry. When `dry_run` is enabled, it
/// returns a preview of the resulting workspace state without materializing the rebases.
pub fn commit_squash_only_with_perm(
    ctx: &mut but_ctx::Context,
    subject_commit_ids: Vec<gix::ObjectId>,
    target_commit_id: gix::ObjectId,
    how_to_combine_messages: MessageCombinationStrategy,
    dry_run: DryRun,
    perm: &mut RepoExclusive,
) -> anyhow::Result<CommitSquashResult> {
    if subject_commit_ids.is_empty() {
        anyhow::bail!("No commits were provided to squash")
    }
    let mut meta = ctx.meta()?;
    let (repo, mut ws, mut db) = ctx.workspace_mut_and_db_mut_with_perm(perm)?;
    let editor = Editor::create(&mut ws, &mut meta, &repo, &mut db)?;
    let SquashCommitsOutcome {
        rebase,
        commit_selector,
    } = but_workspace::commit::squash_commits(
        editor,
        subject_commit_ids,
        target_commit_id,
        how_to_combine_messages,
    )?;
    let new_commit = rebase.lookup_pick(commit_selector)?;
    let workspace = WorkspaceState::from_successful_rebase(rebase, &repo, dry_run)?;

    Ok(CommitSquashResult {
        new_commit,

View on GitHub (pinned to 58e5313667)