gitbutlerapp/gitbutler · error · anyhow::Error

Refusing to land `{branch}` with --whole-stack: it is not th

Error message

Refusing to land `{branch}` with --whole-stack: it is not the top of its stack — unnamed segment(s) with commits sit above it (their branch refs no longer exist), so landing `{branch}` would not land the entire stack.

What it means

Error "Refusing to land `{branch}` with --whole-stack: it is not the top of its stack — unnamed segment(s) with commits sit above it (their branch refs no longer exist), so landing `{branch}` would not land the entire stack." thrown in gitbutlerapp/gitbutler.

Source

Thrown at crates/but-api/src/land/mod.rs:416

    ctx: &mut Context,
    branch: &str,
    target_display: &str,
    whole_stack: bool,
) -> anyhow::Result<Vec<String>> {
    let Some(scan) = scan_stack(ctx, branch)? else {
        return Ok(Vec::new());
    };

    if whole_stack && scan.has_upper {
        // Judge "top of the stack" by position, not by names: a segment whose branch ref was
        // deleted still holds commits that "land the entire stack" would have to include.
        if let Some(top) = scan.upper_segments.first() {
            bail!(
                "Refusing to land `{branch}` with --whole-stack: it is not the top of its stack. \
                 --whole-stack lands the entire stack; name its top segment `{top}` instead.",
            );
        }
        bail!(
            "Refusing to land `{branch}` with --whole-stack: it is not the top of its stack — \
             unnamed segment(s) with commits sit above it (their branch refs no longer exist), so \
             landing `{branch}` would not land the entire stack.",
        );
    }
    // Key off the commits below, not the segment names: segments whose branch ref was deleted are
    // unnamed but their commits would be published all the same.
    let publishes_below = scan.commits_below > 0 || !scan.lower_segments.is_empty();
    if publishes_below && !whole_stack {
        if scan.lower_segments.is_empty() {
            bail!(
                "Refusing to land `{branch}`: {} commit(s) on unnamed segment(s) below it would \
                 also be published to {target_display}. Pass --whole-stack to land `{branch}` \
                 together with everything below it.",
                scan.commits_below,
            );
        }
        bail!(

View on GitHub (pinned to caf1f223d3)

When it happens

Trigger: Thrown at crates/but-api/src/land/mod.rs:416 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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