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

Directory paths are ignored even if negative-ignore exists for files underneath it #1050

Open
infinity0 opened this issue Sep 13, 2018 · 5 comments
Labels
bug A bug. gitignore Bugs related to gitignore problems.

Comments

@infinity0
Copy link
Contributor

infinity0 commented Sep 13, 2018

Running over https://salsa.debian.org/rust-team/debcargo-conf/:

$ cat .gitignore
/build
/src/*/*
!/src/*/debian

$ rg -q copyright 
$ rg -q copyright src
No files were searched, which means ripgrep probably applied a filter you didn't expect. Try running again with --debug.
1
$ rg -q copyright src/*

$ git grep -q copyright 
$ git grep -q copyright src
$ git grep -q copyright src/*
@BurntSushi BurntSushi added the bug A bug. label Sep 13, 2018
@BurntSushi
Copy link
Owner

Yeah, this is one of the cases where it's tough for ripgrep to behave the same as git here. I think there have been bugs reported on this issue in the past, but I can't find them.

The fundamental issue is that /src/*/* matches src/atty (for example), and therefore, that directory is ignored and ripgrep doesn't descend into it. So the !/src/*/debian whitelist rule isn't even applied.

Two thoughts:

  1. Should src/atty actually match /src/*/*? There might be some special handling going on with the trailing slash that allows it to match. Not sure.
  2. Maybe ripgrep either needs to get smarter, or it cannot implement the optimization of avoiding to descend into directories that have been ignored.

@infinity0
Copy link
Contributor Author

infinity0 commented Sep 15, 2018

Should src/atty actually match /src//?

No, */* is pretty explicit about only matching 2 levels down. I think this would take it further away from the behaviour of git.

Maybe ripgrep either needs to get smarter, or it cannot implement the optimization of avoiding to descend into directories that have been ignored.

I think this would be the correct approach, how about not implementing the optimisation if there exists a ! whitelist rule matching potentially anything below that directory?

@BurntSushi
Copy link
Owner

BurntSushi commented Sep 15, 2018

how about not implementing the optimisation if there exists a ! whitelist rule matching potentially anything below that directory?

Yes, that's what I mean by "smarter." There's no infrastructure for that kind of analysis yet.

But it sounds like we should at least try to understand why src/atty is matching src/*/* and fix that.

@ssbarnea
Copy link
Contributor

In fact the ignore-file implementation seems to be quite broken, I just discovered that an entry like .pre-commit/ caused the ignore of all files in all folders named .pre-commit-config.yaml, which is clearly not what I was looking for.

@BurntSushi
Copy link
Owner

In fact the ignore-file implementation seems to be quite broken, I just discovered that an entry like .pre-commit/ caused the ignore of all files in all folders named .pre-commit-config.yaml, which is clearly not what I was looking for.

That is entirely separate from this issue. Please open a new issue with an MRE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug. gitignore Bugs related to gitignore problems.
Projects
None yet
Development

No branches or pull requests

3 participants