Only display Git column for directories with repos

This fixes the previous commit.
This commit is contained in:
Benjamin Sago 2017-09-02 00:04:22 +01:00
parent 558b13880b
commit 9cda05df20
4 changed files with 6 additions and 3 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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();

View File

@ -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