gitbutlerapp/gitbutler · error

no commit IDs provided for uncommit

Error message

no commit IDs provided for uncommit

What it means

Uncommitting extracts the changes of given commits back into the workspace; it requires at least one commit ID. `commit_uncommit_only_with_perm` validates the input list and bails immediately if empty, avoiding a no-op rebase of the stack.

Solutions

  1. Pass at least one commit ID in `subject_commit_ids`
  2. Validate the selection before calling the API and show a user-facing message when empty
  3. Check the code deriving commit IDs (parsing, filtering) to ensure it yields non-empty output

Example fix

// before
uncommit(ctx, Vec::new(), assign_to, dry_run)?;
// after
ensure!(!ids.is_empty(), "No commits selected to uncommit");
uncommit(ctx, ids, assign_to, dry_run)?;
Defensive patterns

Strategy: validation

Validate before calling

if ids.is_empty() { eprintln!("select a commit to uncommit"); return Ok(()); }

Try / catch

match api.commit_uncommit_only(ctx, ids, assign_to, dry_run) {
    Err(e) if e.to_string().contains("no commit IDs provided for uncommit") => prompt_selection(),
    other => other?,
}

Prevention

When it happens

Trigger: Calling `commit_uncommit_only` / `commit_uncommit_with_perm` with an empty `subject_commit_ids` vector, optionally with an `assign_to` stack ID but no commits.

Common situations: User invokes 'uncommit' from the UI with no commit selected; a script parses commit IDs from output that matched nothing; duplicated IDs collapse to an empty set upstream.

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/079dcfc5c7071b42. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-api/src/commit/uncommit.rs:206

///
/// The commits are removed from branch history, but their changes are
/// **kept** — they surface as uncommitted workspace modifications. When
/// `assign_to` is set, newly surfaced hunks are assigned to that stack.
///
/// This contrasts with [`super::discard_commit::commit_discard()`], which
/// removes both the commit and its changes.
///
/// When `dry_run` is enabled, it returns a preview of the resulting workspace
/// state without materializing the rewrite.
pub fn commit_uncommit_only_with_perm(
    ctx: &mut but_ctx::Context,
    subject_commit_ids: Vec<gix::ObjectId>,
    assign_to: Option<but_core::ref_metadata::StackId>,
    dry_run: DryRun,
    perm: &mut RepoExclusive,
) -> anyhow::Result<UncommitResult> {
    if subject_commit_ids.is_empty() {
        anyhow::bail!("no commit IDs provided for uncommit");
    }
    let context_lines = ctx.settings.context_lines;
    let mut meta = ctx.meta()?;
    let (repo, mut ws, mut db) = ctx.workspace_mut_and_db_mut_with_perm(perm)?;

    let surfaced =
        SurfacedHunks::record_before(assign_to, dry_run, &mut db, &repo, &ws, context_lines)?;

    let editor = Editor::create(&mut ws, &mut meta, &repo, &mut db)?;

    let mut rebase =
        but_workspace::commit::discard_commits(editor, subject_commit_ids.iter().copied())
            .with_context(|| {
                format!(
                    "failed to uncommit commits: {}",
                    subject_commit_ids
                        .iter()
                        .map(|id| id.to_hex().to_string())

View on GitHub (pinned to 58e5313667)