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

.rgignore glob? #50

Closed
kaushalmodi opened this issue Sep 24, 2016 · 6 comments
Closed

.rgignore glob? #50

kaushalmodi opened this issue Sep 24, 2016 · 6 comments

Comments

@kaushalmodi
Copy link
Contributor

kaushalmodi commented Sep 24, 2016

I am trying to figure out how to ignore a particular dir name (that dir name could occur multiple times in the search path) using .rgignore.

Let's say I have the .rgignore as /proj/SOMEPRJ/.rgignore, and I have these directories

  • /proj/SOMEPRJ/abc/def/XYZ/
  • /proj/SOMEPRJ/ghi//XYZ/

What do I put in /proj/SOMEPRJ/.rgignore to ignore both the XYZ/ dirs?

For ag, I can simply put XYZ in the .agignore and be done with it. But the same does not work here.

*XYZ also does not work.

For now I need to put in the full paths to XYZ/ (both) in the .rgignore.

What is the right way?

@kaushalmodi
Copy link
Contributor Author

The benefit of allowing XYZ/ to ignore both of the above dirs is that I could be initiating my search from any of these directories and that ignore pattern will still work:

  • /proj/SOMEPRJ/
  • /proj/SOMEPRJ/abc/
  • /proj/SOMEPRJ/abc/def/
  • /proj/SOMEPRJ/ghi/

@BurntSushi
Copy link
Owner

Hmm, I can't reproduce:

[andrew@Cheetah 50] tree
.
└── proj
    └── SOMEPRJ
        ├── abc
        │   └── def
        │       └── XYZ
        │           └── bar
        └── ghi
            └── XYZ
                └── bar

7 directories, 2 files
[andrew@Cheetah 50] rg foo
proj/SOMEPRJ/abc/def/XYZ/bar
1:foo

proj/SOMEPRJ/ghi/XYZ/bar
1:foo
[andrew@Cheetah 50] echo XYZ > .rgignore
[andrew@Cheetah 50] rg foo
No files were searched, which means ripgrep probably applied a filter you didn't expect. Try running again with --debug.

A few questions:

  1. What directory are running rg in?
  2. Could you run rg with --debug set and post the output here?

Thanks!

@kaushalmodi
Copy link
Contributor Author

Sorry, actually the ignore pattern was something like XXX/YYY/.

km²~/temp/:proj> tree                                                                          09/24 1:07am
.
└── SOMEPRJ
    ├── abc
    │   └── def
    │       └── XXX
    │           └── YYY
    │               └── bar
    └── ghi
        └── XXX
            └── YYY
                └── bar

8 directories, 2 files
km²~/temp/:proj> cat SOMEPRJ/abc/def/XXX/YYY/bar                                                                                                                                                     09/24 1:08am
foo
km²~/temp/:proj> cat SOMEPRJ/.rgignore                                                                                                                                                               09/24 1:08am
XXX/YYY/
km²~/temp/:proj> rg --no-ignore-parent foo                                                                                                                                                           09/24 1:08am
SOMEPRJ/abc/def/XXX/YYY/bar
1:foo

SOMEPRJ/ghi/XXX/YYY/bar
1:foo
km²~/temp/:proj> rg --no-ignore-parent foo --debug                                                                                                                                                   09/24 1:08am
DEBUG:grep::search: regex ast:
Literal {
    chars: [
        'f',
        'o',
        'o'
    ],
    casei: false
}
DEBUG:grep::literals: literal prefixes detected: Literals { lits: [Complete(foo)], limit_size: 250, limit_class: 10 }
DEBUG:rg::ignore: ./SOMEPRJ/.rgignore ignored because it is hidden
SOMEPRJ/abc/def/XXX/YYY/bar
1:foo

SOMEPRJ/ghi/XXX/YYY/bar
1:foo

@BurntSushi
Copy link
Owner

OK, I think this is a dupe of #25. I'll be sure to include your case in a regression test when I fix it.

@BurntSushi
Copy link
Owner

Actually, this is a dupe of #16. Fix incoming.

BurntSushi added a commit that referenced this issue Sep 24, 2016
We were erroneously neglecting to prefix a pattern like `foo/`
with `**/` (to make `**/foo/`) because it had a slash in it. In fact, the
only reason to neglect a **/ prefix is if the pattern already starts
with **/, or if the pattern is absolute.

Fixes #16, #49, #50, #65
@kaushalmodi
Copy link
Contributor Author

I confirm the fix. Thanks!

amsharma91 added a commit to amsharma91/ripgrep that referenced this issue Sep 27, 2016
We were erroneously neglecting to prefix a pattern like `foo/`
with `**/` (to make `**/foo/`) because it had a slash in it. In fact, the
only reason to neglect a **/ prefix is if the pattern already starts
with **/, or if the pattern is absolute.

Fixes BurntSushi#16, BurntSushi#49, BurntSushi#50, BurntSushi#65
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

No branches or pull requests

2 participants