Skip to content

Match literal [: prefixes in gitignore bracket expressions - #195

Open
wissaaamm wants to merge 1 commit into
cpburnz:masterfrom
wissaaamm:fix/literal-posix-bracket-prefix
Open

wissaaamm wants to merge 1 commit into
cpburnz:masterfrom
wissaaamm:fix/literal-posix-bracket-prefix

Conversation

@wissaaamm

Copy link
Copy Markdown

Problem

Git treats [[:x] as a bracket set containing [, : and x. PathSpec scans ahead for :], so it misses the actual closing bracket and can discard a pattern like [[:x].md instead of matching those filenames.

The segment splitter and glob translator now use the same closing-bracket scanner. It skips a POSIX class only when the first closing bracket completes its token. For incomplete class syntax it continues parsing the brackets as an ordinary set, as Git's wildmatch implementation does.

Tests

  • The new cases failed before this change. Git 2.39.5 check-ignore --no-index confirmed the expected matches, including literal colon filenames and a slash inside the set.
  • python -m unittest discover -t . -s tests/ completed successfully under Python 3.13. The suite reported 331 tests and skipped optional RE2 and Hyperscan cases because those backends were unavailable offline.

Prepared with Codex assistance.

This branch has not been deployed

No deployments
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