summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Sago <ogham@bsago.me>2017-09-02 00:04:22 +0100
committerBenjamin Sago <ogham@bsago.me>2017-09-02 00:04:22 +0100
commit9cda05df20b1066aed5ef3f4842185572637c923 (patch)
treec9f998573ce09aa5c56c7cdcd05d941c0bc11869
parent558b13880b3ddf84ec7a48c48e934caf5fa6c5c2 (diff)
Only display Git column for directories with repos
This fixes the previous commit.
-rw-r--r--src/fs/feature/git.rs2
-rw-r--r--src/output/details.rs3
-rw-r--r--src/output/grid_details.rs1
-rwxr-xr-xxtests/run.sh3
4 files changed, 6 insertions, 3 deletions
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<DetailsRow>) {
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