Skip to content

Match newlines in gitignore globstar path segments - #139

Merged
cpburnz merged 1 commit into
cpburnz:masterfrom
jackwalkerlabs:fix/newline-globstar-paths
Sep 10, 2026
Merged

Match newlines in gitignore globstar path segments#139
cpburnz merged 1 commit into
cpburnz:masterfrom
jackwalkerlabs:fix/newline-globstar-paths

Conversation

@jackwalkerlabs

@jackwalkerlabs jackwalkerlabs commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Patterns such as target, **/target, and root/**/target fail to match when a parent directory contains a newline: the generated globstar regex uses a dot without DOTALL. GitIgnoreBasicPattern also misses a filename consisting only of a newline for * and **.

Use scoped DOTALL for globstar segments and the basic match-all shortcut. Update literal regex expectations, add newline regressions, and include a changelog entry. Matching ordinary segment characters remains unchanged.

Validation: new regressions fail before the change; 214 tests and 652 subtests pass with simple, RE2, and Hyperscan backends on CPython 3.12.14. Five cases were independently checked against git check-ignore --stdin -z in real temporary repositories; Git and all three backends agree.

Implemented and locally validated with OpenAI Codex.

Issue tracking: Found during source inspection; no matching open issue was identified for this fix.

@cpburnz

cpburnz commented Sep 10, 2026

Copy link
Copy Markdown
Owner

Thanks for finding and fixing this. It dismays me that git actually supports newlines in file names.

@cpburnz
cpburnz merged commit 547a38e into cpburnz:master Sep 10, 2026
64 checks passed
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