From 89540edb22bffc9903dae46326cb828aa793307b Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Sun, 6 Aug 2017 12:02:17 +0100 Subject: [PATCH] Allow xattrs to be shown in --tree without --long MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This restriction was originally only there because a standalone --tree wasn’t a thing. Now it’s there, there’s no reason to forbid the combination. --- src/options/mod.rs | 10 -------- src/options/view.rs | 7 ++--- xtests/attributes_dir | 57 +++++++++++++++++++++++++++++++++++++++++ xtests/attributes_files | 56 ++++++++++++++++++++++++++++++++++++++++ xtests/run.sh | 6 +++-- 5 files changed, 119 insertions(+), 17 deletions(-) create mode 100644 xtests/attributes_dir create mode 100644 xtests/attributes_files diff --git a/src/options/mod.rs b/src/options/mod.rs index 0881f0b..d488381 100644 --- a/src/options/mod.rs +++ b/src/options/mod.rs @@ -159,7 +159,6 @@ mod test { use super::{Options, Misfire, flags}; use std::ffi::OsString; use fs::filter::{SortField, SortCase}; - use fs::feature::xattr; /// Creates an `OSStr` (used in tests) #[cfg(test)] @@ -274,13 +273,4 @@ mod test { let opts = Options::getopts(&args); assert_eq!(opts.unwrap_err(), Misfire::Useless(&flags::GIT, false, &flags::LONG)) } - - #[test] - fn extended_without_long() { - if xattr::ENABLED { - let args = [ os("--extended") ]; - let opts = Options::getopts(&args); - assert_eq!(opts.unwrap_err(), Misfire::Useless(&flags::EXTENDED, false, &flags::LONG)) - } - } } diff --git a/src/options/view.rs b/src/options/view.rs index 1487fdc..e9e81fc 100644 --- a/src/options/view.rs +++ b/src/options/view.rs @@ -61,9 +61,6 @@ impl Mode { else if matches.has(&flags::LEVEL) && !matches.has(&flags::RECURSE) && !matches.has(&flags::TREE) { Err(Useless2(&flags::LEVEL, &flags::RECURSE, &flags::TREE)) } - else if xattr::ENABLED && matches.has(&flags::EXTENDED) { - Err(Useless(&flags::EXTENDED, false, &flags::LONG)) - } else { Ok(()) } @@ -83,7 +80,7 @@ impl Mode { let details = details::Options { table: None, header: false, - xattr: false, + xattr: xattr::ENABLED && matches.has(&flags::EXTENDED), }; Ok(Mode::Details(details)) @@ -106,7 +103,7 @@ impl Mode { let details = details::Options { table: None, header: false, - xattr: false, + xattr: xattr::ENABLED && matches.has(&flags::EXTENDED), }; Ok(Mode::Details(details)) diff --git a/xtests/attributes_dir b/xtests/attributes_dir new file mode 100644 index 0000000..13ce6ee --- /dev/null +++ b/xtests/attributes_dir @@ -0,0 +1,57 @@ +/testcases/attributes +├── dirs +│ ├── no-xattrs_empty +│ ├── no-xattrs_empty_forbidden +│ │ └──  +│ ├── no-xattrs_one-file +│ │ └── file-in-question +│ ├── no-xattrs_one-file_forbidden +│ │ └──  +│ ├── no-xattrs_two-files +│ │ ├── that-file +│ │ └── this-file +│ ├── no-xattrs_two-files_forbidden +│ │ └──  +│ ├── one-xattr_empty +│ │ └── user.greeting (len 5) +│ ├── one-xattr_empty_forbidden +│ │ └──  +│ ├── one-xattr_one-file +│ │ ├── user.greeting (len 5) +│ │ └── file-in-question +│ ├── one-xattr_one-file_forbidden +│ │ └──  +│ ├── one-xattr_two-files +│ │ ├── user.greeting (len 5) +│ │ ├── that-file +│ │ └── this-file +│ ├── one-xattr_two-files_forbidden +│ │ └──  +│ ├── two-xattrs_empty +│ │ ├── user.greeting (len 5) +│ │ └── user.another_greeting (len 2) +│ ├── two-xattrs_empty_forbidden +│ │ └──  +│ ├── two-xattrs_one-file +│ │ ├── user.greeting (len 5) +│ │ ├── user.another_greeting (len 2) +│ │ └── file-in-question +│ ├── two-xattrs_one-file_forbidden +│ │ └──  +│ ├── two-xattrs_two-files +│ │ ├── user.greeting (len 5) +│ │ ├── user.another_greeting (len 2) +│ │ ├── that-file +│ │ └── this-file +│ └── two-xattrs_two-files_forbidden +│ └──  +└── files + ├── no-xattrs + ├── no-xattrs_forbidden + ├── one-xattr + │ └── user.greeting (len 5) + ├── one-xattr_forbidden + ├── two-xattrs + │ ├── user.greeting (len 5) + │ └── user.another_greeting (len 2) + └── two-xattrs_forbidden diff --git a/xtests/attributes_files b/xtests/attributes_files new file mode 100644 index 0000000..92d94b6 --- /dev/null +++ b/xtests/attributes_files @@ -0,0 +1,56 @@ +/testcases/attributes/dirs +├── no-xattrs_empty +├── no-xattrs_empty_forbidden +│ └──  +├── no-xattrs_one-file +│ └── file-in-question +├── no-xattrs_one-file_forbidden +│ └──  +├── no-xattrs_two-files +│ ├── that-file +│ └── this-file +├── no-xattrs_two-files_forbidden +│ └──  +├── one-xattr_empty +│ └── user.greeting (len 5) +├── one-xattr_empty_forbidden +│ └──  +├── one-xattr_one-file +│ ├── user.greeting (len 5) +│ └── file-in-question +├── one-xattr_one-file_forbidden +│ └──  +├── one-xattr_two-files +│ ├── user.greeting (len 5) +│ ├── that-file +│ └── this-file +├── one-xattr_two-files_forbidden +│ └──  +├── two-xattrs_empty +│ ├── user.greeting (len 5) +│ └── user.another_greeting (len 2) +├── two-xattrs_empty_forbidden +│ └──  +├── two-xattrs_one-file +│ ├── user.greeting (len 5) +│ ├── user.another_greeting (len 2) +│ └── file-in-question +├── two-xattrs_one-file_forbidden +│ └──  +├── two-xattrs_two-files +│ ├── user.greeting (len 5) +│ ├── user.another_greeting (len 2) +│ ├── that-file +│ └── this-file +└── two-xattrs_two-files_forbidden + └──  +/testcases/attributes/files +├── no-xattrs +├── no-xattrs_forbidden +├── one-xattr +│ └── user.greeting (len 5) +├── one-xattr_forbidden +├── two-xattrs +│ ├── user.greeting (len 5) +│ └── user.another_greeting (len 2) +└── two-xattrs_forbidden diff --git a/xtests/run.sh b/xtests/run.sh index 1b9d0b3..9425585 100755 --- a/xtests/run.sh +++ b/xtests/run.sh @@ -57,8 +57,10 @@ COLUMNS=200 $exa $testcases/files/* -lG | diff -q - $results/files_star_lG_200 # Attributes -# (there are many tests, but they're all done in one go) -$exa $testcases/attributes -l@T | diff -q - $results/attributes || exit 1 +# (there are many tests, but they’re all done in one go) +$exa $testcases/attributes -l@T | diff -q - $results/attributes || exit 1 +$exa $testcases/attributes -@T | diff -q - $results/attributes_dir || exit 1 +$exa $testcases/attributes/* -@T | diff -q - $results/attributes_files || exit 1 # UIDs and GIDs