Repository navigation
fix(server): refreshing a merge request worktree keeps other branches' upstreams - #47593
Conversation
…ktree refresh Co-authored-by: Claude Opus 5.5 <[email protected]>
…' upstreams Configure the head upstream on the branch found for the worktree instead of re-reading whichever branch the checkout holds at that moment. Co-authored-by: Claude Opus 5.5 <[email protected]>
ApprovabilityVerdict: Would Approve Macroscope's review found this PR approvable — Worktree preparation now configures the intended request branch’s upstream instead of whichever branch happens to be checked out. Existing fetch and refresh safeguards remain unchanged, with no obvious material risk requiring human judgment. Needs human approval because:
Notes:
You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…ests Replace the PATH-shim scenario with a GitManager unit test that pauses after the reused worktree's upstream read and switches its branch, which fails on main and passes with the fix. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Dismissing prior approval to re-evaluate df439d7
EvidenceReal web app, Chromium 156 on Linux, 1280×800, light theme for every capture. Fresh per-commit databases; Replay is used only to seed threads. GitLab requests, fetches, worktree creation, branch switches, and configuration queries are real.
Scenario: Merge request preparation preserves unrelated upstreams in reused and new worktreesProven: the scenario fails on base 9e0de5137b and passes on head df439d76a3. | | Base 9e0de5137b | Head df439d76a3 | The reused-worktree race produces the warning on both commits; that warning is expected after switching away and is not the verdict. The Git configuration captures show the difference. The normal control shows mr-source selected without the warning on both commits. The automatic duplicate failure screenshot is omitted. Recordings retain the checkout interaction, followed by the completion screenshot for two seconds and the terminal result screenshot for three seconds:
|








When a worktree was reused for a pull or merge request checkout, T3 Code set the upstream on whatever branch that worktree had checked out at that moment, read again partway through. If someone switched the worktree to another branch during the checkout, that branch was left tracking the request's source branch. T3 Code now sets the upstream on the request branch it already found for the worktree. Newly created worktrees use the branch they were created for.
Related: #23368
Reproduction on main
Commit ca36afaeb1 (main). T3 Code makes the other branch track the merge request's source branch. Expected: The other branch keeps its configured upstream.
The cause is at
apps/server/src/git/GitManager.ts:4109. Ranpnpm scenarios:prove scripts/scenarios/pr-worktree-keeps-switched-branch-upstream.e2e.ts --target webwith the repro scenario added: it failed in 2 of 2 runs on a clean boat.dev VM, withexpected "origin/review-source" to be "origin/separate-work"in the output.Evidence
Environment: The web app in Chromium on Linux x64, a fresh checkout on a boat.dev VM reset before each run.
Proven: the repro fails at the test commit 5d7fb578dc and passes on the head ae2ea9d132, both on main 54e81819cb.
T3 Code makes the other branch track the merge request's source branch.
The other branch keeps its configured upstream.
Tests
pnpm exec vp run check:changed 54e81819cbe825bfa36808c783c84758890e4ca0passed on head.Not in this change
Who did the work
Made in T3 Code by GPT 6.2 Sol and Claude Opus 5.5