gitbutlerapp/gitbutler · error · anyhow::Error

committing stack assignments is not supported. Use `but comm

Error message

committing stack assignments is not supported. Use `but commit`

What it means

The legacy TUI commit flow explicitly rejects committing when the current selection is scoped to a stack assignment (scope_to_stack is Some). Stack assignments are only supported by the `but commit` command, so the TUI refuses at confirmation time and points the user to that command.

Source

Thrown at crates/but/src/command/legacy/status/tui/app/commit_mode.rs:515

    ctx: &mut Context,
    terminal_guard: &mut T,
    messages: &mut Vec<Message>,
    mode: &CommitMode,
    commit_op: commit::CommitOperation,
    stack_on_head: bool,
) -> anyhow::Result<()>
where
    T: TerminalGuard,
    anyhow::Error: From<<T::Backend as Backend>::Error>,
{
    let CommitMode {
        source,
        message_composer,
        insert_side: _,
        scope_to_stack,
    } = mode;

    anyhow::ensure!(
        scope_to_stack.is_none(),
        "committing stack assignments is not supported. Use `but commit`"
    );

    let commit_selection = match &**source {
        // Marks can span checkouts, so this is where that gets rejected.
        CommitSource::Marks(hunks) => commit::CommitSelection::Changes(Box::new(
            UncommittedSelection::new(hunks.clone()).map_err(CliError::into_internal)?,
        )),
        CommitSource::Uncommitted => commit::CommitSelection::AllChanges(ChangeSourceId::Head),
        CommitSource::Worktree(name) => {
            commit::CommitSelection::AllChanges(ChangeSourceId::Worktree(name.clone()))
        }
        CommitSource::UncommittedHunk(hunk) => commit::CommitSelection::Changes(Box::new(
            UncommittedSelection::new(NonEmpty::new(hunk.clone()))
                .map_err(CliError::into_internal)?,
        )),
    };

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Use `but commit` with the same stack selection instead of the TUI confirm
  2. Clear the stack scope: reselect plain hunks or uncommitted files, then confirm from the TUI
  3. Check `but status` to see what is currently scoped before committing

Example fix

# before: TUI commit confirm with a stack scope selected -> error
# after:
but commit <stack-id>
Defensive patterns

Strategy: validation

Validate before calling

if mode.scope_to_stack.is_some() {
    // do not enter TUI commit confirmation; route to `but commit <stack-id>`
    return route_to_but_commit(mode.scope_to_stack.unwrap());
}

Try / catch

anyhow::ensure!(scope_to_stack.is_none(), "committing stack assignments is not supported. Use `but commit`"); — enforce at commit-mode entry so the user learns the constraint before composing a message, not after.

Prevention

When it happens

Trigger: Confirming a commit in the TUI commit mode while a stack scope is active, e.g. after selecting a stack/worktree assignment and then hitting the commit confirmation key.

Common situations: Workflows that mix TUI hunk selection with stack assignments; older workflows where the TUI accepted stack-scoped commits before they were moved to `but commit`.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/7d2f707639a159e9. Report an issue: GitHub.