What's wrong
BranchPattern says it honours the same constructs as git's wildmatch for git branch --list (GitBranchStateCache/Refs/BranchPattern.cs:22-25). The #43 fix added ranges, sets, negation and escapes, but not POSIX character classes: [:alpha:], [:digit:], [:alnum:], [:upper:], [:lower:], [:space:], [:xdigit:], [:punct:] and the rest. git supports all of these.
In TryMatchBracket (BranchPattern.cs:190-214), the first ] after [[:digit: closes the bracket. The expression becomes the set { '[', ':', 'd', 'i', 'g', 't' } and the second ] is matched as a literal character.
Failure scenario
- Pattern:
origin/release-[[:digit:]]*
- Branch:
origin/release-1.0
- Here: no match, because
1 is not in the set.
- git:
git branch --list 'release-[[:digit:]]*' lists the branch.
TryParse accepts the pattern, so /state and /branches return 200 with those branches missing. The client never hears about assets changed on them. The same pattern also wrongly matches a branch such as origin/release-d]x.
Suggested fix / acceptance criteria
- In
TryMatchBracket, recognise [:name:] as a bracket member and test the character with the matching ASCII predicate (char.IsAsciiDigit, char.IsAsciiLetter, and so on). Keep the linear walk with no regular expressions.
- Reject an unknown class name such as
[[:bogus:]] in TryParse with a 400, rather than letting it mismatch silently. git's wildmatch aborts the match in that case.
- Add tests for
[[:digit:]], [[:digit:]], [[:alpha:]_-], a mix like [a[:digit:]], and the malformed [[:bogus:]].
- Update the remarks at
BranchPattern.cs:22-25 to list the classes.
What's wrong
BranchPatternsays it honours the same constructs as git's wildmatch forgit branch --list(GitBranchStateCache/Refs/BranchPattern.cs:22-25). The #43 fix added ranges, sets, negation and escapes, but not POSIX character classes:[:alpha:],[:digit:],[:alnum:],[:upper:],[:lower:],[:space:],[:xdigit:],[:punct:]and the rest. git supports all of these.In
TryMatchBracket(BranchPattern.cs:190-214), the first]after[[:digit:closes the bracket. The expression becomes the set{ '[', ':', 'd', 'i', 'g', 't' }and the second]is matched as a literal character.Failure scenario
origin/release-[[:digit:]]*origin/release-1.01is not in the set.git branch --list 'release-[[:digit:]]*'lists the branch.TryParseaccepts the pattern, so/stateand/branchesreturn 200 with those branches missing. The client never hears about assets changed on them. The same pattern also wrongly matches a branch such asorigin/release-d]x.Suggested fix / acceptance criteria
TryMatchBracket, recognise[:name:]as a bracket member and test the character with the matching ASCII predicate (char.IsAsciiDigit,char.IsAsciiLetter, and so on). Keep the linear walk with no regular expressions.[[:bogus:]]inTryParsewith a 400, rather than letting it mismatch silently. git's wildmatch aborts the match in that case.[[:digit:]],[[:digit:]],[[:alpha:]_-], a mix like[a[:digit:]], and the malformed[[:bogus:]].BranchPattern.cs:22-25to list the classes.