gitbutlerapp/gitbutler · warning

Selection aborted

Error message

Selection aborted

What it means

handle_no_branch_specified throws 'Selection aborted' when the interactive branch multi-select (shown when no branch is given to `but push`) is cancelled or returns no selection. It is the expected abort path for the prompt, not an internal failure.

Solutions

  1. Re-run `but push` and select at least one branch
  2. Specify branches explicitly: `but push branch-a`
  3. For scripting, always pass branch names to avoid the interactive prompt entirely

Example fix

// before
but push  # interactive selection aborted
// after
but push my-branch  # explicit, no prompt
Defensive patterns

Strategy: try-catch

Validate before calling

// pass branches explicitly so no interactive prompt appears
if (!branchArgs.length) {
  throw new Error('Specify branches to push');
}
await runBut(['push', ...branchArgs]);

Type guard

function selectionMade<T>(sel: T[] | null): sel is T[] {
  return Array.isArray(sel) && sel.length > 0;
}

Try / catch

try {
  await runBut(['push']);
} catch (e) {
  if (/Selection aborted/.test(e.message)) {
    console.warn('Push cancelled: no branches selected');
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `but push` without arguments, then pressing Esc/Ctrl+C or confirming an empty selection at the 'Which branch(es) would you like to push?' prompt.

Common situations: Users backing out of an accidental push, terminal issues making the multi-select unusable, or automation invoking push without args in a non-TTY environment.

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

Appendix: source

Thrown at crates/but/src/command/legacy/push.rs:926

            (label, candidate.branch_name.clone())
        })
        .collect::<Vec<_>>();
    let options = nonempty::NonEmpty::from_vec(options).context("No branches available to push")?;
    let mut input = out
        .prepare_for_terminal_input()
        .context("Human input required - run this in a terminal")?;

    // Preselect everything so plain Enter pushes all candidates; the picker
    // starts empty otherwise, making Enter a silent no-op.
    let selected_branches = input
        .prompt_multi_select_with_help(
            "Which branch(es) would you like to push?",
            &options,
            (0..options.len()).collect(),
            Vec::new(),
            |_| None,
        )?
        .ok_or_else(|| anyhow::anyhow!("Selection aborted"))?
        .into_iter()
        .cloned()
        .collect::<Vec<_>>();

    if selected_branches.is_empty() {
        Ok(BranchSelection::None)
    } else {
        Ok(BranchSelection::Selected(selected_branches))
    }
}

/// A branch worth offering for push: the topmost branch with unpushed commits
/// in its stack. Pushing a branch always pushes its stack ancestors too, so
/// lower branches of the same stack are folded into one candidate instead of
/// being offered (and pushed) separately.
struct PushCandidate {
    branch_name: String,
    /// Unpushed commits across this branch and its ancestors.

View on GitHub (pinned to 58e5313667)