Skip to content

Commit 80b0d9d

Browse files
committed
Display if a file is ignored by git
1 parent 485611e commit 80b0d9d

File tree

6 files changed

+12
-3
lines changed

6 files changed

+12
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ These options are available when running with --long (`-l`):
5252
- **-u**, **--accessed**: use the accessed timestamp field
5353
- **-U**, **--created**: use the created timestamp field
5454
- **-@**, **--extended**: list each file's extended attributes and sizes
55-
- **--git**: list each file's Git status, if tracked
55+
- **--git**: list each file's Git status, if tracked or ignored
5656
- **--time-style**: how to format timestamps
5757

5858
- Valid **--color** options are **always**, **automatic**, and **never**.

src/fs/feature/git.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ fn working_tree_status(status: git2::Status) -> f::GitStatus {
279279
s if s.contains(git2::Status::WT_DELETED) => f::GitStatus::Deleted,
280280
s if s.contains(git2::Status::WT_RENAMED) => f::GitStatus::Renamed,
281281
s if s.contains(git2::Status::WT_TYPECHANGE) => f::GitStatus::TypeChange,
282+
s if s.contains(git2::Status::IGNORED) => f::GitStatus::Ignored,
282283
_ => f::GitStatus::NotModified,
283284
}
284285
}

src/fs/fields.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ pub enum GitStatus {
197197

198198
/// A file that’s had its type (such as the file permissions) changed.
199199
TypeChange,
200+
201+
/// A file that’s ignored (that matches a line in .gitignore)
202+
Ignored,
200203
}
201204

202205
/// A file’s complete Git status. It’s possible to make changes to a file, add

src/options/help.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ LONG VIEW OPTIONS
5050
-U, --created use the created timestamp field
5151
--time-style how to format timestamps (default, iso, long-iso, full-iso)"##;
5252

53-
static GIT_HELP: &str = r##" --git list each file's Git status, if tracked"##;
53+
static GIT_HELP: &str = r##" --git list each file's Git status, if tracked or ignored"##;
5454
static EXTENDED_HELP: &str = r##" -@, --extended list each file's extended attributes and sizes"##;
5555

5656

src/output/render/git.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ impl f::GitStatus {
2626
f::GitStatus::Deleted => colours.deleted().paint("D"),
2727
f::GitStatus::Renamed => colours.renamed().paint("R"),
2828
f::GitStatus::TypeChange => colours.type_change().paint("T"),
29+
f::GitStatus::Ignored => colours.ignored().paint("I"),
2930
}
3031
}
3132
}
@@ -38,6 +39,7 @@ pub trait Colours {
3839
fn deleted(&self) -> Style;
3940
fn renamed(&self) -> Style;
4041
fn type_change(&self) -> Style;
42+
fn ignored(&self) -> Style;
4143
}
4244

4345

@@ -60,6 +62,7 @@ pub mod test {
6062
fn deleted(&self) -> Style { Fixed(93).normal() }
6163
fn renamed(&self) -> Style { Fixed(94).normal() }
6264
fn type_change(&self) -> Style { Fixed(95).normal() }
65+
fn ignored(&self) -> Style { Fixed(96).normal() }
6366
}
6467

6568

src/style/colours.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ pub struct Git {
101101
pub deleted: Style,
102102
pub renamed: Style,
103103
pub typechange: Style,
104+
pub ignored: Style,
104105
}
105106

106107
impl Colours {
@@ -177,6 +178,7 @@ impl Colours {
177178
deleted: Red.normal(),
178179
renamed: Yellow.normal(),
179180
typechange: Purple.normal(),
181+
ignored: Style::default().dimmed(),
180182
},
181183

182184
punctuation: Fixed(244).normal(),
@@ -326,6 +328,7 @@ impl render::GitColours for Colours {
326328
fn deleted(&self) -> Style { self.git.deleted }
327329
fn renamed(&self) -> Style { self.git.renamed }
328330
fn type_change(&self) -> Style { self.git.typechange }
331+
fn ignored(&self) -> Style { self.git.ignored }
329332
}
330333

331334
impl render::GroupColours for Colours {
@@ -400,4 +403,3 @@ impl FileNameColours for Colours {
400403
fn symlink_path(&self) -> Style { self.symlink_path }
401404
fn executable_file(&self) -> Style { self.filekinds.executable }
402405
}
403-

0 commit comments

Comments
 (0)