Skip to content

Fix update-base error when branches are fully integrated#13574

Merged
mtsgrd merged 1 commit intomasterfrom
new-heads-current-heads
Apr 30, 2026
Merged

Fix update-base error when branches are fully integrated#13574
mtsgrd merged 1 commit intomasterfrom
new-heads-current-heads

Conversation

@mtsgrd
Copy link
Copy Markdown
Contributor

@mtsgrd mtsgrd commented Apr 30, 2026

Summary

Fixes the error The new head names do not match the current heads that occurs when updating the workspace base after branches have been fully integrated upstream.

Problem

set_all_heads validates that the rebase output references match exactly the non-archived heads in a stack. When a branch is fully integrated, the rebaser prunes it from its output since there are no remaining commits. However, archival was happening after this validation, so the fully-integrated branch was still counted as a non-archived head — causing a mismatch between the head names and the rebase references.

Fix

  • Move branch archival to run before set_heads_from_rebase_output
  • Detect heads that are absent from the rebase output (i.e. branches already fully integrated with no remaining commits) and include them in the archival set

This ensures that by the time validation runs, fully-integrated branches are already marked as archived and excluded from the comparison.

@github-actions github-actions Bot added the rust Pull requests that update Rust code label Apr 30, 2026
@mtsgrd mtsgrd force-pushed the new-heads-current-heads branch from 87f1b76 to ff64944 Compare April 30, 2026 09:46
@mtsgrd mtsgrd marked this pull request as ready for review April 30, 2026 09:53
@mtsgrd mtsgrd requested review from Caleb-T-Owens and Copilot April 30, 2026 09:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a failure during “update base” when some stack heads are already fully integrated and therefore no longer show up in the rebase output, causing set_heads_from_rebase_output to reject the update due to a head/reference mismatch.

Changes:

  • Moves integrated-head archival earlier in the upstream integration update flow (before set_heads_from_rebase_output).
  • Expands the archival candidate set to also include non-archived stack heads that are absent from the rebase output references.
  • Introduces HashSet usage to efficiently detect which heads are missing from the rebase output.
Comments suppressed due to low confidence (1)

crates/gitbutler-branch-actions/src/upstream_integration.rs:675

  • Archiving heads before set_heads_from_rebase_output() can cause a new validation failure: set_all_heads() requires the rebase output’s reference names to match exactly the non-archived heads, but output.references may still include entries for heads you just archived (e.g. branches in for_archival that now have zero picks but still have RebaseStep::Reference markers). Consider filtering output.references to only those refs that correspond to stack.heads where !archived (or alternatively, only pre-archive the “missing from output” heads and keep for_archival archival after set_heads_from_rebase_output).
            // Update the branch heads
            if let Some(output) = rebase_output {
                stack.set_heads_from_rebase_output(ctx, output.references.clone())?;
            }

Comment thread crates/gitbutler-branch-actions/src/upstream_integration.rs Outdated
@mtsgrd mtsgrd force-pushed the new-heads-current-heads branch from ff64944 to 6589f72 Compare April 30, 2026 12:31
Copilot AI review requested due to automatic review settings April 30, 2026 14:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes upstream integration (integrate_upstream) failing with The new head names do not match the current heads when a stack contains branches that become fully integrated (and thus are pruned from rebase output).

Changes:

  • Archive integrated/pruned heads before applying rebase-output head updates during upstream integration.
  • Filter rebase output references to exclude archived heads so set_all_heads validation sees a consistent active-head set.
  • Add a regression test covering a stack with a fully integrated branch that should be archived instead of causing a validation error.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
crates/gitbutler-branch-actions/src/upstream_integration.rs Archives integrated heads earlier and filters rebase references to avoid head-name mismatches during validation.
crates/gitbutler-branch-actions/tests/branch-actions/virtual_branches/apply_virtual_branch.rs Adds a regression test reproducing the fully-integrated-branch scenario and asserting successful integration + archival.

Comment thread crates/gitbutler-branch-actions/src/upstream_integration.rs
When a branch in a stack is fully integrated upstream, the rebaser
drops it from its output since there are no remaining commits. However,
`set_heads_from_rebase_output` calls `set_all_heads`, which validates
that rebase references match exactly the non-archived heads — causing
the error "The new head names do not match the current heads".

Fix this by archiving integrated heads before calling
`set_heads_from_rebase_output`, and filtering the rebase output
references to exclude archived heads so the validation sees a
consistent set.

Add a regression test that reproduces the exact scenario: a stack with
an integrated branch and a non-integrated branch, verifying that
`integrate_upstream` succeeds and the integrated branch is archived.
@mtsgrd mtsgrd force-pushed the new-heads-current-heads branch from d62b316 to 9ead27f Compare April 30, 2026 16:36
@mtsgrd mtsgrd merged commit 4206ae4 into master Apr 30, 2026
36 checks passed
@mtsgrd mtsgrd deleted the new-heads-current-heads branch April 30, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants