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

Search doesn't exclude gitignored files #45487

Closed
borekb opened this issue Mar 10, 2018 · 14 comments
Closed

Search doesn't exclude gitignored files #45487

borekb opened this issue Mar 10, 2018 · 14 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug search Search widget and operation issues

Comments

@borekb
Copy link

borekb commented Mar 10, 2018

I just encountered a situation where "Use exclude settings and ignore files" is not honored:

image

This is strange because it usually works fine for me. Also, it has some effect because if I unclick the gear icon, I get different results:

image

I do not quite understand. I've tried in both current version and insiders, it behaves the same in both.

My main VSCode version:

Version 1.21.0
Commit 9a199d77c82fcb82f39c68bb33c614af01c111ba
Date 2018-03-07T11:04:09.886Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architecture ia32

My insiders version:

Version 1.22.0-insider
Commit 3817c899cae312e0e989da8bfbc61308cfbf45f1
Date 2018-03-09T05:15:56.454Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64
@kieferrm kieferrm added the search Search widget and operation issues label Mar 11, 2018
@borekb
Copy link
Author

borekb commented Mar 27, 2018

Confirmed by a colleague on a Mac, VSCode 1.21.1.

@roblourens
Copy link
Member

Any clue what's different about the files in .cache that are correctly excluded vs the ones that aren't? Is it the same set every time?

@roblourens roblourens added the info-needed Issue requires more information from poster label Mar 27, 2018
@borekb
Copy link
Author

borekb commented Mar 27, 2018

I found out what is causing it: the fact that I want to search in a specific folder in our monorepo (the folder is website in the screenshots above). If "files to include" is empty, the problem goes away.

Our monorepo has a structure like this:

- app1
  - .gitignore
- app2
  - .gitignore
- website
  - .gitignore

My goal is to search inside website but still apply the exclude rules in websites/.gitignore.

@roblourens
Copy link
Member

Seems that ripgrep doesn't look at child .gitignore files as it searches. Does using ./website instead work?

@borekb
Copy link
Author

borekb commented Mar 27, 2018

Yes although I'm not sure the results are as expected. I created this repo so that you can try yourself: https://github.com/borekb/vscode-search-issue-45487

Some screenshots:


This is how the structure looks:

image

All four .txt files contain the same thing, a string "hello".


Plain search works as expected:

image


Scoping to just "a" doesn't work:

image


Scoping to "./a" works better but looks differently, for example, the small gray "a" is missing from the search result:

image


Including both folders makes this more apparent, especially compared to the original result:

image image

@borekb
Copy link
Author

borekb commented Mar 27, 2018

Thanks for the tip about ./something by the way, it's much better than getting .gitignored results.

@roblourens
Copy link
Member

Actually it's not what I said before, this is about the include pattern overriding the gitignore file, which ripgrep does.

The result format is what I expect - that syntax roots the search in that folder, rather than searching from the open folder, with the given folder name as **/a/**. That also causes it to use the multi-folder result format.

Will have to play with this some more, I don't think glob patterns should override the gitignore file.

@roblourens roblourens added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Mar 27, 2018
@jameshulse
Copy link

In VSCode 1.22.2 the issue which you originally mentioned does exist @roblourens. Search is finding results in files which should be ignored by sub .gitignore files.

It seems that only the root .gitignore is being used and the others are being ignored.

A standard Laravel project contains the structure:

/storage
    .gitignore
    /framework
        .gitignore
        /cache
            .gitignore                 <- ignores '*'
            /data                        <- should be ignored

Everything in the /storage/framework/cache/data/ folder should be ignored by its most local .gitignore, but results from this folder are being returned.

As a note, the project explorer itself is correctly dimming the ignored data folder.

@roblourens
Copy link
Member

Are you sure @jameshulse? Like @borekb said,

Plain search works as expected

And that's what I saw. So I don't think child .gitignore files are ignored entirely. If you have an include pattern, it might override the gitignore file.

@jameshulse
Copy link

Hopefully these screenshots will show the issue. I am searching for some arbitrary text in one of the ignored cache files in my project.

screen shot 2018-05-02 at 09 31 47
screen shot 2018-05-02 at 09 32 09

Nothing in the include / exclude patterns box and results are the same whether I have the "Exclude settings" toggle on or off.

The nearest .gitignore simply has:

*
!.gitignore

Let me know if there is anything else I can provide.

@roblourens
Copy link
Member

It looks like that file was open before you searched - open files can still be searched even when they should be excluded. That's another bug: #31819

@jameshulse
Copy link

Good catch. I think you might be right - I'm not sure how I originally came across the issue now, but I might have had an inclusion string set.

Sorry for the time waste, I really appreciate all your team do on VS Code!

@ifeltsweet
Copy link

I can confirm this is happening in 1.24.1

@roblourens
Copy link
Member

I believe this is actually a dupe of #26574

@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug search Search widget and operation issues
Projects
None yet
Development

No branches or pull requests

5 participants