Skip to content

Fix wildcard match failing for mid-path segments#5

Merged
andrew merged 1 commit intomainfrom
fix-wildcard-middle-match
Mar 30, 2026
Merged

Fix wildcard match failing for mid-path segments#5
andrew merged 1 commit intomainfrom
fix-wildcard-middle-match

Conversation

@andrew
Copy link
Copy Markdown
Contributor

@andrew andrew commented Mar 26, 2026

Three fixes for pattern matching to align with git behavior:

  1. The literalSuffix fast-reject optimization checked only the last path segment, but patterns with an implicit trailing ** can match any segment. A pattern like v*o would fail to match value/vulkano/tail because the suffix o was checked against tail instead of vulkano. Skip suffix extraction when the pattern ends with **.

  2. Patterns with unclosed bracket expressions (e.g. v[ou]l[) were treated as containing a literal [. Git rejects these patterns entirely. Now reported as a compilation error via Errors().

  3. Trailing /** patterns (e.g. /a*/**) matched plain files when they should only match directories and their contents. In git, dir/** matches dir/ and dir/file but not dir as a file. Convert trailing /** to dirOnly semantics by stripping the ** and setting dirOnly.

Fixes #4

@AriehSchneier
Copy link
Copy Markdown

AriehSchneier commented Mar 26, 2026

I have some other bugs, I added them to the issue instead of here.

Three fixes for pattern matching to align with git behavior:

1. The literalSuffix fast-reject optimization checked only the last path
segment, but patterns with an implicit trailing ** can match any segment.
Skip suffix extraction when the pattern ends with **.

2. Patterns with unclosed bracket expressions (e.g. "v[ou]l[") were treated
as containing a literal "[". Git rejects these entirely. Now reported as a
compilation error via Errors().

3. Trailing /** patterns (e.g. "/a*/**") matched plain files when they
should only match directories and their contents. Convert trailing /** to
dirOnly semantics by stripping the ** and setting dirOnly.

Fixes #4
@andrew andrew force-pushed the fix-wildcard-middle-match branch from 568f576 to 62c9331 Compare March 26, 2026 16:23
@andrew andrew merged commit 2173528 into main Mar 30, 2026
4 checks passed
@andrew andrew deleted the fix-wildcard-middle-match branch March 30, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Match fails for wildcard in folder name

2 participants