Repository navigation
Take a project checkout's branches from origin when its clone lacks them - #5885
Closed
alexandre-vl wants to merge 1 commit into
Closed
alexandre-vl wants to merge 1 commit into
alexandre-vl wants to merge 1 commit into
Conversation
A clone bb makes holds only the default branch locally, and the picker names origin's branches without `origin/`. The host passed that name to git, so a new branch from `dev` failed with `fatal: invalid reference: dev`, and an existing `release` with `Cannot checkout missing branch release`. The host now looks a branch up locally, then as `origin/<name>`. A new branch starts from that ref and tracks nothing, as the worktree host makes one. The host reports the ref as the branch's base, and the provider records it as the merge base: `dev` does not resolve in that clone, and a recorded `dev` hides the thread's commits from its diff. An existing branch only origin has is switched to with `--track`.
Contributor
|
Thanks @alexandre-vl for the PR. This repo approves new contributors before it reviews their PRs, so this PR now closes on its own. That is expected. Join the #contributors channel in Discord (https://discord.gg/kvBU6tJhcJ), post a link to this PR, and explain what it changes and why. A maintainer then adds you to the allow list and can reopen the PR. |
ymichael
pushed a commit
that referenced
this pull request
Oct 20, 2026
… the clone lacks them (#5855) ## Human comments Thanks @ymichael for rebuilding this on `main`. ## What was wrong A project bb clones onto a machine holds only the remote's default branch, and the picker lists origin's branches there without `origin/`. The host passed the bare name to git. On `main` at 81b48d3, after #5856, a new branch from `dev` fails with `fatal: invalid reference: dev`, and an existing `release` with `Cannot checkout missing branch release`. ## What changed - The host looks a branch up locally, then as `origin/<name>` (`locateBranch`, on the shared `hasRef`). - An existing branch that only origin holds is switched to with `git switch --track origin/<name>`, so the switch does not depend on `checkout.guess`. - A new branch starts from `origin/<base>` when no local branch has it. The host reports that ref, and the provider records it as the merge base in place of the requested name. `dev` does not resolve in that clone, so a recorded `dev` would leave the thread's diff empty. #5856's other cases are unchanged. - A new branch tracks nothing, as the worktree host's `worktree add --no-track -B` makes one. Otherwise a branch made from `origin/dev` would take it as its upstream. ## How you verified At ebe71b6: - `project-checkout-branches.test.ts` runs in a plain clone. A new branch from `dev` records `origin/dev`, and `release` ends up tracking `origin/release`. Both fail on `main` with the errors above. - #5885's test, run here, has the thread commit in that clone: its diff reads `A\tthread.txt`. - These pass: - the plugin's tests (46) - the smoke, multi-thread and environments integration suites, with #5885's two tests added (43) - #5885 makes the same fix and lists which test fails when each part is reverted alone. Fixes #5851 > AGENT GENERATED Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Oct 20, 2026
…ck (#5907) ## Human comments ## What was wrong #5855 fixed fresh-clone branch resolution, but its integration test only checked an empty initial diff. That could not prove committed thread changes remain visible. The README also still described the selected name as the recorded base rather than the resolved ref. ## What changed Bring over the remaining test and documentation coverage from #5885: - Extend the fresh-clone integration test to commit thread.txt and assert that the diff contains exactly that file. - Extend the existing provider contract test table to verify that selecting dev records the host-resolved origin/dev. - Document local-first branch lookup, origin fallback, tracking behavior, and the resolved diff base. No production code or wire contracts change. ## How you verified - Turbo plugin server tests: 27 passed. - Turbo project-checkout integration tests: 3 passed. - Turbo lint/typecheck for the plugin and integration packages completed successfully. - Temporarily changed the server to record the requested dev instead of origin/dev: the provider test failed and the integration test failed with an empty diff instead of A\tthread.txt\n. Restored production code byte for byte and reran both suites successfully. - Formatted all three changed files and ran git diff --check. Follow-up to #5855; carries over coverage and documentation from #5885. > AGENT GENERATED
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.
Human comments
cc @SawyerHood: this builds on #5856, which you merged, for the fresh-clone half (#5851).
What was wrong
A clone bb makes onto a machine holds only the default branch locally (project.ts#L101), and for a machine with no checkout yet the picker lists origin's branches without
origin/(app.tsx#L351-L357). The checkout host passed that name to git. Onmain(81b48d3) a thread there fails to start:What changed
origin/<name>, as the default-base lookup already does (git.ts#L478-L497).origin/<base>when no local branch has that name. It tracks nothing, as the worktree host makes one (worktree.ts#L559). Otherwise it would takeorigin/devas its upstream.baseBranch, as the worktree host does (host.ts#L115), and the provider records that ref as the merge base instead of the name it was given.devdoes not resolve in that clone, so a recordeddevwould leave the thread's diff empty. The rest of Preserve new checkout branch comparison bases #5856 is unchanged: an existing branch clears the merge base, an attach without a switch keeps it, and a restore re-reports it.git switch --track origin/<name>, so the switch does not depend oncheckout.guess.baseBranchis a new field on the plugin's own host RPC. The daemon runs the host artifact the server sends (plugin-host-manager.ts#L428-L440), so the server and the host change together.How you verified
New integration test
project-checkout-fresh-clone.test.ts, in a plain clone, through the server, the daemon and the bundled plugin:devcommitsthread.txt. Its diff readsA\tthread.txtand its merge base isorigin/dev.releaseends up onrelease, trackingorigin/release.Each change, reverted alone, fails a test:
expected '' to be 'A\tthread.txt\n'; server testexpected '' to be 'A\tthread.txt\n'; 2 host testsfatal: invalid reference: dev; host testCannot checkout missing branch release; host test--trackdroppedcheckout.guess=false--no-trackdroppedorigin/devThese pass:
turbo run typecheck lint --filter='...[origin/main]'(8 tasks)Supersedes #5855.
Fixes #5851