test(GB-1294): reproduce branch replace bug with test case#13912
Draft
slarse wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Rust CLI test in the but crate intended to capture/regress GB-1294, where creating a new branch anchored on a branch shared by multiple applied stacks can incorrectly affect projections in other stacks.
Changes:
- Introduces a new integration test that sets up two stacks sharing branch
A. - Exercises
but branch new -a <anchor> <new-branch>with an anchor (h0) that exists in one stack’s projection. - Asserts the resulting
but statusoutput matches the intended “only mutate the targeted stack” behavior.
Comment on lines
+69
to
+73
| fn handles_adding_branch_anchored_on_branch_shared_by_other_stack() -> anyhow::Result<()> { | ||
| let env = Sandbox::init_scenario_with_target_and_default_settings("one-stack")?; | ||
| env.setup_metadata(&["A"])?; | ||
|
|
||
| env.but("branch new -a A first-stack").assert().success(); |
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.
Adds a test case to reproduce GB-1294.
The the problem appears when you have multiple stacks that share a branch applied at the same time, and you try to create a new branch anchored to the branch in one of those stacks.
I'm not entirely sure what semantics we even want to have here. @Caleb-T-Owens do you have any ideas? Before I dive further into this I think we should establish if this behavior is even supposed to be supported. But I think it feels sane to be able to have multiple stacks with a common base.
Example
For example, you may have this state:
And then you'd want to add a new branch
first-stack-middleanchored ath0.I would expect the result to be that the branch is added to only one of the stacks, or possibly to both, but what actually happens is that
Ais replaced in the projection in both stacks.Funky variation
If you instead unapply e.g.
second-stackand create a new branch anchored atA, then the branch is correctly inserted in the middle offirst-stack. Applyingsecond-stackafterwards leads to this (to me, expected) state:But if you then add a commit to
first-stack-middle, then that branch and commit gets inserted intosecond-stackas well.