Fix update-base error when branches are fully integrated#13574
Merged
Conversation
87f1b76 to
ff64944
Compare
Contributor
There was a problem hiding this comment.
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
HashSetusage 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, butoutput.referencesmay still include entries for heads you just archived (e.g. branches infor_archivalthat now have zero picks but still haveRebaseStep::Referencemarkers). Consider filteringoutput.referencesto only those refs that correspond tostack.headswhere!archived(or alternatively, only pre-archive the “missing from output” heads and keepfor_archivalarchival afterset_heads_from_rebase_output).
// Update the branch heads
if let Some(output) = rebase_output {
stack.set_heads_from_rebase_output(ctx, output.references.clone())?;
}
Caleb-T-Owens
approved these changes
Apr 30, 2026
ff64944 to
6589f72
Compare
Contributor
There was a problem hiding this comment.
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_headsvalidation 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. |
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.
d62b316 to
9ead27f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the error
The new head names do not match the current headsthat occurs when updating the workspace base after branches have been fully integrated upstream.Problem
set_all_headsvalidates 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
set_heads_from_rebase_outputThis ensures that by the time validation runs, fully-integrated branches are already marked as archived and excluded from the comparison.