From 7dc3a02185bbfbc1cdf3f148bcb76932a562d3df Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Tue, 10 Mar 2015 18:36:29 +0100 Subject: [PATCH 1/4] Make Git Column Optional Closes #47 --- src/options.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/options.rs b/src/options.rs index ec015f9..f23da3d 100644 --- a/src/options.rs +++ b/src/options.rs @@ -72,6 +72,10 @@ impl Options { opts.optflag("", "version", "display version of exa"); opts.optflag("?", "help", "show list of command-line options"); + if cfg!(feature="git") { + opts.optflag("", "git", "show git status"); + } + if xattr::feature_implemented() { opts.optflag("@", "extended", "display extended attribute keys and sizes in long (-l) output"); } @@ -490,6 +494,7 @@ pub struct Columns { links: bool, blocks: bool, group: bool, + git: bool } impl Columns { @@ -501,6 +506,7 @@ impl Columns { links: matches.opt_present("links"), blocks: matches.opt_present("blocks"), group: matches.opt_present("group"), + git: matches.opt_present("git"), }) } @@ -545,7 +551,7 @@ impl Columns { if cfg!(feature="git") { if let Some(d) = dir { - if d.has_git_repo() { + if self.git && d.has_git_repo() { columns.push(GitStatus); } } From 5d152dbe158cd4ea7b777a8dda83fb7636819ba0 Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Tue, 10 Mar 2015 18:56:38 +0100 Subject: [PATCH 2/4] Git Column is Useless Without `--long` --- src/options.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/options.rs b/src/options.rs index f23da3d..1feeae4 100644 --- a/src/options.rs +++ b/src/options.rs @@ -279,6 +279,9 @@ impl View { else if matches.opt_present("blocks") { Err(Misfire::Useless("blocks", false, "long")) } + else if cfg!(feature="git") && matches.opt_present("git") { + Err(Misfire::Useless("git", false, "long")) + } else if matches.opt_present("time") { Err(Misfire::Useless("time", false, "long")) } @@ -653,6 +656,13 @@ mod test { assert_eq!(opts.unwrap_err(), Misfire::Useless("blocks", false, "long")) } + #[test] + #[cfg(feature="git")] + fn just_git() { + let opts = Options::getopts(&[ "--git".to_string() ]); + assert_eq!(opts.unwrap_err(), Misfire::Useless("git", false, "long")) + } + #[test] fn extended_without_long() { if xattr::feature_implemented() { From a4459da6adbf31dcabfbcb5d165d8d9b42b6949d Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Tue, 10 Mar 2015 19:00:52 +0100 Subject: [PATCH 3/4] "`--group` is useless without `--long`" --- src/options.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/options.rs b/src/options.rs index ec015f9..b352c66 100644 --- a/src/options.rs +++ b/src/options.rs @@ -281,6 +281,9 @@ impl View { else if matches.opt_present("tree") { Err(Misfire::Useless("tree", false, "long")) } + else if matches.opt_present("group") { + Err(Misfire::Useless("group", false, "long")) + } else if matches.opt_present("level") && !matches.opt_present("recurse") { Err(Misfire::Useless2("level", "recurse", "tree")) } @@ -629,6 +632,12 @@ mod test { assert_eq!(opts.unwrap_err(), Misfire::Useless("header", false, "long")) } + #[test] + fn just_group() { + let opts = Options::getopts(&[ "--group".to_string() ]); + assert_eq!(opts.unwrap_err(), Misfire::Useless("group", false, "long")) + } + #[test] fn just_inode() { let opts = Options::getopts(&[ "--inode".to_string() ]); From 0359f19ca47b65226f7f7ddbd9a50f2b5252fc52 Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Tue, 10 Mar 2015 19:06:03 +0100 Subject: [PATCH 4/4] Mention `--git` in Readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7981ecf..aed2be5 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ - **-B**, **--bytes**: list file sizes in bytes, without prefixes - **-d**, **--list-dirs**: list directories as regular files - **-g**, **--group**: show group as well as user +- **--git**: show git status (depends on libgit2, see below) - **-h**, **--header**: show a header row - **-H**, **--links**: show number of hard links column - **-i**, **--inode**: show inode number column