Repository navigation
Conversation
…entireio#2551) `entire session resume <branch>` compared and looked up branch names byte-exact, so a name differing from the on-disk ref only by Unicode normalization (NFC vs NFD) was reported "not found" even though git treats the two spellings as the same branch (core.precomposeUnicode) and checks it out fine. This bit cross-platform teams: a branch created on Linux (NFD) and synced could not be resumed on a macOS checkout (NFC), especially once refs were packed (go-git matches packed-refs byte-exact). Add ResolveLocalBranchName, which resolves a supplied name to the canonical on-disk ref by folding to NFC when an exact lookup misses, plus branchNamesEquivalent for the "already on this branch" fast path. Thread the resolved name through switchToBranchForResume so the checkout and the downstream checkpoint lookup target the real branch. Regression tests cover the NFC/NFD packed-ref case. Fixes entireio#2551
KC1706
force-pushed
the
kc/2551-normalize-branch-name-resume
branch
from
October 9, 2026 17:20
8db6168 to
de2cf6d
Compare
Contributor
Author
|
Rebased onto latest main — the earlier conflicts (trail_cmd.go, go.mod) are resolved and it's now a single clean commit. Verified locally: build, the NFC/NFD regression tests, and mise run lint all pass. Ready whenever you have a moment. |
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.
Fixes #2551.
Problem
entire session resume <branch>compared and looked up branch names byte-for-byte, with no Unicode normalization. Git treats a precomposed (NFC,éU+00E9) and decomposed (NFD,e+ U+0301) spelling of the same accented branch as one branch (core.precomposeUnicode), sogit checkoutfinds it either way — but entire would reportbranch '<name>' not found locally or on originwhen the supplied name's normalization differed from the on-disk ref. It bit cross-platform teams: a branch created on Linux (NFD) and synced couldn't be resumed on a macOS checkout (NFC), especially once refs were packed (git gc), where go-git matchespacked-refsbyte-exact.Fix
ResolveLocalBranchName(git_operations.go): exact ref match wins; otherwise it scans local branches and matches normalization-insensitively (fold to NFC), returning the canonical on-disk ref name so the checkout and the downstream checkpoint lookup target the real branch. Works on both NFC (macOS) and NFD (Linux) checkouts.branchNamesEquivalent: NFC-folded comparison with an ASCII fast path, used for the "already on this branch" check that previously failed even while standing on the branch.switchToBranchForResumenow returns the resolved canonical name and threads it throughresumeFromCurrentBranch(and the two trail resume callers), so the rest of resume uses the real ref name.golang.org/x/textwas already an (indirect) dependency; this promotes it to direct.Testing
TestResolveLocalBranchName_UnicodeNormalizationInsensitivebuilds an NFD-stored branch with packed refs (deterministic across platforms viacore.precomposeUnicode=false) and asserts the NFC spelling resolves to the canonical NFD ref;TestBranchNamesEquivalent_NFCvsNFDcovers the comparison helper.mise run fmt && mise run lint→ 0 issues. Existing resume/trail/branch tests pass.Scope
Deliberately scoped to the resume path from #2551. Other branch-name comparison sites (e.g.
dispatch --all-branches) share the same underlying gap and could reuse these helpers in a follow-up; happy to do that separately if you'd prefer.