Repository navigation
Conversation
…acks `resolveRemoteTrackingCommit` built its remote-tracking ref by concatenating `<fallbackRemote>/<refName>`, never consulted the branch's configured upstream, and had no fallback. Creating a worktree with "start from origin" therefore failed with a raw `fatal: Needed a single revision` for any local branch whose name does not exist verbatim on the remote — including branches whose upstream is correctly configured, which makes the failure look arbitrary. Resolve in order instead: an already remote-qualified ref, the branch's configured upstream, `<fallbackRemote>/<refName>`, then the local branch. The local fallback matches what `GitManager.resolveBaseRangeRef` already does with this same resolver. `remoteRefName` is now null in that case, so callers can tell a remote base from a local one. When nothing resolves, fail with a message naming the ref that was looked for rather than passing git's stderr through. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Attempting to run a command using github.com/JLarky/lima-escape
What Changed
resolveRemoteTrackingCommit(apps/server/src/vcs/GitVcsDriverCore.ts) now resolves in order instead of assuming<fallbackRemote>/<refName>exists:origin/foo) — unchanged<branch>@{upstream})<fallbackRemote>/<refName>— unchangedremoteRefName: nullGitResolveRemoteTrackingCommitResult.remoteRefNamewidens tostring | nullso callers can distinguish a remote base from a local one.Why
Creating a worktree with "start from origin" failed for any local branch whose name does not exist verbatim on the remote:
The old code built the ref by string concatenation and never consulted the branch's upstream, so even a branch with a correctly configured upstream failed — which makes the error look arbitrary. Reproduced against this repo: the default checkout sits on a local branch
main-mainthat was never pushed, so the server ran62cf46175upstream flippednewWorktreesStartFromOriginto defaulttrue, so this path now runs for everyone rather than only for people who opted in.Why the local fallback rather than
origin/HEAD: if the selected branch is an unpushed feature branch with real commits, silently basing the worktree onorigin/HEADdrops that work out of the base and the agent proceeds on the wrong tree with nothing in the UI saying so.refs/remotes/origin/HEADis also frequently unset locally (it is unset in this clone), so it needs a guard regardless. Falling back to the local ref never changes which branch you asked for.Precedent:
GitManager.resolveBaseRangeRefalready calls this same resolver withEffect.orElseSucceed(() => baseBranch)— falling back to the local ref is already this codebase's behavior for this resolver. The worktree bootstrap path was the inconsistent one.Scope
Deliberately excluded, to keep this reviewable as an upstream candidate:
origin/HEADfallback (see above).baseBranchForWorktree,apps/web/src/components/ChatView.tsx).baseRefNamemetadata passed tocreateWorktree. It is unrelated to this bug and behaviorally inert, sincecreateWorktreealready strips the remote prefix.Testing
Four focused integration tests in
apps/server/src/vcs/GitVcsDriverCore.test.ts, each against a real temp repo:main-maincase)vp test run src/vcs/GitVcsDriverCore.test.ts→ 33 passed.vp fmt --checkclean,vp lintclean,apps/servertypecheck passes (only pre-existing findings in fork-onlysay-to-me/voiceNotesProxy.ts).🤖 Generated with Claude Code