Repository navigation
Fix explicit **/*/** matching top-level directories - #171
Open
mayur-dhavan wants to merge 4 commits into
Open
mayur-dhavan wants to merge 4 commits into
mayur-dhavan wants to merge 4 commits into
Conversation
Refactor directory pattern handling for efficiency.
Add tests for GitIgnore patterns with globstar syntax.
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.
An explicit
**/*/**pattern is caught by the*/normalization special case inGitIgnoreSpecPattern.__normalize_segmentsand compiles to a bare/, soGitIgnoreSpec.from_lines(['**/*/**']).match_file('a/')returnsTruewhile Git does not excludeaitself during traversal. Verified against a real tree: with.gitignorecontaining**/*/**and!a/keep.txt,git add -A -nshows it would stagea/keep.txt— Git does not excludeaitself, so the negation re-includes the file. pathspec instead reportsmatch_file('a/keep.txt')asTrue(ignored), because the degenerate/regex makes the excluded-ancestor rule treataas excluded, which suppresses the negation. Directory behavior is checked through traversal and the staging dry run; git check-ignore on a trailing-slash path can report a different verdict.*/and**/*/**are not equivalent in Git: the latter requires a descendant segment after the*. Under*/+!a/keep.txt, Git cannot re-include the canary (the parent directory is excluded); under**/*/**+!a/keep.txt, it can and does.This change restricts the special case to the directory form it was written for (
*/,is_dir_pattern=True) and lets an explicit**/*/**go through segment translation, which requires a descendant segment after the*(^(?s:.+/)?[^/]+/[^/]). Regression tests cover the directory verdict and the negation re-inclusion; the existing terminal-globstar tests from #137/#138/#164 are unchanged and still pass.The gitwildmatch path already answers both probes the way Git does. The deprecated GitIgnoreBasicPattern still returns a bare
/for this pattern and is left untouched.Closed, unmerged PR #155 included the same condition change as part of a broader patch. This PR targets the still-reproducible
**/*/**case on current master, with regression tests for the directory verdict and negation re-inclusion. PR #164 addressed the separatefolder/**/case.