Skip to content

Branch patterns ? and [...] disagree with git branch --list on non-ASCII names: origin/? matches origin/é here but not in git #115

Closed

Description

@matt-edmondson

What's wrong

The README says branch patterns mean what they mean to git branch --list. But BranchPattern (MatchesOne / TryWalkBracket in Refs/BranchPattern.cs) matches on UTF-16 chars, while git's wildmatch matches on bytes. Any branch name outside ASCII therefore gets a different answer.

Observed differences

I compared BranchPattern with git branch -r --list over 43 patterns and 37 real refs:

Pattern Ref git BranchPattern
origin/? origin/é no match (é is 2 bytes) match
origin/[é] origin/é no match match
origin/caf?? origin/café match no match
? / [...] against an emoji — counts 4 bytes counts 2 UTF-16 units

Every ASCII-only pattern agreed.

Why it matters

A client that tests a pattern with git branch --list and then sends it here gets a different branch set. Its /state answer quietly leaves out branches it expected, or includes branches it didn't. This affects any team whose branch names contain accented letters or emoji.

Suggested fix

Match against the UTF-8 bytes of the pattern and the ref name, the way git's wildmatch does. That gives exact parity, including git's own byte-level behaviour for ? on multi-byte characters.

If byte-level ? is judged too surprising to copy, the README should instead state the deviation explicitly (code-point matching). As it stands, the README promises parity and the code doesn't deliver it.

Acceptance criteria

Activity

  1. matt-edmondson commented on Nov 1, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions