-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support escaping meta characters in glob patterns #526
Comments
From
From
From
I made a simple C program to call And here is how git itself handles the
Sooo... i think git is behaving as documented: It treats In any case, you can fix the problem by escaping the pattern like this: Note that |
@okdana's analysis is almost correct (thank you!). The only thing you missed is that ripgrep doesn't actually support the I think if |
[
and ]
in gitignore
Oh, i didn't actually test So, i believe i've got a solution that works fine on UNIX... but it occurred to me that this has implications for Windows: It looks like Does git support Not sure what to do 🤔 |
@okdana Thank you for the in-depth analysis of what gitignore does with brackets! That's super cool to know! |
@okdana From (non-exhaustively) testing git 2.13.0 on Windows 7 it doesn't appear to support |
@okdana Except there might be other repercussions if globset doesn't treat So if globset is used to parse the The C# glob matcher that I'm familiar with has an |
I suppose you could do something like have it check to see if the character following Most glob meta-characters are illegal in Windows file paths anyway, so there would probably never be a situation where you were trying to match a file name containing a literal I suspect that Windows user + glob containing sub-directory + file name containing meta-character is an exceptionally unlikely set of circumstances, so it'd probably work out most of the time in the real world. It does feel a little weird though — it certainly is non-standard, and it might give users the false impression that git supports this behaviour. FWIW, i looked into how other projects handle globs on Windows:
If i were a Windows user i think i'd just deal with the tab-completion not working — presumably it already fails to work, as it does on UNIX, in several cases: when you're doing negation ( |
* Remove `[` from .gitignore because ripgrep reads the gitignore and errors on what it (and git, actually) thinks is the start of a regex (BurntSushi/ripgrep#526) * Create `NewGrep` command; the `silent` suppresses fullscreen program output which I think prevents the screen from being cleared (or at least makes Vim look super odd after running it). To fix that, call `redraw!`. # Why: # # * # # This change addresses the need by: # # * # # Side effects: # * # # Trello:
* Remove `[` from .gitignore because ripgrep reads the gitignore and errors on what it (and git, actually) thinks is the start of a regex (BurntSushi/ripgrep#526) * Create `NewGrep` command; the `silent` suppresses fullscreen program output which I think prevents the screen from being cleared (or at least makes Vim look super odd after running it). To fix that, call `redraw!`. # Why: # # * # # This change addresses the need by: # # * # # Side effects: # * # # Trello:
* Remove `[` from .gitignore because ripgrep reads the gitignore and errors on what it (and git, actually) thinks is the start of a regex (BurntSushi/ripgrep#526) * Create `NewGrep` command; the `silent` suppresses fullscreen program output which I think prevents the screen from being cleared (or at least makes Vim look super odd after running it). To fix that, call `redraw!`. # Why: # # * # # This change addresses the need by: # # * # # Side effects: # * # # Trello:
@okdana Absolute paths do complete, on Powershell at least (the leading I guess the real potential issue with changing the behavior of |
Sorry, i meant
Yeah, i can certainly see how it would be confusing if (from the user's perspective) the glob just silently failed to work. This tool was recommended to me in the first place because i found I suppose idk. At this point i feel like i'm getting out into the weeds over-analysing this so i'll shut up for a bit :| |
Currently, if you want |
Use the new `Globset::backslash_escape` knob to conform to git behavior: `\` will escape the following character. For example, the pattern `\*` will match a file literally named `*`. Also tweak a test in ripgrep that was relying on this incorrect behavior. Closes BurntSushi#526.
I have the following in my global
.gitignore
:This is because my text editor sometimes creates files with these exact names, and I want to ignore them. However, ripgrep is (I think!) parsing these lines as part of a regex:
To reproduce:
mkdir test_dir
cd test_dir
echo [ > .gitignore
echo ] >> .gitignore
rg anything
Version:
Debug output:
The text was updated successfully, but these errors were encountered: