Closed mentalisttraceur closed 1 year ago
Until this is fixed, we can only partially work around it as users. In the general case it's impractical since exa
could for example get separate paths as arguments where some some are in Git repos leafwards of a Git ceiling dir while others are in Git repos rootwards of a Git ceiling dir.
Turns out the fix is just changing line 165 in git.rs
from
let repo = match git2::Repository::discover(&path) {
to
let flags = git2::RepositoryOpenFlags::FROM_ENV;
let repo = match git2::Repository::open_ext(&path, flags, &[] as &[&OsStr]) {
The solution in my last comment builds fine, passes cargo test
, worked correctly in all of my manual testing, and I'm now running a build of Exa with this patch on all of my devices.
The way I initially wrote it does cause a "trivial cast" warning (due to the cast of &[]
, since the open_ext
template can't infer the type of an empty slice literal argument):
warning: trivial cast: `&[&OsStr; 0]` as `&[&OsStr]`
--> src/fs/feature/git.rs:166:67
|
166 | let repo = match git2::Repository::open_ext(&path, flags, &[] as &[&OsStr]) {
| ^^^^^^^^^^^^^^^^
|
= help: cast can be replaced by coercion; this might require a temporary variable
note: the lint level is defined here
--> src/main.rs:6:9
|
6 | #![warn(trivial_casts, trivial_numeric_casts)]
| ^^^^^^^^^^^^^
Here's the best refactor I could quickly come up with to avoid that lint rule:
let flags = git2::RepositoryOpenFlags::FROM_ENV;
let unused: [&OsStr; 0] = [];
let repo = match git2::Repository::open_ext(&path, flags, &unused) {
One objective advantage of writing it that way is that the code now explicitly hints that the third parameter of open_ext
is ignored in this case.
@ariasuni also this!
Closing this since exa is unmaintained (see https://github.com/ogham/exa/issues/1243), and this has been done in the active fork eza.
Problem
When running a command with the
--git
option, it seems thatGIT_CEILING_DIRECTORIES
is not respected.This can lead to huge delays when
exa
looks past a ceiling directory, finds a.git
in some larger parent, and checks that entire larger tree for Git changes.Reproducible Example
The easiest repro is probably to temporarily make your home directory into a git repo, and see what that does to your execution time, with or without
GIT_CEILING_DIRECTORIES=~
in the environment:This is great for a test because your home directory is probably big enough to see the slowdown. (Just don't forget to
rm -rf ~/.git
when done, unless you're into that sort of thing... if you've just discovered you might be, I recommendgit config status.showUntrackedFiles no
andexport GIT_CEILING_DIRECTORIES=~
.)Misc.
Output of
exa --version
(but I would guess this happens with any version):Observed on the following OS+hardware combinations (but I would guess it this happens on any OS and any hardware):