close
Skip to content

fix: ignore invalid gitignore bracket ranges#123

Open
Gares95 wants to merge 1 commit into
cpburnz:masterfrom
Gares95:fix-gitignore-spec-invalid-ranges
Open

fix: ignore invalid gitignore bracket ranges#123
Gares95 wants to merge 1 commit into
cpburnz:masterfrom
Gares95:fix-gitignore-spec-invalid-ranges

Conversation

@Gares95
Copy link
Copy Markdown

@Gares95 Gares95 commented May 25, 2026

Summary

This updates GitIgnoreSpecPattern so reversed invalid bracket ranges such as [z-a] and a[z-a] are treated as null patterns instead of propagating a regex compile error.

This matches the existing invalid-range handling direction for gitignore spec patterns and keeps GitIgnoreBasicPattern behavior unchanged.

What changed

Why

The surrounding test already notes that these patterns should become null patterns to fully replicate Git behavior. This makes reversed invalid ranges consistent with the existing invalid-range cases already covered by the test suite.

Tests

Ran:

python -m unittest tests.test_04_gitignore_spec.GitIgnoreSpecPatternTest.test_15_issue_93_c_2_invalid
python -m unittest tests.test_04_gitignore_spec
python -m unittest tests.test_03_gitignore_basic
python -m unittest tests.test_06_gitignore
python -m unittest discover -t . -s tests/

Full configured unittest result:

Ran 197 tests in 0.203s
OK (skipped=276)

Compatibility notes

  • Scoped to GitIgnoreSpecPattern.
  • GitIgnoreBasicPattern behavior is unchanged.
  • Matching, path normalization, backend dispatch, and tree-walk behavior are unchanged.

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