diff --git a/src/fs/feature/git.rs b/src/fs/feature/git.rs index ffa2dc6..84d2431 100644 --- a/src/fs/feature/git.rs +++ b/src/fs/feature/git.rs @@ -23,7 +23,7 @@ pub struct GitCache { impl GitCache { pub fn has_anything_for(&self, index: &Path) -> bool { - true + self.repos.iter().any(|e| e.has_path(index)) } pub fn get(&self, index: &Path, prefix_lookup: bool) -> f::Git { diff --git a/src/output/details.rs b/src/output/details.rs index 2068579..c647505 100644 --- a/src/output/details.rs +++ b/src/output/details.rs @@ -144,7 +144,8 @@ impl<'a> Render<'a> { let mut rows = Vec::new(); if let Some(ref table) = self.opts.table { - if self.dir.is_none() { git = None } + if self.dir.is_none() { git = None } + if let (Some(g), Some(d)) = (git, self.dir) { if !g.has_anything_for(&d.path) { git = None } } let mut table = Table::new(&table, git, &self.colours); if self.opts.header { diff --git a/src/output/grid_details.rs b/src/output/grid_details.rs index 9778e2b..c12c339 100644 --- a/src/output/grid_details.rs +++ b/src/output/grid_details.rs @@ -169,6 +169,7 @@ impl<'a> Render<'a> { fn make_table<'t>(&'a self, options: &'a TableOptions, mut git: Option<&'a GitCache>, drender: &DetailsRender) -> (Table<'a>, Vec) { if self.dir.is_none() { git = None } + if let (Some(g), Some(d)) = (git, self.dir) { if !g.has_anything_for(&d.path) { git = None } } let mut table = Table::new(options, git, self.colours); let mut rows = Vec::new(); diff --git a/xtests/run.sh b/xtests/run.sh index 11da8d9..c68d126 100755 --- a/xtests/run.sh +++ b/xtests/run.sh @@ -213,7 +213,8 @@ $exa $testcases/git/additions $testcases/git2/deeply \ $exa $testcases/git2/deeply/nested/directory $testcases/git/edits \ $testcases/git2/target $testcases/git2/deeply $testcases/git --git --long | diff -q - $results/git_21221 || exit 1 - + $exa $testcases/files -l --git | diff -q - $results/files_l || exit 1 # no git status for dirs +COLUMNS=40 $exa $testcases/files -lG --git | diff -q - $results/files_lG_40 || exit 1 # that aren't under git # Hidden files