Skip to content

Ignore unmatched exclusions in detailed_match_files - #158

Merged
cpburnz merged 1 commit into
cpburnz:masterfrom
Larry-Labs:fix/detailed-match-unmatched-negation
Oct 10, 2026
Merged

cpburnz merged 1 commit into
cpburnz:masterfrom
Larry-Labs:fix/detailed-match-unmatched-negation

Conversation

@Larry-Labs

Copy link
Copy Markdown
Contributor

detailed_match_files() raises KeyError when an exclusion matches a file that no previous inclusion added, or when an exclusion is repeated. Remove entries only when present, preserving existing inclusion order and both all_matches modes. Related: #105.

Reproduction on current master:

from pathspec.patterns.gitignore.basic import GitIgnoreBasicPattern
from pathspec.util import detailed_match_files

patterns = list(map(GitIgnoreBasicPattern, ['*.txt', '!*.log']))
result = detailed_match_files(patterns, ['notes.txt', 'debug.log'])
# Previously: KeyError: 'debug.log'; now result contains only 'notes.txt'.

Regression tests cover unmatched exclusions, repeated exclusions, re-inclusion, and removal of an existing match. The unmatched/repeated cases fail on unchanged master. Full unittest discovery passes with the simple and RE2 backends; Hyperscan and the Windows-only case remain untested locally.

Prepared with OpenAI Codex (GPT-6) assistance; the reproduction, tests, and diff were checked before submission.

@cpburnz

cpburnz commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Thanks for finding and fixing this. detailed_match_files() has been neglected.

@cpburnz
cpburnz merged commit bfb5393 into cpburnz:master Oct 10, 2026
7 checks passed
cpburnz added a commit that referenced this pull request Oct 10, 2026
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.

2 participants