Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A gitignore rule such as
foocurrently matches a path namedfoo\nin the simple and Hyperscan backends, although Git keeps the newline as part of the filename. Python's$anchor may match before a final newline; Hyperscan has the same behavior for$and\Z.Generate Python's strict
\Zend anchor, and translate it to the equivalent\zspelling before compiling RE2/Hyperscan expressions. Keep escaped literal backslash-Z filenames intact and preserve the directory-marker splitting logic. RE2's existing split$already has strict end-of-text semantics. The same translation keeps a customRegexPatternusing a Python\Zanchor consistent across backends.The change is distinct from merged #139 (globstars containing newlines in parent directories) and open #150 (trimming whitespace from pattern lines). This fixes matching of filenames that themselves end with a newline.
Validation
git check-ignore --stdin -zoracle: 480 comparisons across ten pattern configurations and three backends. Mismatches decrease from 46 to 8; all 38 corrected cases concern terminal-newline handling, and there are zero new mismatches. The eight remaining simple-backend ancestor-negation mismatches are identical on untouched upstream and remain outside this change.mypy pathspec tests/check_usage.pyandpyright pathspec tests/check_usage.pyreport the same 5 and 8 diagnostics, respectively, on this patch and an untouched upstream checkout. These concern missing RE2 typing and existing_typing.py/usage-check diagnostics; no new diagnostic is introduced.git diff --checkpasses.AI assistance: OpenAI Codex prepared and validated the patch and tests. Claude Opus independently reviewed the relevant source and backend contracts before submission. No human review is claimed.