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

Tracking of ignored files showing false positives. #310

Closed
rscorer opened this issue Feb 13, 2017 · 12 comments
Closed

Tracking of ignored files showing false positives. #310

rscorer opened this issue Feb 13, 2017 · 12 comments

Comments

@rscorer
Copy link

rscorer commented Feb 13, 2017

Received notice that

Ignored files found that are tracked: .ignore plugin found some files that are tracked with Git which are also listed in .gitignore file.

However, the file being highlighted is gradle-wrapper.jar which is in my .gitignore file as this:

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

Earlier I also noticed that log4j2.properties file which is in my build folder was similarly being marked. It is of course included in git in the main project, and my build folder is added to .gitignore, so this rule seems a little confused.

@akomelj
Copy link

akomelj commented Feb 13, 2017

I noticed very similar behaviour across several projects. In one case, my project root (directory!) is being detected as being tracked and ignored at the same time by the plugin. Obviously, my project root directory is not included in .gitignore.

@hsz
Copy link
Member

hsz commented Feb 16, 2017

@akomelj Thank you for your report!

When displaying those kind of informations, I'm depending on the following git command:

git ls-files --ignored --exclude-standard

performed in each Git root directory.
This command provides me a list of the files (relative paths to the git-root) that are listed in .gitignore file AND tracked by git (so, they were added to Git repo before a rule was added to the .gitignore).

Can you plase execute this command in your git roots and provide me the output to help on the issue investigation?

@rscorer
Copy link
Author

rscorer commented Feb 16, 2017

$ git ls-files --ignored --exclude-standard
gradle/wrapper/gradle-wrapper.jar
$ cat .gitignore
...
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
...

@rscorer
Copy link
Author

rscorer commented Feb 16, 2017

Interesting, I thought I'd try something quickly - and apparently its all git's fault.

If I edit my .gitignore I can avoid this issue...

Previously:

$ cat .gitignore
...
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
...
# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar

...

$ git ls-files --ignored --exclude-standard
gradle/wrapper/gradle-wrapper.jar
$

Edited, I end up with this:

$ cat .gitignore
...
# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

...

$ git ls-files --ignored --exclude-standard
$ 

Previously the Avoid line was placed before the *.jar line

So the order is apparently very important

(Hope that makes sense)

@akomelj
Copy link

akomelj commented Feb 16, 2017

@hsz

The provided command does not list HWE directory (supposedly ignored & tracked):

netek:epay-hwe andrej$ git ls-files --ignored --exclude-standard
MODULES/business_portal/src/main/resources/static/components/qr/.DS_Store
MODULES/issuer_portal/src/main/resources/static/css/.DS_Store
MODULES/modules-furs/src/test/resources/.DS_Store
MODULES/sessionmodule/web/src/main/webapp/META-INF/MANIFEST.MF
MODULES/sessionmodule/web/src/main/webapp/META-INF/context.xml
MPS/StatusImporter/.factorypath
WEBAPP/overlays/rs/ebills/admin/src/main/webapp/static/js/views/.gitignore
WEBAPP/overlays/rs/ebills/portal/src/main/webapp/static/js/views/.gitignore

.gitignore in the root of Git repo and in HWE project directory (direct descendant of the root of Git repo) also does not list HWE as excluded:

netek:epay-hwe andrej$ cat .gitignore 
# Compiled source #
target/
build/
bin/
.metadata
.settings/
.apt_generated/
.project
.classpath
.factorypath
.idea/
.codepro/
*.iml
/log/
*.log
pom.xml.versionsBackup
netek:epay-hwe andrej$ cat HWE/.gitignore
cat: HWE/.gitignore: No such file or directory

Since my project root HWE is not in the root of Git repo - is it possible that your plugin processes Git output and wants to display descendants of HWE which are not listed and displays only empty project root directory as a result?

Plugin dialog screenshot:
screen shot 2017-02-16 at 23 31 19

@BorzdeG
Copy link

BorzdeG commented Feb 25, 2017

before press "add unversioned files": https://habrastorage.org/files/559/1e1/17a/5591e117a1374d34a56f4718a670e38b.png
after press: https://habrastorage.org/files/9bb/243/ab5/9bb243ab5287461c8557eeff4d9dcdeb.png

command "git ls-files --ignored --exclude-standard" no output

UPD: I think that the plug-in sees the files and directories that are created IDEA for internal needs and then removed. the problem is probably in IDEA virtual file system

@SUPERCILEX
Copy link

I'm having the same issue:
image

.gitignore:

.idea
!.idea/codeStyleSettings.xml

@NielsDoucet
Copy link

@SUPERCILEX I had the exact same match coming up.
To work around the issue, I changed .idea to .idea/**/*.*
It matches everything inside the .idea folder without having to match on a directory level, which apparently causes git to trip up.

@SUPERCILEX
Copy link

@HeadOnAPlate Thanks for the tip! .idea/**/*.* didn't work for me, but this did: .idea/**. That's weird that git can't do this for us. Anyway, thanks!

@bamapookie
Copy link

I've seen this problem elsewhere: toptal/gitignore.io#178

It does appear that order matters in the .gitignore file. Is there a way we could separate the exclusions from templates and include them at the end of the file, maybe after some marker where newly added templates would be placed? Or maybe have the inclusive portion of templates added to the top of the file and exclusionary portions of templates added to the end?

@pbienick
Copy link

I'm experiencing false positives on several projects where the plugin is reporting that it found files which are tracked in Git but are listed in .gitignore, yet the "list of commands to be performed with untrack operation" is empty, and git ls-files --ignored --exclude-standard also does not produce any results.

@hsz
Copy link
Member

hsz commented Jun 5, 2017

@rscorer @akomelj @bamapookie @SUPERCILEX @HeadOnAPlate @bamapookie @pbienick
Thank you guys for this feedback.

I finally was able to resolve this issue (mostly with reimplementing the indexing part). The main issue that caused this bug was wrongly handled files excluding with ! at the beginning (it was commited to #350).

This fix will be released with v2.0.0 as soon as I'll take care of the other issues (I'm back on track for last 2 weeks).

CC @cjbarth @pvannuff @bamapookie @Hronom

@hsz hsz added this to the v2.0 milestone Jun 5, 2017
@hsz hsz closed this as completed Jul 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants