Use a character class to ignore Icon\r directories #4596
+1
−3
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.
Reasons for making this change:
Years ago,
Icon^M^M
was added as a macOS rule. This gets parsed asIcon^M
, which ignores macOSIcon\r
/Icon^M
directories.A strange byproduct of this rule is that when Ripgrep's commonly used
ignore
crate parses gitinore rules, it strips trailing whitespace that is not a literal space character.This means that if you have the current
Icon^M^M
rule in your global gitignore tool, Ripgrep, and any Rust-based directory scanning tool that uses theignore
crate, will be unable to see any directory namedIcon
— which happens to occur frequently in React codebases.This change switches to using a character class like
[^M]
(literal CR surrounded by square brackets).This prevents the rule from ending in whitespace, and thus makes
Icon
directories visible to Ripgrep and Rust-based directory scanning tools again.Why not change Ripgrep
This is old code in Ripgrep, and is widely deployed. It also seems reasonable to see a carriage return at the end of a gitignore rule as not part of the rule. What Ripgrep/ignore is doing is fairly reasonable. Having a
.gitignore
line that ends in two\r\r
is pretty odd. I think the character class solution with brackets is a reasonable solution.