Преглед изворни кода

Only display Git column for directories with repos

This fixes the previous commit.
Benjamin Sago пре 8 година
родитељ
комит
9cda05df20
4 измењених фајлова са 6 додато и 3 уклоњено
  1. 1 1
      src/fs/feature/git.rs
  2. 2 1
      src/output/details.rs
  3. 1 0
      src/output/grid_details.rs
  4. 2 1
      xtests/run.sh

+ 1 - 1
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 {

+ 2 - 1
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 {

+ 1 - 0
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();
 

+ 2 - 1
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