Test integrate upstream with conflicting local branch#11897
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
1462eb2 to
5976a16
Compare
|
I asked claude to help me understand why the test is failing and got this reasonable response: After the merge integration, the commit graph looks like this: The merge commit has two parents:
What the graph traversal currently does: When building stack segments, the traversal follows all parents. So it sees: Segment 1: conflicting-branch → Merge Commit → commit C (following first parent) What it should do: For determining the stack structure (i.e., which branches belong to this stack), the traversal should only follow the first parent. The second parent represents the branch that was merged in, not a branch that's part of this stack. In other words: master (the target branch / upstream) should not be considered part of the conflicting-branch stack just because we merged it into conflicting-branch. The merge commit's second parent points to origin/master, but that's external to the stack - it's the upstream we integrated, not a branch we own. The fix should: When building a stack's segments, recognize that commits reachable only via the second (or later) parent of a merge commit, where those commits belong to the target branch, should be excluded from the stack's segment list. They are "merged-in history", not "stack history". |
9c3af3c to
47c3e8f
Compare
|
AI generated fix to added test also added as a second commit. |
Byron
left a comment
There was a problem hiding this comment.
Thanks for tackling this!
I only glimpsed at it and believe this one will take some time to review, a test in but-graph that shows the issue to solve, and a proper implementation of the fix.
Meanwhile, let's be sure this doesn't get merged -I will try to get to it properly soon.
Ofc, I only put this up to demonstrate the problem ✌️ |
Add a new integration test that simulates a remote change and a local conflicting commit to verify upstream integration behavior when conflicts exist. The test sets up a repo with commit A, a remote commit B, and a local conflicting commit C on a virtual branch, checks that the status reports the branch as Conflicted, runs integrate_upstream with a Merge resolution, and asserts the stack remains intact and contains the original branch after merge integration.
|
As getting into this could be a huge time-sink, I had to put it onto my backlog to be able to focus on unapply(). The only consolation I can give is that I let it jump the queue and put it first. |
47c3e8f to
401e3d9
Compare
|
No worries. I force pushed to this branch to remove that second commit, so this pr is now just adding a test that demonstrates the issue. |
The test integrate_upstream_with_conflicting_local_branch is located in crates/gitbutler-branch-actions/tests/virtual_branches/apply_virtual_branch.rs (line 558).
What it tests:
The test expresses your expectation that there should be only one branch in the stack after integration. The test is failing, which indicates there's a bug in the integration logic that's creating an extra "master" branch.