fix(git-checkout): recover in narrowed-refspec (single-branch) workspaces#268
Merged
Merged
Conversation
Contributor
Author
|
Rebased onto current master and dropped the bundled #241 byte-cap commits — those were already merged separately, so this PR now contains only the #267 git-checkout fix (checkout.py +13, test +35). Also chained the narrowed-refspec fallback after the #277 remote-only-branch path that landed in master since this branch was cut, so both recovery cases are handled: #277 creates a tracking branch when a remote ref exists, #267 fetches + resets to FETCH_HEAD when none does. 5/5 checkout tests pass. |
`git fetch --all` in a single-branch workspace only updates FETCH_HEAD — it never creates refs/remotes/origin/<branch>, so the retry checkout still fails. Fall back to an explicit `git fetch origin <ref>` + `git checkout -B <ref> FETCH_HEAD`. Closes #267 Co-Authored-By: Max <noreply>
fae8270 to
eb2b69c
Compare
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
git-checkout:<branch>fails withref '<branch>' not found even after fetchin workspaces whoseremote.origin.fetchis narrowed to a single branch (e.g.+refs/heads/master:refs/remotes/origin/master). The auto-fetch fallback runsgit fetch --all --prune, which only updatesFETCH_HEAD— it never createsrefs/remotes/origin/<branch>— so the retrygit checkout <branch>still fails.Hit in DVSI Kevin-style single-branch automation worktrees.
Fix
When the retry still hits a pathspec error, fall back to the manual workaround:
-Bis safe here: this block only runs after the first plaingit checkout <ref>already failed, so a pre-existing local branch (which would have made that succeed) is impossible —-Bonly ever creates the branch.Audit
git-divergeandgit-mergedo not share the bug — neither auto-fetches nor assumesorigin/*tracking refs; both verify a local ref and tell the user to fetch.Tests
Added
test_narrowed_refspec_recovers_via_single_ref_fetch. 5/5 pass.Closes #267