Allow xattrs to be shown in --tree without --long

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.
This commit is contained in:
Benjamin Sago 2017-08-06 12:02:17 +01:00
parent b5bcf22612
commit 89540edb22
5 changed files with 119 additions and 17 deletions

View File

@ -159,7 +159,6 @@ mod test {
use super::{Options, Misfire, flags}; use super::{Options, Misfire, flags};
use std::ffi::OsString; use std::ffi::OsString;
use fs::filter::{SortField, SortCase}; use fs::filter::{SortField, SortCase};
use fs::feature::xattr;
/// Creates an `OSStr` (used in tests) /// Creates an `OSStr` (used in tests)
#[cfg(test)] #[cfg(test)]
@ -274,13 +273,4 @@ mod test {
let opts = Options::getopts(&args); let opts = Options::getopts(&args);
assert_eq!(opts.unwrap_err(), Misfire::Useless(&flags::GIT, false, &flags::LONG)) 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))
}
}
} }

View File

@ -61,9 +61,6 @@ impl Mode {
else if matches.has(&flags::LEVEL) && !matches.has(&flags::RECURSE) && !matches.has(&flags::TREE) { else if matches.has(&flags::LEVEL) && !matches.has(&flags::RECURSE) && !matches.has(&flags::TREE) {
Err(Useless2(&flags::LEVEL, &flags::RECURSE, &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 { else {
Ok(()) Ok(())
} }
@ -83,7 +80,7 @@ impl Mode {
let details = details::Options { let details = details::Options {
table: None, table: None,
header: false, header: false,
xattr: false, xattr: xattr::ENABLED && matches.has(&flags::EXTENDED),
}; };
Ok(Mode::Details(details)) Ok(Mode::Details(details))
@ -106,7 +103,7 @@ impl Mode {
let details = details::Options { let details = details::Options {
table: None, table: None,
header: false, header: false,
xattr: false, xattr: xattr::ENABLED && matches.has(&flags::EXTENDED),
}; };
Ok(Mode::Details(details)) Ok(Mode::Details(details))

57
xtests/attributes_dir Normal file
View File

@ -0,0 +1,57 @@
/testcases/attributes
├── dirs
│ ├── no-xattrs_empty
│ ├── no-xattrs_empty_forbidden
│ │ └── <Permission denied (os error 13)>
│ ├── no-xattrs_one-file
│ │ └── file-in-question
│ ├── no-xattrs_one-file_forbidden
│ │ └── <Permission denied (os error 13)>
│ ├── no-xattrs_two-files
│ │ ├── that-file
│ │ └── this-file
│ ├── no-xattrs_two-files_forbidden
│ │ └── <Permission denied (os error 13)>
│ ├── one-xattr_empty
│ │ └── user.greeting (len 5)
│ ├── one-xattr_empty_forbidden
│ │ └── <Permission denied (os error 13)>
│ ├── one-xattr_one-file
│ │ ├── user.greeting (len 5)
│ │ └── file-in-question
│ ├── one-xattr_one-file_forbidden
│ │ └── <Permission denied (os error 13)>
│ ├── one-xattr_two-files
│ │ ├── user.greeting (len 5)
│ │ ├── that-file
│ │ └── this-file
│ ├── one-xattr_two-files_forbidden
│ │ └── <Permission denied (os error 13)>
│ ├── two-xattrs_empty
│ │ ├── user.greeting (len 5)
│ │ └── user.another_greeting (len 2)
│ ├── two-xattrs_empty_forbidden
│ │ └── <Permission denied (os error 13)>
│ ├── two-xattrs_one-file
│ │ ├── user.greeting (len 5)
│ │ ├── user.another_greeting (len 2)
│ │ └── file-in-question
│ ├── two-xattrs_one-file_forbidden
│ │ └── <Permission denied (os error 13)>
│ ├── two-xattrs_two-files
│ │ ├── user.greeting (len 5)
│ │ ├── user.another_greeting (len 2)
│ │ ├── that-file
│ │ └── this-file
│ └── two-xattrs_two-files_forbidden
│ └── <Permission denied (os error 13)>
└── 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

56
xtests/attributes_files Normal file
View File

@ -0,0 +1,56 @@
/testcases/attributes/dirs
├── no-xattrs_empty
├── no-xattrs_empty_forbidden
│ └── <Permission denied (os error 13)>
├── no-xattrs_one-file
│ └── file-in-question
├── no-xattrs_one-file_forbidden
│ └── <Permission denied (os error 13)>
├── no-xattrs_two-files
│ ├── that-file
│ └── this-file
├── no-xattrs_two-files_forbidden
│ └── <Permission denied (os error 13)>
├── one-xattr_empty
│ └── user.greeting (len 5)
├── one-xattr_empty_forbidden
│ └── <Permission denied (os error 13)>
├── one-xattr_one-file
│ ├── user.greeting (len 5)
│ └── file-in-question
├── one-xattr_one-file_forbidden
│ └── <Permission denied (os error 13)>
├── one-xattr_two-files
│ ├── user.greeting (len 5)
│ ├── that-file
│ └── this-file
├── one-xattr_two-files_forbidden
│ └── <Permission denied (os error 13)>
├── two-xattrs_empty
│ ├── user.greeting (len 5)
│ └── user.another_greeting (len 2)
├── two-xattrs_empty_forbidden
│ └── <Permission denied (os error 13)>
├── two-xattrs_one-file
│ ├── user.greeting (len 5)
│ ├── user.another_greeting (len 2)
│ └── file-in-question
├── two-xattrs_one-file_forbidden
│ └── <Permission denied (os error 13)>
├── two-xattrs_two-files
│ ├── user.greeting (len 5)
│ ├── user.another_greeting (len 2)
│ ├── that-file
│ └── this-file
└── two-xattrs_two-files_forbidden
 └── <Permission denied (os error 13)>
/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

View File

@ -57,8 +57,10 @@ COLUMNS=200 $exa $testcases/files/* -lG | diff -q - $results/files_star_lG_200
# Attributes # Attributes
# (there are many tests, but they're all done in one go) # (there are many tests, but theyre all done in one go)
$exa $testcases/attributes -l@T | diff -q - $results/attributes || exit 1 $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 # UIDs and GIDs