Repository navigation
fix: reconcile fetch refspecs with remote — heal bare git fetch after branch deletion - #21
Merged
Merged
Conversation
… branch deletion An exact fetch refspec pointing at a branch the remote no longer has makes every bare git fetch fail with "couldn't find remote ref" in every worktree of the pool. Two sources produced such entries: - orbit_add_fetch_refspec entries outliving their remote branch (typical: auto-deleted on PR merge) — nothing ever removed them - switch -c pre-registered a refspec for the not-yet-pushed branch, breaking every bare fetch between switch and first push (found by dogfooding) orbit sync / prune now reconcile refspecs with the remote (single ls-remote): remove entries whose remote branch is gone (plus their stale tracking refs), register entries for locally-tracked branches that now exist remotely so their refs materialize. switch -c no longer pre-registers; sync fetches bare so newly registered refs materialize immediately. Removal uses an exact-match list rebuild (git config --unset treats the refspec's leading + as a regex; --fixed-value needs git >= 2.26). Reconciliation is skipped when the remote is unreachable. Signed-off-by: zheng-weihao <zheng-weihao@outlook.com>
…-time tracking UX switch -c no longer pre-registers (previous commit), but pre-registration existed to make the first push materialize the tracking ref immediately. Restore that experience without the fetch-breaking window: orbit info and the context --startup reignite block already fetched opportunistically — they now reconcile refspecs first and fetch bare, so a scoped/raw branch shows remote tracking from the first session start (or info/sync run) after its push. Changes are announced on stderr; stdout report/JSON shapes are untouched. cruise block and orbit status stay purely local. Signed-off-by: zheng-weihao <zheng-weihao@outlook.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.
Problem
An exact fetch refspec pointing at a branch the remote no longer has makes every bare
git fetchfail withfatal: couldn't find remote ref— in every worktree of the pool. Two sources produced such entries:orbit_add_fetch_refspecentries outlive their remote branch (typical: auto-deleted on PR merge). Nothing ever removed them.switch -cregistered a refspec for the not-yet-pushed branch, breaking every bare fetch between switch and first push — the fix branch itself broke the pool's fetch while this PR was being written.Fix
Every orbit command that already fetches opportunistically —
orbit sync,orbit info, theorbit context --startupreignite block — plusorbit prunenow reconciles fetch refspecs with the remote first (onels-remoteper repo), then fetches bare (git fetch origin):refs/remotes/origin/<branch>ref. →removed stale fetch refspec: <branch>added fetch refspec: <branch>Changes print on stderr (report commands) so stdout/JSON shapes are untouched; prune
--dry-runreportswould remove/add ....Push-time UX preserved without the broken window:
switch -cno longer pre-registers (the branch doesn't exist remotely yet — the refspec is the bug), but it still wires the upstream config up front, so push/pull work immediately; the tracking ref materializes at the first fetching command after the push — session start,orbit info, ororbit sync— or instantly viagit fetch origin <branch>. (A git pre-push hook could materialize at push time, but orbit does not install git hooks into pool repos — it would clash with repos' own hook setups.)Supporting details:
git config --unsettreats the refspec's leading+as an invalid regex, and--fixed-valueneeds git ≥ 2.26 (orbit supports ≥ 2.20).orbit context(cruise block) andorbit statusstay purely local (no fetch, no reconcile).Verified end-to-end on a live pool: planted residue → bare fetch fails →
orbit syncremoves it → bare fetch works; and the pre-registration residue left by this branch's ownswitch -cwas cleaned the same way.Tests
09_prune: removes remote-deleted residue (asserts bare fetch broken before, healed after),--dry-runreports without mutating, removes legacy pre-registered entries while keeping the local branch18_sync: same removal via sync, keeps live refspecs06_worktree_integration:switch -cdoes not pre-register; push →orbit syncregisters the refspec and materializesorigin/<branch>12_context: push → session-start reignite registers + materializes (the agent-facing path)Full suite: 215/215 ok,
make lintclean.