gitbutlerapp/gitbutler · error

Cannot reorder ' ' in single-branch mode without branch…

Error message

Cannot reorder '{subject_branch_name}' in single-branch mode without branch order metadata

What it means

Reordering refs in single-branch mode persists a branch order in ref metadata. If the metadata backend reports can_persist_branch_stack_order() == false, the reordering cannot be recorded and the operation is refused, because without persisted order the projected segment order would be indeterminate.

Solutions

  1. Use a RefMetadata implementation that supports persisting branch stack order
  2. Enable/update metadata storage for the repository before reordering
  3. Choose a reorder target that does not require a graph update, or skip reordering
Defensive patterns

Strategy: validation

Validate before calling

let (_repo, meta) = rebase.repo_and_meta_mut();
if !meta.can_persist_branch_stack_order() {
    // reordering not possible with this metadata backend
}

Try / catch

match move_branch(editor, subject, target) {
    Err(e) if e.to_string().contains("without branch order metadata") => use_persistent_metadata_backend(),
    other => other?,
}

Prevention

When it happens

Trigger: Calling move_branch() in single-branch mode where move_requires_graph_update triggers an order-based reorder, but the active RefMetadata implementation cannot persist branch_stack_order (e.g. no metadata storage, read-only meta, or unsupported backend).

Common situations: Workspaces stored on filesystems/backends without branch-order metadata; metadata objects constructed without persistence enabled; repos migrated from older formats lacking the order chain.

Related errors


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

Appendix: source

Thrown at crates/but-workspace/src/branch/move_branch.rs:255

        let (source_stack, subject_segment) = &source;
        let (destination_stack, _) = &destination;
        let entrypoint = workspace.ref_name().map(ToOwned::to_owned);
        // A branch that owns commits can only be reordered within its current stack in
        // single-branch mode. Moving it across stacks would change commit ownership and needs a
        // real rebase.
        if !subject_segment.commits.is_empty() && !same_stack(source_stack, destination_stack) {
            bail!("Moving a non-empty branch in single-branch mode is not yet supported");
        }
        // Reordering same-target empty refs only changes which empty segment is displayed first.
        // If their targets differ, however, the subject crosses commit-owning segments and its ref
        // must move with it or those commits would be projected as belonging to the empty branch.
        let move_requires_graph_update = !subject_segment.commits.is_empty()
            || successful_rebase.reference_target(subject_branch_name)?
                != successful_rebase.reference_target(target_branch_name)?;
        let existing_order = {
            let (_repo, meta) = successful_rebase.repo_and_meta_mut();
            if !meta.can_persist_branch_stack_order() {
                bail!(
                    "Cannot reorder '{subject_branch_name}' in single-branch mode without branch order metadata"
                );
            }
            // Reorder against the existing chain. A movable subject is always part of `branch_order`
            // (that's what makes it a projected segment), so the first lookup normally succeeds. The
            // target and entrypoint lookups are defensive fallbacks so that, should the projection ever
            // surface a segment that isn't tracked yet, we extend the real chain instead of clobbering
            // it down to just the moved refs.
            match meta.branch_stack_order(subject_branch_name)? {
                Some(order) => order,
                None => match meta.branch_stack_order(target_branch_name)? {
                    Some(order) => order,
                    None => entrypoint
                        .as_ref()
                        .map(|entrypoint| meta.branch_stack_order(entrypoint.as_ref()))
                        .transpose()?
                        .flatten()
                        .unwrap_or_else(|| stack_branch_order(source_stack)),

View on GitHub (pinned to 58e5313667)