When using --git-ignore along with --all, the .git folder shows up.
By itself it's not an issue but when adding --tree it's undesirable.
My use case is printing a tree of a project, ideally would like to see only source files.
--git-ignore handles most of the clutter, but .git folder is still there.
It seems reasonable to me tat when using --git-ignore you'd want to hide .git as well.
You can use -I .git to ignore the .git folder.
You can use
-I .gitto ignore the.gitfolder.
Yes I know, but it feels like you'd expect it to happen automatically when using --git-ignore
--git-ignore ignores files listed in .gitignore. .git will not be in .gitignore.. Think you will have to explicitly ignore if you need it to be ignored.
I understand the mechanics of how it works right now.
But there's also basic expectations from users.
Sensible defaults would go a long mile making people's lives easier.
I'm specifically asking that on a combination of --git-ignore and --tree for the .git folder to be excluded by default.
If that request doesn't make sense for any valid reason, we can close this issue.
Otherwise I'm asking to consider.
@alexilyaev:
But there's also basic expectations from users.
And my expectation when combining --all (with or without --tree) with --git-ignore is to show all files/directories (in tree view or not) except those listed in .gitignore (which does *not include the .git directory itself).
Maybe add a --ignore-git option to ignore the .git directory would be possible but that's basically the same as -I .git which one can even alias to exa (via alias exa='exa -I .git') as it doesn't do any harm if no .git directory exists.
Indeed I'm using an alias right now:
alias llt='exa --all --group-directories-first --git-ignore --tree --level=2 --ignore-glob ".git"'
I think of --all as it sets the initial set of files and other flags filter that list down.
If it makes sense for --git-ignore to filter the list with --all, then it would make sense as well if the .git folder was part of --git-ignore filtering by default.
I think my request is an edge case and not so mainstream, let's wait for a maintainer to decide.
@alexilyaev
I think my request is an edge case and not so mainstream, let's wait for a maintainer to decide.
No offense, but I think you have not read the manual carefully:
FILTERING AND SORTING OPTIONS
-a, --all
show hidden and 'dot' files. Use this twice to also show the . and .. directories.
--all (just like for ls) is about 'un-hiding' 'hidden' files which in the UNIX world are indicated by a leading dot (.). The default is to ignore those, --all changes that to include them.
--git-ignore would also hide a file called foo (no leading dot, so simple exa would show it) as long as this file is mentioned in the .gitignore file.
Again, the manual is very clear about this:
ignore files mentioned in '.gitignore'
Consider the follwoing example:
mkdir test
cd test
touch .foo bar baz
echo bar >> .gitignore
Now exa will give you
bar baz
because .foo and .gitignore start with a leading dot (.) and are therefore considered 'hidden' and not shown by default.
exa --all will include both of them:
.foo .gitignore bar baz
If you run exa --all --git-ignore you get
.foo .gitignore baz
because bar is mentioned in the .gitignore file and thus not shown when specifying ---git-ignore.
Note however that ---git-ignore also works without --all: exa --git-ignore will give you
only, because on top of not showig the 'hidden' files .foo and .gitignore (default, not overwritten by --all), bar is also not shown because it is mentioned in the .gitignore file.
If you replace the file .foo by a directory .git, nothing changes the above logic:
Without --all you won't see it because it's 'hidden', with --all you will, regardless of --git-ignore because the .gitignore file does not mention a directory called .git to it is not ignored.
The --tree flag has nothing to do with what entries are shown, just how:
DISPLAY OPTIONS
[...]
-T, --tree
recurse into directories as a tree
I hope this example helped to clarify and I agree that --all is a bad name compared to --show-hidden or --ignore-leading-dots but ls does the same and this goes back a long time so I think changing it would do more harm than good. On the other hand introducing ---show-hidden with the current documentation of --all while keeping --all and documenting it as a (discouraged) alias for ---show-hidden that is kept for historical reasons might be a good compromise.
Regardless, I think the functionality should not be changed from how it is right now.
@mschilli87 Thanks for the detailed write up.
I get your point, right now it's easier to reason about, and if it were to behave like I suggested that would be considered magic and might be unexpected.
That been said, I do think that specifically when using --tree, the .git folder is not just a folder, it's a Git folder and it has many many files (potentially), and it's always there if you're using the --git-ignore.
So that's not quite the same as an arbitrary .foo folder.
I'm going to close this now since it's a rare case and it's solvable via an ignore glob.
And now that we had the discussion on it, it's somewhat documented.
If other people will be interested in this in the future we could re-open if needed.
Thanks!
Most helpful comment
--git-ignoreignores files listed in.gitignore..gitwill not be in.gitignore.. Think you will have to explicitly ignore if you need it to be ignored.