Skip to content

Make glob **/ match zero or more path segments again - #145

Merged
matt-edmondson merged 1 commit into
mainfrom
fix-globstar-separator
Oct 7, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix-globstar-separator

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #126

What changed

The #114 fix replaces / and \ with U+E000 before DotNet.Glob sees the pattern, so * and ? can cross slashes. A side effect is that DotNet.Glob no longer recognises **/ as "zero or more segments", so src/**/*.cs, **/*.cs and **/readme.md matched nothing.

ResolveGlob now expands every masked **/ into two forms before it parses:

  • the zero-segment form, with the **/ removed
  • the */ form, meaning anything up to a separator

A token matches if any expansion matches. Up to 4 **/ per token get both forms, which is 16 globs at most. Any beyond that keep only the */ form. The glob cache now stores Glob[] instead of Glob.

Tests

  • New: GlobStarSlashMatchesZeroOrMoreSegments covers every case in the issue, plus backslash separators and a 5× **/ pattern. Also new: GlobStarSlashStillRejectsNonMatchingPaths, GlobStarSlashFiltersPathItems and GlobStarSlashMatchesCaseInsensitively.
  • With the fix reverted, 7 of the new **/ cases fail. With the fix they pass.
  • The full suite passes locally (158/158), including GlobStarMatchesAcrossSlash, GlobFilterKeepsPathItems and GlobLiteralSlashInPatternStillMatchesSlashInText.

🤖 Generated with Claude Code

https://claude.ai/code/session_01634kz4hrbkEJcGHKJWQjtA


Generated by Claude Code

Masking path separators (#114) hid the separators DotNet.Glob uses to
recognise "**/", so src/**/*.cs and **/*.cs matched nothing. Each "**/"
is now expanded into its zero-segment and "*/" forms before parsing, and
a token matches if any expansion does. The #114 behaviour is unchanged.

Fixes #126

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01634kz4hrbkEJcGHKJWQjtA
@sonarqubecloud

sonarqubecloud Bot commented Oct 7, 2026

Copy link
Copy Markdown

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.

Glob **/ patterns match nothing since the #114 separator fix: src/**/*.cs and **/*.cs filter out every path

2 participants