Respect global .gitignore when excludesFile path uses surrounding double quotes#2629
Respect global .gitignore when excludesFile path uses surrounding double quotes#2629Kentokamoto wants to merge 2 commits intoBurntSushi:masterfrom
Conversation
BurntSushi
left a comment
There was a problem hiding this comment.
Thanks! But the regex here looks too permissive. It accepts any sequence of whitespace and quotes. It probably should be \s*"?\s* or something.
And please use a literal quote instead of its hex escape. You'll want to use r#"..."# for the string syntax.
|
@BurntSushi , Thanks for the feedback. I've gone ahead and made the changes you suggested. I added an extra test to check if more than one pair of double quotes surrounding the path is valid or not. I can remove it if it's overkill but let me know. |
BurntSushi
left a comment
There was a problem hiding this comment.
This does allow a quote on one side but not the other, but we're never going to get this exactly right with using a regex to parse this file anyway.
|
Also, in the future, PRs like this should just be one commit. So changes should be fixed up into one commit and then force pushed. |
| super::expand_tilde("~/foo/bar") | ||
| ); | ||
| } | ||
| #[test] |
There was a problem hiding this comment.
And also, code should follow the style of the surrounding code. In this case, there should be a blank
line separating test functions.
(You don't need to do this now. I've done it for you and this PR will get rolled up into another bigger one.)
Related Issue: #2392
Summary of problem:
In a .gitconfig file, a user may specify additional file patterns they may want to ignore when committing changes by using the
core.excludesFilesetting. RipGrep respects these file patterns as well.Git also handles file paths that are surrounded by double quotes like
RipGrep's logic does not handle for double quotes.
Changes
The regex used to parse the
excludesFilesection of the .gitconfig adds double quotes (\x22) as a part of the parsing pattern.Tests
Wrote
parse_excludes_file4for unit testingManually tested from issue's example: