broot
broot copied to clipboard
Files in directories with whitelist-style .gitignore are hidden
Consider the .gitignore:
# Ignore everything, but not directories:
*
!**/
# Except the following file types:
!.gitignore
!**.txt
!**.md
Broot doesn't show any file in the directory with such .gitignore:
ls -a
. .. credits.txt .git .gitignore Readme.md
BROOT_LOG=debug br
/home/allkromm/src/bugs/broot-gitignore
mv .gitignore ..
BROOT_LOG=debug br
/home/allkromm/src/bugs/broot-gitignore
├──broot.log
├──credits.txt
└──Readme.md
Steps to reproduce the behavior:
- Open a directory with git repository and gitignore like described above (minimal example attached);
- Launch Broot;
- Type
pt
;
Expected behavior: credits.txt and Readme.md files are displayed. Actual behavior: they are not displayed.
Files are displayed if .gitignore file is removed from the directory, or if gi flag is no.
- broot version: broot 1.6.3
- OS: Debian
- Version: 11.0
There is a mention of whitelist-style .gitignore files here: https://github.com/Canop/broot/issues/35#issuecomment-753346679
What isn't currently supported by broot's implementation of gitignore is a family of patterns like **.txt
or !**.txt
. It must be noted that those patterns shouldn't be present in a .gitignore as they don't make sense and are confusing, being equivalent to *.txt
and !*.txt
(reference).
The fact is git doesn't complain and silently accepts any number of consecutive stars in this context. Broot should idealy do the same. It's not the case because the "glob" crate I'm using rejects those patterns as invalid ("recursive wildcards must form a single path component"), which is probably the right behavior usually.
I'm not sure of what I'll do. I might solve the problem by switching to the globset crate if it has the same performance (which is probable). In the meantime I suggest you fix your .gitignore files.
You are right. Thanks for the explanation!
I guess I have a bunch of .gitignore files to fix.
Don't close the issue: I'm still trying to have the same behavior than git (I'm trying the globset crate at the moment, must check for all possible regressions...)
In fact I can't use the globset crate. I get a huge perf penalty when using it.