Skip to content

Commit 558b138

Browse files
committed
Don’t pass Dirs to the Table
A Table now doesn’t need to know about (or even import) Dir, because we can just not pass the Git reference in if it shouldn’t be using it.
1 parent f3c7fa5 commit 558b138

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/output/details.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,12 @@ impl<'a> AsRef<File<'a>> for Egg<'a> {
140140

141141

142142
impl<'a> Render<'a> {
143-
pub fn render<W: Write>(self, git: Option<&'a GitCache>, w: &mut W) -> IOResult<()> {
143+
pub fn render<W: Write>(self, mut git: Option<&'a GitCache>, w: &mut W) -> IOResult<()> {
144144
let mut rows = Vec::new();
145145

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

149150
if self.opts.header {
150151
let header = table.header_row();

src/output/grid_details.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ impl<'a> Render<'a> {
167167
None
168168
}
169169

170-
fn make_table<'t>(&'a self, options: &'a TableOptions, git: Option<&'a GitCache>, drender: &DetailsRender) -> (Table<'a>, Vec<DetailsRow>) {
171-
let mut table = Table::new(options, self.dir, git, self.colours);
170+
fn make_table<'t>(&'a self, options: &'a TableOptions, mut git: Option<&'a GitCache>, drender: &DetailsRender) -> (Table<'a>, Vec<DetailsRow>) {
171+
if self.dir.is_none() { git = None }
172+
let mut table = Table::new(options, git, self.colours);
172173
let mut rows = Vec::new();
173174

174175
if self.details.header {

src/output/table.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use users::UsersCache;
1313
use style::Colours;
1414
use output::cell::TextCell;
1515
use output::time::TimeFormat;
16-
use fs::{File, Dir, fields as f};
16+
use fs::{File, fields as f};
1717
use fs::feature::git::GitCache;
1818

1919

@@ -284,9 +284,8 @@ pub struct Row {
284284
}
285285

286286
impl<'a, 'f> Table<'a> {
287-
pub fn new(options: &'a Options, dir: Option<&'a Dir>, git: Option<&'a GitCache>, colours: &'a Colours) -> Table<'a> {
288-
let has_git = if let (Some(g), Some(d)) = (git, dir) { g.has_anything_for(&d.path) } else { false };
289-
let columns = options.extra_columns.collect(has_git);
287+
pub fn new(options: &'a Options, git: Option<&'a GitCache>, colours: &'a Colours) -> Table<'a> {
288+
let columns = options.extra_columns.collect(git.is_some());
290289
let widths = TableWidths::zero(columns.len());
291290

292291
Table {

0 commit comments

Comments
 (0)