Repository navigation
Treat gitignore segments of three or more asterisks as a globstar - #167
Merged
Merged
Conversation
Git's wildmatch treats a run of asterisks that spans a whole path segment as a single globstar, so '***/x' behaves like '**/x'. Those segments were handled as a single '*', so 'x' and 'a/b/x' were not matched by '***/x'. Collapse such segments to '**' in both pattern classes.
Owner
|
Thanks for finding and fixing this! |
cpburnz
added a commit
that referenced
this pull request
Oct 23, 2026
cpburnz
added a commit
that referenced
this pull request
Oct 23, 2026
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.
Git's wildmatch treats a run of three or more asterisks that makes up a whole path segment the same as
**. pathspec treats it as a single*, so patterns like***/xdon't match what git matches.Example, checked against
git check-ignore:Same for
a/***,a/***/band****/x.This collapses such segments to
**before the pattern is translated, in bothGitIgnoreBasicPatternandGitIgnoreSpecPattern, via a small_collapse_star_runshelper ingitignore/base.py. A run of asterisks inside a segment with other characters (a***b) is unchanged and still acts like*.Added
tests/test_10_gitignore_star_runs.py, which covers both pattern classes andGitIgnoreSpec.from_lines. Full suite passes (290 tests). I also added a line under Bug fixes inCHANGES_1.in.rst.I searched the open issues and PRs for
***, "asterisk" and "globstar" and didn't find one for this case. #45 and #164 look related but are about other globstar cases.