Skip to content

Replace regex with wildmatch, add missing features#1

Merged
andrew merged 1 commit intomainfrom
improvements
Feb 9, 2026
Merged

Replace regex with wildmatch, add missing features#1
andrew merged 1 commit intomainfrom
improvements

Conversation

@andrew
Copy link
Contributor

@andrew andrew commented Feb 9, 2026

Replace the regex matching engine with a direct wildmatch implementation (same algorithm as git's wildmatch.c). Fix trimTrailingSpaces bugs. Add core.excludesfile support, automatic nested .gitignore discovery, match provenance, error reporting, and pattern indexing.

  • Fix trimTrailingSpaces: was using TrimLeft, stripping tabs, mishandling escaped spaces
  • Add benchmarks for compile and match operations
  • Replace regex with two-pointer backtracking wildmatch (9-19x faster matching)
  • Add core.excludesfile support (global gitignore)
  • Add NewFromDirectory and Walk for automatic .gitignore discovery
  • Document thread safety on Matcher
  • Add MatchPath(path, isDir) to avoid trailing slash convention
  • Surface parse errors via Errors() method
  • Add MatchDetail for match provenance (which pattern matched, source file, line number)
  • Add literal suffix indexing for fast pattern rejection (another 2-3x on top)

…itignore API

Rewrites the matching engine from regex compilation to a direct wildmatch
implementation (two-pointer backtracking, same algorithm as git's wildmatch.c).
This fixes bracket expressions, POSIX character classes, and proper ** handling,
with 10-20x better match performance.

Adds core.excludesfile support, NewFromDirectory and Walk for automatic nested
.gitignore discovery, MatchPath, MatchDetail for match provenance, parse error
surfacing via Errors(), and literal suffix indexing for fast pattern rejection.
@andrew andrew merged commit 2e1736e into main Feb 9, 2026
4 checks passed
@andrew andrew deleted the improvements branch February 9, 2026 11:19
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.

1 participant

Comments