Skip to content

Commit 9cda05d

Browse files
committed
Only display Git column for directories with repos
This fixes the previous commit.
1 parent 558b138 commit 9cda05d

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

src/fs/feature/git.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct GitCache {
2323

2424
impl GitCache {
2525
pub fn has_anything_for(&self, index: &Path) -> bool {
26-
true
26+
self.repos.iter().any(|e| e.has_path(index))
2727
}
2828

2929
pub fn get(&self, index: &Path, prefix_lookup: bool) -> f::Git {

src/output/details.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ impl<'a> Render<'a> {
144144
let mut rows = Vec::new();
145145

146146
if let Some(ref table) = self.opts.table {
147-
if self.dir.is_none() { git = None }
147+
if self.dir.is_none() { git = None }
148+
if let (Some(g), Some(d)) = (git, self.dir) { if !g.has_anything_for(&d.path) { git = None } }
148149
let mut table = Table::new(&table, git, &self.colours);
149150

150151
if self.opts.header {

src/output/grid_details.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ impl<'a> Render<'a> {
169169

170170
fn make_table<'t>(&'a self, options: &'a TableOptions, mut git: Option<&'a GitCache>, drender: &DetailsRender) -> (Table<'a>, Vec<DetailsRow>) {
171171
if self.dir.is_none() { git = None }
172+
if let (Some(g), Some(d)) = (git, self.dir) { if !g.has_anything_for(&d.path) { git = None } }
172173
let mut table = Table::new(options, git, self.colours);
173174
let mut rows = Vec::new();
174175

xtests/run.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ $exa $testcases/git/additions $testcases/git2/deeply \
213213
$exa $testcases/git2/deeply/nested/directory $testcases/git/edits \
214214
$testcases/git2/target $testcases/git2/deeply $testcases/git --git --long | diff -q - $results/git_21221 || exit 1
215215

216-
216+
$exa $testcases/files -l --git | diff -q - $results/files_l || exit 1 # no git status for dirs
217+
COLUMNS=40 $exa $testcases/files -lG --git | diff -q - $results/files_lG_40 || exit 1 # that aren't under git
217218

218219

219220
# Hidden files

0 commit comments

Comments
 (0)