Skip to content
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

Double-star in ignore glob patterns does not work #530

Open
tremby opened this issue Nov 21, 2014 · 19 comments
Open

Double-star in ignore glob patterns does not work #530

tremby opened this issue Nov 21, 2014 · 19 comments
Labels

Comments

@tremby
Copy link

tremby commented Nov 21, 2014

I have a rule /public/**/*.js in my .gitignore file, which means ignore any file ending in .js which is in /public or any subdirectory of /public. Ag is still giving results from such files.

@ggreer ggreer added the ignore label Nov 23, 2014
@smathy
Copy link

smathy commented Nov 30, 2014

Same for me in 0.26

@ggreer
Copy link
Owner

ggreer commented Dec 1, 2014

Yes, this requires some changes to the ignoring code to work correctly. I don't use double-stars in my gitignores, so I've kinda neglected it. Sorry. :(

Note: The "ignore" label is for issues with git/hg/ag-ignores. It doesn't mean I'm going to ignore the issue.

@smathy
Copy link

smathy commented Dec 1, 2014

😆 re the explanation of the ignore tag, thanks for the clarification :)

@jasonkarns
Copy link

As noted in #594 (comment), this could be solved for git by using git status --ignored to get the ignore list rather than parsing .gitignore directly.

@decaff
Copy link

decaff commented Jun 23, 2015

I wired up Jason's suggestion, here. Not tested on Unix. Works for me on Windows.

@talha131
Copy link

Any update on this issue?

@talha131
Copy link

I have added note about this issue in the wiki.

@tremby
Copy link
Author

tremby commented Sep 18, 2016

I just use git grep instead of this package and no longer have to worry about things like this.

@lilyball
Copy link

Are single asterisks not supported either? I'm trying a pattern like p/main/*/migrations and it's not actually ignoring anything.

@roblourens
Copy link

I know this is an old issue, but is it likely to ever be fixed? If it might be fixable via PR, can you give a pointer to where in the code this pattern matching happens?

@gavenkoa
Copy link

@kballard I reported bug: #1060

Adding leaning slash allows matches of path with asterisks...

For your case it is /p/main/*/migrations

@fabiospampinato
Copy link

It would be nice if this got fixed. I was quite disappointed to discover that even though the readme says It ignores file patterns from your .gitignore and .hgignore. that's not really the case :/.

Reading @decaff's published fix this doesn't seem too hard to implement.

@ggreer would you consider a PR for this?

@fmcgough
Copy link

fmcgough commented Sep 6, 2018

This is making ag basically unusable for me, I use double-stars heavily in my .gitignore files. It seems to be a regression since (at least) version 0.31, as I discovered when upgrading to ubuntu 18.04 from 16.04. And as @fabiospampinato mentioned, it's misleading and frustrating to find that the readme is incorrect.

@talha131
Copy link

talha131 commented Sep 6, 2018

@fmcgough There is an alternate RipGrep which does not have this bug. Like me, you may want to migrate to it.

@cmdcolin
Copy link

Would definitely like this :) big fan of ag, my hands are trained on it!

torbiak added a commit to torbiak/dotfiles that referenced this issue Feb 13, 2020
Because patterns with double-star globs in .ignore files doesn't work
with ag: ggreer/the_silver_searcher#530
@rugglcon
Copy link

This is similar for leading backslashes. In .NET projects, ag still searches through the bin folder even though it is specified in .gitignore as \bin/

@togakangaroo
Copy link

Just to throw up another use case:

**/node_modules/*

!src/server/app/node_modules/my-app

for allowing "mock modules". This rule makes ag search all node_modules, making it kind of useless

@togakangaroo
Copy link

Workaround:

new file   .ignore
@@ -0,0 +1 @@
+node_modules
\ No newline at end of file

@jbuck94
Copy link

jbuck94 commented May 18, 2021

using --path-to-ignore .gitignore with

/node_modules/*

in my .gitignore seems to work

jcanseco added a commit to jcanseco/.dotfiles that referenced this issue Nov 4, 2022
Update vim's fzf plugin to use rg (ripgrep) instead of ag
(silversearcher) to perform searches inside files, using [1] as a guide.

rg is faster than ag [2] which makes it perform better on larger
repositories. The former also has better support for ignore files:

* It is able to fully respect (i.e. ignore) files ignored by .gitignore
  and .hgignore, unlike ag [3].
* Its --ignore-file flag can accept an ignore file that has the same
  syntax as .gitignore, .hgignore, etc.

[1] https://github.com/junegunn/fzf.vim#example-rg-command-with-preview-window
[2] https://github.com/BurntSushi/ripgrep#quick-examples-comparing-tools
[3] https://github.com/ggreer/the_silver_searcher/wiki/Advanced-Usage#ignoring-files
[4] ggreer/the_silver_searcher#530 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests