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

Comments

@borekb
Copy link

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
@borekb

This comment has been minimized.

Copy link
Author

commented Mar 27, 2018

Confirmed by a colleague on a Mac, VSCode 1.21.1.

@roblourens

This comment has been minimized.

Copy link
Member

commented Mar 27, 2018

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?

@borekb

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Member

commented Mar 27, 2018

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

@borekb

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Author

commented Mar 27, 2018

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

@roblourens

This comment has been minimized.

Copy link
Member

commented Mar 27, 2018

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 and removed needs more info labels Mar 27, 2018

@jameshulse

This comment has been minimized.

Copy link

commented May 1, 2018

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

This comment has been minimized.

Copy link
Member

commented May 1, 2018

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

This comment has been minimized.

Copy link

commented May 2, 2018

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

This comment has been minimized.

Copy link
Member

commented May 3, 2018

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

This comment has been minimized.

Copy link

commented May 3, 2018

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

This comment has been minimized.

Copy link

commented Jun 29, 2018

I can confirm this is happening in 1.24.1

@roblourens

This comment has been minimized.

Copy link
Member

commented Sep 13, 2018

I believe this is actually a dupe of #26574

@roblourens roblourens closed this Sep 13, 2018

@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.
Projects
None yet
5 participants
You can’t perform that action at this time.