Răsfoiți Sursa

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.
Benjamin Sago 8 ani în urmă
părinte
comite
89540edb22
5 a modificat fișierele cu 119 adăugiri și 17 ștergeri
  1. 0 10
      src/options/mod.rs
  2. 2 5
      src/options/view.rs
  3. 57 0
      xtests/attributes_dir
  4. 56 0
      xtests/attributes_files
  5. 4 2
      xtests/run.sh

+ 0 - 10
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))
-        }
-    }
 }

+ 2 - 5
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))

+ 57 - 0
xtests/attributes_dir

@@ -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 - 0
xtests/attributes_files

@@ -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

+ 4 - 2
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