Repository navigation
Handle escaped internal separators in gitignore patterns - #170
Open
KennyMcSimpson wants to merge 1 commit into
Open
KennyMcSimpson wants to merge 1 commit into
KennyMcSimpson wants to merge 1 commit into
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.
Gitignore patterns with escaped internal separators are currently discarded as if they contained a trailing backslash. For example, with a real
build/output.txtfile andbuild\/output.txtin.gitignore, Git ignores the file, butGitIgnoreSpec.from_lines([r"build\/output.txt"]).match_file("build/output.txt")returnsFalse.Account for the separator following each pattern segment before treating its last backslash as invalid. Preserve backslash parity, directory-only patterns, and Git's distinction between
**/band**\/b: the escaped slash must still be present. Escaped leading slashes remain literal, and escaped terminal slashes remain invalid. Existing segment-translator overrides keep their original calling convention.Regression tests cover literal paths, globs, negated rules, text/byte patterns, and all three backends. The new tests fail on the unchanged base and pass after the fix; all 46 targeted Git comparison cases agree with
git check-ignore.Validation on Python 3.13 / Windows:
tox -e ci-base,ci-hyperscan,ci-re2andtox -e docspass. With both optional backends installed,python -m unittest discover -t . -s tests/passes all 295 tests (16 existing platform skips).mypy pathspec tests/check_usage.pyandgit diff --checkpass.AI assistance: prepared with OpenAI Codex, with the reproduction and regression checks described above.