Repository navigation
Match POSIX character classes in branch patterns [patch] - #95
Merged
Merged
Conversation
A pattern such as release-[[:digit:]]* was read as a plain set closed by the first ], so it left out release-1.0 and matched release-d]x instead. Bracket expressions now honour the twelve classes git's wildmatch knows, alone or mixed with other members, and a pattern naming an unknown class such as [:bogus:] is refused, since git abandons the match for it. Fixes #56 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LxJek7fRQ3W1PmY5cm9btG
|
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 #56
Summary
BranchPatternread[[:digit:]]as the plain set{ '[', ':', 'd', 'i', 'g', 't' }closed by the first], soorigin/release-[[:digit:]]*left outorigin/release-1.0and matchedorigin/release-d]x. Bracket expressions now honour the POSIX classes git's wildmatch knows.TryReadClassrecognises[:name:]inside a bracket the way wildmatch does: after[:, the first]ends a class only when a:comes straight before it; otherwise the[is an ordinary member.IsInClasstests the character against the ASCII range foralnum,alpha,blank,cntrl,digit,graph,lower,print,punct,space,upperandxdigit. The walk stays linear, with no regular expressions.TryParserefuses a pattern that names an unknown class ([[:bogus:]]), so the endpoints answer 400 instead of silently matching nothing. git abandons the match in that case.Testing
BranchPatternTests:[[:digit:]],[[:alnum:]],[[:alpha:]_-],[a[:digit:]], a negated class,[[:x]as an ordinary set,[[:bogus:]]refused, and an escaped look-alike accepted.BranchPattern.cschange reverted, 5 of the new tests fail (digit, alnum, mixed, negated, unknown class). With it, they pass.GitBranchStateCache.Testssuite: 261/261 pass.Generated by Claude Code