Skip to content

Require a descendant directory for a terminal star run like d/***/ - #189

Open
zzoraemon043 wants to merge 1 commit into
cpburnz:masterfrom
zzoraemon043:fix/star-run-dir-globstar
Open

zzoraemon043 wants to merge 1 commit into
cpburnz:masterfrom
zzoraemon043:fix/star-run-dir-globstar

Conversation

@zzoraemon043

Copy link
Copy Markdown

d/**/ only matches directories below d (#164), but d/***/ still matches d/ and its direct files, even though #167 made a run of three or more asterisks a globstar:

>>> spec = GitIgnoreSpec.from_lines(['d/***/'])
>>> spec.match_file('d/'), spec.match_file('d/top.txt'), spec.match_file('d/child/')
(True, True, True)

Git ignores only d/child/ (checked with git check-ignore; same for /d/****/, **/d/***/ and a/**/***/).

requires_dir_descendant looks at the raw segments, where the last one is ***, not **, so the check misses it. It now uses the segments with star runs collapsed, as __normalize_segments() does.

The new test_c cases fail before the change and pass after it; the full test suite passes. I also compared GitIgnoreSpec with git check-ignore on about 55,000 random pattern/path pairs. Before the change every difference was a star-run directory pattern like these; after it they all agree.

This branch has not been deployed

No deployments
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