Repository navigation
fix(server): an upstream shadowed by a local origin/<branch> branch keeps its real remote - #29180
Merged
Merged
Conversation
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.
Problem
A branch
featuretracksorigin/feature, and the repository also has a local branch literally namedorigin/feature. That happens easily aftergit checkout -b origin/featureorgit branch origin/x. In that casegit rev-parse --abbrev-ref @{upstream}printsremotes/origin/feature, and T3 reads the upstream remote asremotes:remotes. It fails every time and backs off, so behind counts never refresh.branch.feature.t3-merge-base=origin/featureandt3-merge-base-ref=refs/remotes/remotes/origin/feature(a ref that does not exist) to git config. A later PR then resolves that base to the localorigin/featurebranch and targets the wrong base.Change
readCurrentUpstreamRefnow reads the full upstream ref (rev-parse --symbolic-full-name @{upstream}) and stripsrefs/remotes/itself. It also stripsrefs/heads/, so a local (remote = .) upstream gives the same short value as before. This follows #24258 (branchNameFromHeadRef, the same problem with tag shadowing) and the siblingresolveTrackedRemoteBaseRef, which already reads full refs so a similarly named local branch cannot shadow the remote one.The ahead/behind count in
statusDetailsRemotenow compares againstHEAD...@{upstream}instead of the shortened name. Otherwiseorigin/featurewould resolve to the shadowing local branch.Scope and approval
Very small, focused fix for an obvious bug, so no prior issue: one function reads the upstream with the same shortened-ref ambiguity #24258 already fixed for the branch name, plus the one comparison that consumed that name. Overlap search: #24258 (merged) fixed only the HEAD branch read. #19802 (merged) avoided remote enumeration in status reads. Open #24047 uses
--abbrev-ref @{upstream}only in tests and does not touchreadCurrentUpstreamRef. No open PR changes this read.Verification
GitVcsDriverCore.test.ts. It now tracks a bare remote, adds an unpushed commit, creates a localorigin/releasebranch, and assertsupstreamRef === "origin/release"andaheadCount === 1.AssertionError: expected 'remotes/origin/release' to equal 'origin/release'. With only the upstream read fixed, the count assertion failed withexpected +0 to equal 1.vp test run src/vcs/GitVcsDriverCore.test.ts: 223 passed, 1 failed. The failure is "keeps generated worktree folders short without changing long branch names", a macOS/varvs/private/varpath mismatch that also fails on clean main.GitManager,VcsStatusBroadcaster, andSourceControlRepositoryServicetests: 163/163 passed.vp run check:changed: format, lint, knip, graphql, and typecheck pass. Tests fail only on the same macOS case.remotes/origin/feature, the background fetch failed, and push wrotet3-merge-base-ref = refs/remotes/remotes/origin/feature. I did not rerun that end-to-end script against this branch. The test covers the status path, and push consumes the same parsed remote.Reviewed with sol-loop: 2 rounds with GPT-6.1 Sol on high. Sol verdict: approved. Round 1 caught the ahead/behind comparison, which is fixed here.
Created with Claude Opus 5.5 in Claude Code (T3 Code).
🤖 Generated with Claude Code