Open rafitorres opened 10 years ago
I'd like to try an reproduce this and then open an issue on libgit2 if it is an issue there.
Does your repo have multiple .gitignore
files in different folders or is the example all in the .gitignore
file at the root of the repo with the content:
/*
!.gitignore
!wp-content/
wp-content/*
!wp-content/plugins/
!wp-content/themes/
Just one .gitignore
on the root with that content, yes.
I have a similar problem. I'm not sure if I should create a new issue.
With the following .gitignore
:
node_modules/*
!node_modules/mylib
mylib
appears grayed out, even if it's not ignored:
I'm pretty sure that this was working in the previous versions.
+1, still getting this in latest version ( atom 0.169.0 / tree view 0.147.0 )
I think I may be having the opposite problem (or it could just be that my gitignore skills are bad).
I have the following in my .gitignore
file:
addons/sourcemod/scripting/**
addons/sourcemod/scripting/include/**
!addons/sourcemod/scripting/include/
!addons/sourcemod/scripting/include/freak_fortress_2*.inc
freak_fortress_2.inc
etc. show up properly and respond to changes correctly, but any other file in /include/
shows up as newly added (aka green).
The full .gitignore
file is available here.
Ubuntu 14.04 LTS, tree-view 0.162.0, atom 0.184.0
I believe this is related to this issue. I have a git ignored folder with a negated git ignore folder inside it. When clicking Hide VCS Ignored Files
it hides the highest ignored file and all of its contents. I don't think it should be hiding that folder if it contains project files still.
#.gitignore (snippet)
/dist/src/main/webapp/
/dist/target
!/dist/src/main/webapp/WEB-INF/
Showing VCS Ignored Files:
Hiding VCS Ignored Files
:+1:
Hi everyone !
Same issue here, with this .gitignore file.
/*
!/.gitignore
!/components
/components/*
!/components/com_hello
!/media
/media/*
!/media/com_hello
...
Files in both /components/com_hello and /media/com_hello were ignored in the tree view. So I changed it for this :
/*
!/.gitignore
!/components
/components/*
!/components/com_hello
!/components/com_hello/*
!/media
/media/*
!/media/com_hello
!/media/com_hello/*
...
Those two new lines are useless for git but allow the tree view to track files in both folders. However if the file /components/com_hello/hello.php is modified the components/ folder will not be displayed as modified (but com_hello/ AND hello.php will be).
[UPDATE]
Ok, I think I have found something !
Just switch some lines and everything seems to work like a charm !
/*
!/.gitignore
/components/*
!/components
!/components/com_hello
!/components/com_hello/*
/media/*
!/media
!/media/com_hello
!/media/com_hello/*
...
I was having the same issue, where the negated file ignore entries (using !) were not being picked up by fuzzy finder or in the tree view. Using the work around that @KevinHivert suggested fixes the issue.
Original: node_modules !src/node_modules
changed it to: !src/node_modules node_modules/*
Clue: I changed my original to:
node_modules !src/node_modules
to:
node_modules/* !src/nodemodules
and it shows up as not grayed-out in tree view, but does not show up in the fuzzyfinder
Me thinks this is not a bug with this, since there's nothing modifying file statuses in transit here, but a bug in Atom or one of its dependencies. I traced the dependency chain from there to this:
atom.project
global gave it away)One of these files (or libgit2) has to have the bug, and I don't think tree-view has it.
BTW I'm affected as well.
+1
Thanks all, this is almost certainly a bug in libgit2.
If I remember correctly, @albertein tested the response of libgit2 and it was working correctly.
The issue is that every folder is lazy loaded hence you won't know if there's a file that shouldn't be ignored inside an ignored one. See #524.
@pablasso If that's the issue, then I think what should happen is that tree-view should only ignore the directory if the directory itself is matched by .gitignore
. Just because all the files currently in a directory are matched by .gitignore, doesn't necessarily mean that all files will be.
No idea what functions tree-view is using under the hood, but the git check-ignore
command can get this information trivially. (If running it on a directory returns 0, the directory is ignored. Otherwise it's not.)
@Ajedi32 The problem is that the directory itself its matched, but you also have a rule to not match subdirectories of that directory, so asking libgit2 for wether the pater directory is ignored returns true and tree-view never gets to know there are files inside that directory which are not ignored.
@albertein If the directory itself is matched, then even the standard git CLI will ignore the negated matchers matching files inside the directory. From the docs:
- An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesnβt list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined. Put a backslash ("\") in front of the first "!" for patterns that begin with a literal "!", for example, "!important!.txt".
git distinguishes between ignoring all files in a directory, and ignoring the directory itself. tree-view, for whatever reason, apparently doesn't.
Here is (another) case:
.gitignore
* # Ignore all files
!/**/ # Allow directories
!*.keep # Allow .keep files
!.gitignore # Allow .gitignore
files
.
βββ .gitignore
βββ src
βββ A
βββ A.keep
A
should be ignored (grey not green):src
should't be colouredProof
Looks like libgit2 is causing the bug. See my referenced issue. https://github.com/libgit2/libgit2/pull/5020 might help (not released yet)
A fix has been written for libgit2
(not merged yet).
So isPathIgnored will treat paths with trailing "/" as directories. So we need to ensure that Atom passes a trailing "/" when checking for a directory.
Should I create another issue in the main repo to make sure of this ?
Also, some bugs present in this thread are resolved inside the latest version of libgit2
.
https://github.com/atom/git-utils is the one including libgit2
and there was a version bump from v0.27.0
to v0.28.1
which will fix them.
Looks like this 5 years old issue might close soonish.
Should I create another issue in the main repo to make sure of this ?
Yes, I think this would be helpful.
I think that all of these issues could be solved adding this immediately after the symbol: `!/`
Then, add all the subfolders and file...
I think that all of these issues could be solved adding this immediately after the symbol: `!/`
Then, add all the subfolders and file...
you mean, a .gitignore file like so?
*
!*/
!some_folder/**
Nope, that does not help. Files in some_folder
are still hidden by tree-view.
*
!some_folder
!some_folder/**
actually works, with files and folders in some_folder
being shown.
Let's say I add the following rules to my
.gitignore
to ignore everything in the root except thewp-content
directory:So far this works correctly (only
.gitignore
andwp-content/
are shown in the tree view). Now I add the following rules to ignore everything in thewp-content
directory, except theplugins
andthemes
directoriesBefore Atom 0.116.0, the plugins and themes directories were shown correctly in the tree view, but now the
wp-content
directory disappears completely. My machine's git (v2.0.0) parses the .gitignore correctly and sees changes inplugins
andthemes
.I see that 0.116.0 moved to libgit2 0.21.0. If this is what's causing this behavior I'll open an issue with them.