Repository navigation
Match branch patterns on UTF-8 bytes, as git branch --list does [patch] - #119
Merged
Merged
Conversation
BranchPattern compared UTF-16 chars while git's wildmatch compares bytes, so outside ASCII the two picked out different branches: origin/? matched origin/é here but not in git, and origin/caf?? matched origin/café in git but not here. The pattern and the name are now spelled as their UTF-8 bytes, one character per byte, before matching. Every character the matcher treats as syntax is ASCII and every byte of a multi-byte character is above U+007F, so ASCII behaviour, bracket expressions and POSIX classes are unchanged. A new parity test runs 41 patterns through both BranchPattern and git branch -r --list over the same 25 refs and requires them to agree. Fixes #115 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW24ManL6mVAsf34qvT
Loose ref files would let a case-insensitive file system on the macOS and Windows CI legs fold origin/main and origin/Main into one ref. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW24ManL6mVAsf34qvT
On Windows git's object files are read-only, so Directory.Delete threw UnauthorizedAccessException from ClassCleanup. Same handling as RealRepositoryTests.RemoveFixture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW24ManL6mVAsf34qvT
|
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 #115
What changes
The README promises that branch patterns mean what they mean to
git branch --list.BranchPatterncompared UTF-16chars, but git's wildmatch compares bytes, so the two picked out different branches outside ASCII. For example,origin/?matchedorigin/éhere but not in git, andorigin/caf??matchedorigin/caféin git but not here.I took the issue's first option, exact parity:
BranchPatternnow holds the pattern as its UTF-8 bytes, one character per byte (Encoding.Latin1overEncoding.UTF8.GetBytes).Matchesconverts the name the same way, and the existing matcher then runs unchanged.[...]character classes match no branches, though git'sbranch --listhonours them #43 / Branch patterns with POSIX character classes like [[:digit:]] silently match the wrong branches #56 POSIX-class behaviour don't change.TryParse(length limit, unknown-class check) still works on the text as sent./branchessection now say that matching is on bytes, with thecaf??/caf?example.Tests
BranchPatternGitParityTests.EveryPattern_PicksOutTheSameBranchesAsGitBranchList(new) builds a throwaway repo with 25 remote-tracking refs, includingé,café,naïve,😀,x😀and日本alongside the ASCII names from the existing tests. It runs 41 patterns through bothBranchPatternandgit branch -r --list. The patterns include every ASCII case already inBranchPatternTestsand the issue's table. The test requires both sides to pick out the same set for every pattern and lists each disagreement.BranchPatternTests.Matches_OutsideAscii_CountsUtf8BytesLikeGitcovers the issue's table as unit cases.With the old char-level matching swapped back in, the parity test reports 12 disagreeing patterns and 7 of the 9 unit cases fail. With the change, the full
GitBranchStateCache.Testssuite passes (295/295, net10.0).This branch is independent of #117 and #118, and
git merge-treeshows it merges cleanly with both.Generated by Claude Code