Repository navigation
fix(server): a branch prefixed with another remote's name publishes under its full name - #40877
Conversation
…er their full name
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…her-remote-prefix
…mote's prefix Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EvidencePublish local alice/fix with no upstream while origin and alice are configured remotes. In a real replay thread, select Git action options → Push. Same Chromium viewport, light theme, and fresh synthetic state on both commits.
Base created refs/heads/fix. Head created refs/heads/alice/fix and recorded origin/alice/fix as upstream. The scenario failed on base and passed on head. Not shown:
|


Problem
Pushing a new branch whose name starts with the name of a different remote publishes it under the wrong name on the push remote.
Repro on
main:originand a second remote named after a GitHub login, sayalice(your own fork remote, or one T3 added when you checked out a fork PR). Branches named<login>/<topic>are a common convention.alice/fixwith no upstream, commit, and click Push (or Commit & push / Create PR).git push origin HEAD:refs/heads/fixand recordsorigin/fixas the upstream. Expected: it publishesalice/fixto origin. Iffixalready exists on origin and the push fast-forwards it, someone else's branch moves.resolvePublishBranchNameinGitVcsDriverCore.tsdrops a leading<remote>/whenever<remote>is any configured remote, even when the push goes somewhere else. In the steps aboveresolvePushDestinationtakes the no-upstream path,parseRemoteRefWithRemoteNames("alice/fix", ["origin", "alice"])returnsfix, and the push remote falls back toorigin.Change
resolvePublishBranchName(branch, remoteName)now drops the prefix only when it names the remote being pushed to. All three callers pass their destination: the no-upstream publish inresolvePushDestination, the publish path for a branch whose upstream is a base, andpushCurrentBranchwith a requested remote. A branch namedorigin/feature/pushpushed tooriginstill publishes asfeature/push, which the existing test covers. The helper no longer lists remotes, so it is a plain function.Scope
This is a small fix for an obvious bug in one helper, so I didn't open an issue. It follows the rule #33581 set for local-tracking branches, that a branch publishes under its full local name unless that name really is a ref on the destination. #33557 (open) edits the same call sites for a different feature, so expect a textual conflict only.
Verification
GitVcsDriverCore.test.ts, "publishes a new branch prefixed with another remote's name under its full name", uses real repos with two bare remotes. Onmainit fails withexpected { status: 'pushed', …(3) } to have deep property 'upstreamBranch' of 'origin/alice/fix', but got 'origin/fix'. With the fix it passes and checks thatrefs/heads/alice/fixon origin points at HEAD.it.effect.each(["feature/push", "origin/feature/push"])) still passes.GitVcsDriverCore.test.tsandGitManager.test.tspass (530 tests).vp fmt,vp lintandknip:checkon the changed files are clean, andt3typecheck passes.Code written with Claude Code (Claude Opus 5.5).