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

RipGrep ignoring files from a .gitignore in a parent directory #611

Closed
samsondav opened this issue Sep 23, 2017 · 9 comments
Closed

RipGrep ignoring files from a .gitignore in a parent directory #611

samsondav opened this issue Sep 23, 2017 · 9 comments
Labels
question An issue that is lacking clarity on one or more points.

Comments

@samsondav
Copy link

I have a node app for which all of the useful application code is ignored by the .dockerignore since we only copy the compiled files to docker.

The compiled files are useless for searching and are ignored by the .gitignore file, which is correct.

I want to "ignore" the .dockerignore file. The docs don't seem to specify how to do that, is there a way?

@BurntSushi
Copy link
Owner

Could you please describe what you want in more precise terms? It would help if you gave an example. Namely, I don't know what you mean by "ignoring" .dockerignore. It is a hidden file, so it is automatically ignored by default.

@BurntSushi BurntSushi added the question An issue that is lacking clarity on one or more points. label Sep 23, 2017
@samsondav
Copy link
Author

@BurntSushi

Sorry I wasn't clear.

I mean that the .dockerignore contains some ignore rules that I don't want ripgrep to use. So how can I configure it not to load ignore rules from this file.

@BurntSushi
Copy link
Owner

BurntSushi commented Sep 23, 2017 via email

@samsondav
Copy link
Author

Ahh, you are quite right. It only loads ignore matches from the .gitignore file. The .dockerignore was a red herring.

I ran RipGrep again with --debug and found this output:

$ pwd
/Users/sam/code/nested/local-stack/app-react
$ rg mypattern
...
DEBUG:ignore::walk: ignoring ./app: Ignore(IgnoreMatch(Gitignore(Glob { from: Some("/Users/sam/code/nested/local-stack/.gitignore"), original: "app", actual: "**/app", is_whitelist: false, is_only_dir: false })))
...

I have a directory called app in the directory above the current one. This is gitignored by a .gitignore file in the directory above.

It seems that the rules from the .gitignore in the directory above are being applied incorrectly to this directory.

@samsondav
Copy link
Author

samsondav commented Sep 24, 2017

The directory format looks like this:

project
\-app
\-.gitignore # contains `app`
\-app-react
  \-app # I want to search inside this directory but rg is ignoring it even if I run from app-react

@samsondav samsondav changed the title Can't configure Ripgrep to "ignore" a particular "*ignore" file. RipGrep ignoring files from a .gitignore in a parent directory Sep 24, 2017
@okdana
Copy link
Contributor

okdana commented Sep 24, 2017

How is it incorrect? The gitignore documentation states:

When deciding whether to ignore a path, Git normally checks gitignore patterns from multiple sources, with the following order of precedence, from highest to lowest (within one level of precedence, the last matching pattern decides the outcome):

... Patterns read from a .gitignore file in the same directory as the path, or in any parent directory, with patterns in the higher level files (up to the toplevel of the work tree) being overridden by those in lower level files down to the directory containing the file. These patterns match relative to the location of the .gitignore file. A project normally includes such .gitignore files in its repository, containing patterns for files generated as part of the project build.

You can use the --no-ignore-parent option to disable this behaviour:

--no-ignore-parent
Don't respect ignore files (.gitignore, .ignore, etc.) in parent directories.

@samsondav
Copy link
Author

samsondav commented Sep 24, 2017

I dug into this further.

Turns out it was a weird issue to do with submodules. Not a fault of RipGrep.

This issue can be closed. Thanks for your help! ❤️ 💛 💙 💚 💜

@BurntSushi
Copy link
Owner

Also, if your gitignore file contains an app rule, then that will causeall child directories and files named app to be ignored. If you only want to ignore the top level app directory, then you can use /app instead.

@BurntSushi
Copy link
Owner

In the future, obese start by trying to recreate a minimal reproducible example. That will cut through most misunderstandings like a hot knife through butter. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question An issue that is lacking clarity on one or more points.
Projects
None yet
Development

No branches or pull requests

3 participants