Skip to content
Myr

Merge pull request #812 from yyogo/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Append trailing path separators to directories

authored by David Peter · committed by GitHub · parents dcde6d3, 41affe1 · Browse files · 10 files+282 added−197 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

10 files+282 added−197 removed

  • tests:+97 added−97 removed
  • other:+185 added−100 removed

10 files+282 added−197 removed

modified:src/exec/job.rs+14 added-12 removed
1use std::path::PathBuf;1use std::sync::mpsc::Receiver;2use std::sync::{Arc, Mutex};34use crate::dir_entry::DirEntry;5use crate::error::print_error;6use crate::exit_codes::{merge_exitcodes, ExitCode};7use crate::walk::WorkerResult;8
15 unmodified lines
24 let lock = rx.lock().unwrap();2526 // Obtain the next result from the receiver, else if the channel27 // has closed, exit from the loop28 let value: PathBuf = match lock.recv() {29 Ok(WorkerResult::Entry(path)) => path,28 let dir_entry: DirEntry = match lock.recv() {29 Ok(WorkerResult::Entry(dir_entry)) => dir_entry,30 Ok(WorkerResult::Error(err)) => {31 if show_filesystem_errors {32 print_error(err.to_string());33 }
4 unmodified lines
3839 // Drop the lock so that other threads can read from the receiver.40 drop(lock);41 // Generate a command, execute it and store its exit code.42 results.push(cmd.execute(&value, Arc::clone(&out_perm), buffer_output))42 results.push(cmd.execute(dir_entry.path(), Arc::clone(&out_perm), buffer_output))43 }44 // Returns error in case of any error.45 merge_exitcodes(results)46}
3 unmodified lines
50 cmd: &CommandSet,51 show_filesystem_errors: bool,52 limit: usize,53) -> ExitCode {54 let paths = rx55 .into_iter()54 let paths = rx.iter().filter_map(|value| match value {55 WorkerResult::Entry(path) => Some(path),56 WorkerResult::Error(err) => {57 if show_filesystem_errors {58 print_error(err.to_string());56 .filter_map(|worker_result| match worker_result {57 WorkerResult::Entry(dir_entry) => Some(dir_entry.into_path()),58 WorkerResult::Error(err) => {59 if show_filesystem_errors {60 print_error(err.to_string());61 }62 None63 }60 None61 }62 });64 });65 if limit == 0 {66 // no limit67 return cmd.execute_batch(paths);68 }
10 unmodified lines
modified:src/config.rs+3 added
109 unmodified lines
110111 /// The separator used to print file paths.112 pub path_separator: Option<String>,113114 /// The actual separator, either the system default separator or `path_separator`115 pub actual_path_separator: String,116117 /// The maximum number of search results118 pub max_results: Option<usize>,119120 /// Whether or not to strip the './' prefix for search results
2 unmodified lines
added:src/dir_entry.rs+92 added
1use std::{2 fs::{FileType, Metadata},3 path::{Path, PathBuf},4};56use once_cell::unsync::OnceCell;78enum DirEntryInner {9 Normal(ignore::DirEntry),10 BrokenSymlink(PathBuf),11}1213pub struct DirEntry {14 inner: DirEntryInner,15 metadata: OnceCell<Option<Metadata>>,16}1718impl DirEntry {19 #[inline]20 pub fn normal(e: ignore::DirEntry) -> Self {21 Self {22 inner: DirEntryInner::Normal(e),23 metadata: OnceCell::new(),24 }25 }2627 pub fn broken_symlink(path: PathBuf) -> Self {28 Self {29 inner: DirEntryInner::BrokenSymlink(path),30 metadata: OnceCell::new(),31 }32 }3334 pub fn path(&self) -> &Path {35 match &self.inner {36 DirEntryInner::Normal(e) => e.path(),37 DirEntryInner::BrokenSymlink(pathbuf) => pathbuf.as_path(),38 }39 }4041 pub fn into_path(self) -> PathBuf {42 match self.inner {43 DirEntryInner::Normal(e) => e.into_path(),44 DirEntryInner::BrokenSymlink(p) => p,45 }46 }4748 pub fn file_type(&self) -> Option<FileType> {49 match &self.inner {50 DirEntryInner::Normal(e) => e.file_type(),51 DirEntryInner::BrokenSymlink(_) => self.metadata().map(|m| m.file_type()),52 }53 }5455 pub fn metadata(&self) -> Option<&Metadata> {56 self.metadata57 .get_or_init(|| match &self.inner {58 DirEntryInner::Normal(e) => e.metadata().ok(),59 DirEntryInner::BrokenSymlink(path) => path.symlink_metadata().ok(),60 })61 .as_ref()62 }6364 pub fn depth(&self) -> Option<usize> {65 match &self.inner {66 DirEntryInner::Normal(e) => Some(e.depth()),67 DirEntryInner::BrokenSymlink(_) => None,68 }69 }70}7172impl PartialEq for DirEntry {73 #[inline]74 fn eq(&self, other: &Self) -> bool {75 self.path() == other.path()76 }77}78impl Eq for DirEntry {}7980impl PartialOrd for DirEntry {81 #[inline]82 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {83 self.path().partial_cmp(other.path())84 }85}8687impl Ord for DirEntry {88 #[inline]89 fn cmp(&self, other: &Self) -> std::cmp::Ordering {90 self.path().cmp(other.path())91 }92}
modified:src/filesystem.rs+2 added-2 removed
7 unmodified lines
8use std::path::{Path, PathBuf};910use normpath::PathExt;1112use crate::walk;12use crate::dir_entry;1314pub fn path_absolute_form(path: &Path) -> io::Result<PathBuf> {15 if path.is_absolute() {16 return Ok(path.to_path_buf());
33 unmodified lines
50pub fn is_executable(_: &fs::Metadata) -> bool {51 false52}5354pub fn is_empty(entry: &walk::DirEntry) -> bool {54pub fn is_empty(entry: &dir_entry::DirEntry) -> bool {55 if let Some(file_type) = entry.file_type() {56 if file_type.is_dir() {57 if let Ok(mut entries) = fs::read_dir(entry.path()) {58 entries.next().is_none()
90 unmodified lines
modified:src/filetypes.rs+2 added-2 removed
1use crate::dir_entry;2use crate::filesystem;2use crate::walk;34/// Whether or not to show5#[derive(Default)]6pub struct FileTypes {
6 unmodified lines
13 pub empty_only: bool,14}1516impl FileTypes {17 pub fn should_ignore(&self, entry: &walk::DirEntry) -> bool {17 pub fn should_ignore(&self, entry: &dir_entry::DirEntry) -> bool {18 if let Some(ref entry_type) = entry.file_type() {19 (!self.files && entry_type.is_file())20 || (!self.directories && entry_type.is_dir())21 || (!self.symlinks && entry_type.is_symlink())
18 unmodified lines
modified:src/main.rs+5 added
1mod app;2mod config;3mod dir_entry;4mod error;5mod exec;6mod exit_codes;7mod filesystem;
213 unmodified lines
221222 let path_separator = matches223 .value_of("path-separator")224 .map_or_else(filesystem::default_path_separator, |s| Some(s.to_owned()));225 let actual_path_separator = path_separator226 .clone()227 .unwrap_or_else(|| std::path::MAIN_SEPARATOR.to_string());228 check_path_separator_length(path_separator.as_deref())?;229230 let size_limits = extract_size_limits(&matches)?;231 let time_constraints = extract_time_constraints(&matches)?;
138 unmodified lines
370 #[cfg(unix)]371 owner_constraint,372 show_filesystem_errors: matches.is_present("show-errors"),373 path_separator,374 actual_path_separator,375 max_results: matches376 .value_of("max-results")377 .map(|n| n.parse::<usize>())378 .transpose()
191 unmodified lines
modified:src/output.rs+56 added-17 removed
3 unmodified lines
45use lscolors::{Indicator, LsColors, Style};67use crate::config::Config;8use crate::dir_entry::DirEntry;9use crate::error::print_error;10use crate::exit_codes::ExitCode;11use crate::filesystem::strip_current_dir;1213fn replace_path_separator(path: &str, new_path_separator: &str) -> String {14 path.replace(std::path::MAIN_SEPARATOR, new_path_separator)15}1616// TODO: this function is performance critical and can probably be optimized17pub fn print_entry<W: Write>(stdout: &mut W, entry: &Path, config: &Config) {18 let path = if config.strip_cwd_prefix {19 strip_current_dir(entry)17fn stripped_path<'a>(entry: &'a DirEntry, config: &Config) -> &'a Path {18 let path = entry.path();19 if config.strip_cwd_prefix {20 strip_current_dir(path)21 } else {21 entry22 };22 path23 }24}2526// TODO: this function is performance critical and can probably be optimized27pub fn print_entry<W: Write>(stdout: &mut W, entry: &DirEntry, config: &Config) {28 let r = if let Some(ref ls_colors) = config.ls_colors {25 print_entry_colorized(stdout, path, config, ls_colors)29 print_entry_colorized(stdout, entry, config, ls_colors)30 } else {27 print_entry_uncolorized(stdout, path, config)31 print_entry_uncolorized(stdout, entry, config)32 };3334 if let Err(e) = r {35 if e.kind() == ::std::io::ErrorKind::BrokenPipe {
5 unmodified lines
41 }42 }43}4445// Display a trailing slash if the path is a directory and the config option is enabled.46// If the path_separator option is set, display that instead.47// The trailing slash will not be colored.48#[inline]49fn print_trailing_slash<W: Write>(50 stdout: &mut W,51 entry: &DirEntry,52 config: &Config,53 style: Option<&Style>,54) -> io::Result<()> {55 if entry.file_type().map_or(false, |ft| ft.is_dir()) {56 write!(57 stdout,58 "{}",59 style60 .map(Style::to_ansi_term_style)61 .unwrap_or_default()62 .paint(&config.actual_path_separator)63 )?;64 }65 Ok(())66}6768// TODO: this function is performance critical and can probably be optimized69fn print_entry_colorized<W: Write>(70 stdout: &mut W,44 path: &Path,71 entry: &DirEntry,72 config: &Config,73 ls_colors: &LsColors,74) -> io::Result<()> {75 // Split the path between the parent and the last component76 let mut offset = 0;77 let path = stripped_path(entry, config);78 let path_str = path.to_string_lossy();7980 if let Some(parent) = path.parent() {81 offset = parent.to_string_lossy().len();
19 unmodified lines
101 write!(stdout, "{}", style.paint(parent_str))?;102 }103104 let style = ls_colors77 .style_for_path(path)105 .style_for_path_with_metadata(path, entry.metadata())106 .map(Style::to_ansi_term_style)107 .unwrap_or_default();108 write!(stdout, "{}", style.paint(&path_str[offset..]))?;109110 print_trailing_slash(111 stdout,112 entry,113 config,114 ls_colors.style_for_indicator(Indicator::Directory),115 )?;116117 if config.null_separator {118 write!(stdout, "\0")?;119 } else {120 writeln!(stdout)?;
4 unmodified lines
125126// TODO: this function is performance critical and can probably be optimized127fn print_entry_uncolorized_base<W: Write>(128 stdout: &mut W,94 path: &Path,129 entry: &DirEntry,130 config: &Config,131) -> io::Result<()> {132 let separator = if config.null_separator { "\0" } else { "\n" };133 let path = stripped_path(entry, config);134135 let mut path_string = path.to_string_lossy();136 if let Some(ref separator) = config.path_separator {137 *path_string.to_mut() = replace_path_separator(&path_string, separator);138 }103 write!(stdout, "{}{}", path_string, separator)139 write!(stdout, "{}", path_string)?;140 print_trailing_slash(stdout, entry, config, None)?;141 write!(stdout, "{}", separator)142}143144#[cfg(not(unix))]145fn print_entry_uncolorized<W: Write>(146 stdout: &mut W,109 path: &Path,147 entry: &DirEntry,148 config: &Config,149) -> io::Result<()> {112 print_entry_uncolorized_base(stdout, path, config)150 print_entry_uncolorized_base(stdout, entry, config)151}152153#[cfg(unix)]154fn print_entry_uncolorized<W: Write>(155 stdout: &mut W,118 path: &Path,156 entry: &DirEntry,157 config: &Config,158) -> io::Result<()> {159 use std::os::unix::ffi::OsStrExt;160161 if config.interactive_terminal || config.path_separator.is_some() {162 // Fall back to the base implementation125 print_entry_uncolorized_base(stdout, path, config)163 print_entry_uncolorized_base(stdout, entry, config)164 } else {165 // Print path as raw bytes, allowing invalid UTF-8 filenames to be passed to other processes166 let separator = if config.null_separator { b"\0" } else { b"\n" };129 stdout.write_all(path.as_os_str().as_bytes())?;167 stdout.write_all(stripped_path(entry, config).as_os_str().as_bytes())?;168 print_trailing_slash(stdout, entry, config, None)?;169 stdout.write_all(separator)170 }171}
modified:src/walk.rs+10 added-67 removed
1use std::ffi::OsStr;2use std::fs::{FileType, Metadata};2use std::io;3use std::mem;5use std::path::{Path, PathBuf};4use std::path::PathBuf;5use std::sync::atomic::{AtomicBool, Ordering};6use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender};7use std::sync::{Arc, Mutex};8use std::thread;
2 unmodified lines
1112use anyhow::{anyhow, Result};13use ignore::overrides::OverrideBuilder;14use ignore::{self, WalkBuilder};16use once_cell::unsync::OnceCell;15use regex::bytes::Regex;1617use crate::config::Config;18use crate::dir_entry::DirEntry;19use crate::error::print_error;20use crate::exec;21use crate::exit_codes::{merge_exitcodes, ExitCode};22use crate::filesystem;
11 unmodified lines
34}3536/// The Worker threads can result in a valid entry having PathBuf or an error.37pub enum WorkerResult {39 Entry(PathBuf),38 Entry(DirEntry),39 Error(ignore::Error),40}4142/// Maximum size of the output buffer before flushing results to the console
136 unmodified lines
179 mode: ReceiverMode,180 /// The deadline to switch to streaming mode.181 deadline: Instant,182 /// The buffer of quickly received paths.184 buffer: Vec<PathBuf>,183 buffer: Vec<DirEntry>,184 /// Result count.185 num_results: usize,186}187
52 unmodified lines
240241 /// Wait for a result or state change.242 fn poll(&mut self) -> Result<(), ExitCode> {243 match self.recv() {245 Ok(WorkerResult::Entry(path)) => {244 Ok(WorkerResult::Entry(dir_entry)) => {245 if self.config.quiet {246 return Err(ExitCode::HasResults(true));247 }248249 match self.mode {250 ReceiverMode::Buffering => {252 self.buffer.push(path);251 self.buffer.push(dir_entry);252 if self.buffer.len() > MAX_BUFFER_LENGTH {253 self.stream()?;254 }255 }256 ReceiverMode::Streaming => {258 self.print(&path)?;257 self.print(&dir_entry)?;258 self.flush()?;259 }260 }261
20 unmodified lines
282 Ok(())283 }284285 /// Output a path.287 fn print(&mut self, path: &Path) -> Result<(), ExitCode> {288 output::print_entry(&mut self.stdout, path, &self.config);286 fn print(&mut self, entry: &DirEntry) -> Result<(), ExitCode> {287 output::print_entry(&mut self.stdout, entry, &self.config);288289 if self.interrupt_flag.load(Ordering::Relaxed) {290 // Ignore any errors on flush, because we're about to exit anyway291 let _ = self.flush();
102 unmodified lines
394 }395 })396}397399enum DirEntryInner {400 Normal(ignore::DirEntry),401 BrokenSymlink(PathBuf),402}403404pub struct DirEntry {405 inner: DirEntryInner,406 metadata: OnceCell<Option<Metadata>>,407}408409impl DirEntry {410 fn normal(e: ignore::DirEntry) -> Self {411 Self {412 inner: DirEntryInner::Normal(e),413 metadata: OnceCell::new(),414 }415 }416417 fn broken_symlink(path: PathBuf) -> Self {418 Self {419 inner: DirEntryInner::BrokenSymlink(path),420 metadata: OnceCell::new(),421 }422 }423424 pub fn path(&self) -> &Path {425 match &self.inner {426 DirEntryInner::Normal(e) => e.path(),427 DirEntryInner::BrokenSymlink(pathbuf) => pathbuf.as_path(),428 }429 }430431 pub fn file_type(&self) -> Option<FileType> {432 match &self.inner {433 DirEntryInner::Normal(e) => e.file_type(),434 DirEntryInner::BrokenSymlink(_) => self.metadata().map(|m| m.file_type()),435 }436 }437438 pub fn metadata(&self) -> Option<&Metadata> {439 self.metadata440 .get_or_init(|| match &self.inner {441 DirEntryInner::Normal(e) => e.metadata().ok(),442 DirEntryInner::BrokenSymlink(path) => path.symlink_metadata().ok(),443 })444 .as_ref()445 }446447 pub fn depth(&self) -> Option<usize> {448 match &self.inner {449 DirEntryInner::Normal(e) => Some(e.depth()),450 DirEntryInner::BrokenSymlink(_) => None,451 }452 }453}454398fn spawn_senders(399 config: &Arc<Config>,400 quit_flag: &Arc<AtomicBool>,401 pattern: Arc<Regex>,
142 unmodified lines
544 return ignore::WalkState::Continue;545 }546 }547605 let send_result = tx_thread.send(WorkerResult::Entry(entry_path.to_owned()));548 let send_result = tx_thread.send(WorkerResult::Entry(entry));549550 if send_result.is_err() {551 return ignore::WalkState::Quit;552 }
10 unmodified lines
modified:tests/tests.rs+97 added-97 removed
70 unmodified lines
71 ./one/b.foo72 ./one/two/c.foo73 ./one/two/C.Foo274 ./one/two/three/d.foo75 ./one/two/three/directory_foo",75 ./one/two/three/directory_foo/",76 );77}7879/// Test each pattern type with an empty pattern.
1 unmodified line
81fn test_empty_pattern() {82 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);83 let expected = "./a.foo84 ./e1 e285 ./one85 ./one/86 ./one/b.foo87 ./one/two87 ./one/two/88 ./one/two/c.foo89 ./one/two/C.Foo290 ./one/two/three90 ./one/two/three/91 ./one/two/three/d.foo92 ./one/two/three/directory_foo92 ./one/two/three/directory_foo/93 ./symlink";9495 te.assert_output(&["--regex"], expected);96 te.assert_output(&["--fixed-strings"], expected);
73 unmodified lines
170 "one/b.foo171 one/two/c.foo172 one/two/C.Foo2173 one/two/three/d.foo174 one/two/three/directory_foo",174 one/two/three/directory_foo/",175 );176177 te.assert_output(178 &["foo", "one/two/three"],179 "one/two/three/d.foo180 one/two/three/directory_foo",180 one/two/three/directory_foo/",181 );182183 te.assert_output_subdirectory(184 "one/two",184 "one/two/",185 &["foo", "../../"],186 "../../a.foo187 ../../one/b.foo188 ../../one/two/c.foo189 ../../one/two/C.Foo2190 ../../one/two/three/d.foo191 ../../one/two/three/directory_foo",191 ../../one/two/three/directory_foo/",192 );193194 te.assert_output_subdirectory(195 "one/two/three",196 &["", ".."],197 "../c.foo198 ../C.Foo2199 ../three199 ../three/200 ../three/d.foo201 ../three/directory_foo",201 ../three/directory_foo/",202 );203}204205/// Regex searches
180 unmodified lines
386 "--full-path",387 &format!("^{prefix}.*three.*foo$", prefix = prefix),388 ],389 "./one/two/three/d.foo390 ./one/two/three/directory_foo",390 ./one/two/three/directory_foo/",391 );392}393394/// Hidden files (--hidden)
8 unmodified lines
403 ./one/b.foo404 ./one/two/c.foo405 ./one/two/C.Foo2406 ./one/two/three/d.foo407 ./one/two/three/directory_foo",407 ./one/two/three/directory_foo/",408 );409}410411/// Hidden file attribute on Windows
31 unmodified lines
443 ./one/b.foo444 ./one/two/c.foo445 ./one/two/C.Foo2446 ./one/two/three/d.foo447 ./one/two/three/directory_foo",447 ./one/two/three/directory_foo/",448 );449450 te.assert_output(451 &["--hidden", "--no-ignore", "foo"],
4 unmodified lines
456 ./one/b.foo457 ./one/two/c.foo458 ./one/two/C.Foo2459 ./one/two/three/d.foo460 ./one/two/three/directory_foo",460 ./one/two/three/directory_foo/",461 );462}463464/// .gitignore and .fdignore
144 unmodified lines
609 ./one/b.foo610 ./one/two/c.foo611 ./one/two/C.Foo2612 ./one/two/three/d.foo613 ./one/two/three/directory_foo",613 ./one/two/three/directory_foo/",614 );615}616617/// Test that --no-ignore-vcs still respects .fdignored in parent directory
45 unmodified lines
663 ./one/b.foo664 ./one/two/c.foo665 ./one/two/C.Foo2666 ./one/two/three/d.foo667 ./one/two/three/directory_foo",667 ./one/two/three/directory_foo/",668 );669}670671/// Symlinks (--follow)
90 unmodified lines
762 ./one/b.fooNULL763 ./one/two/C.Foo2NULL764 ./one/two/c.fooNULL765 ./one/two/three/d.fooNULL766 ./one/two/three/directory_fooNULL",766 ./one/two/three/directory_foo/NULL",767 );768}769770/// Maximum depth (--max-depth)
4 unmodified lines
775 te.assert_output(776 &["--max-depth", "3"],777 "./a.foo778 ./e1 e2779 ./one779 ./one/780 ./one/b.foo781 ./one/two781 ./one/two/782 ./one/two/c.foo783 ./one/two/C.Foo2784 ./one/two/three784 ./one/two/three/785 ./symlink",786 );787788 te.assert_output(789 &["--max-depth", "2"],790 "./a.foo791 ./e1 e2792 ./one792 ./one/793 ./one/b.foo794 ./one/two794 ./one/two/795 ./symlink",796 );797798 te.assert_output(799 &["--max-depth", "1"],800 "./a.foo801 ./e1 e2802 ./one802 ./one/803 ./symlink",804 );805}806
5 unmodified lines
812 te.assert_output(813 &["--min-depth", "3"],814 "./one/two/c.foo815 ./one/two/C.Foo2816 ./one/two/three816 ./one/two/three/817 ./one/two/three/d.foo818 ./one/two/three/directory_foo",818 ./one/two/three/directory_foo/",819 );820821 te.assert_output(822 &["--min-depth", "4"],823 "./one/two/three/d.foo824 ./one/two/three/directory_foo",824 ./one/two/three/directory_foo/",825 );826}827828/// Exact depth (--exact-depth)
4 unmodified lines
833 te.assert_output(834 &["--exact-depth", "3"],835 "./one/two/c.foo836 ./one/two/C.Foo2837 ./one/two/three",837 ./one/two/three/",838 );839}840841/// Pruning (--prune)
11 unmodified lines
853 let te = TestEnv::new(dirs, files);854855 te.assert_output(856 &["foo"],857 "./foo857 "./foo/858 ./foo/foo.file859 ./foo/bar/foo.file860 ./bar/foo.file861 ./bar/foo861 ./bar/foo/862 ./bar/foo/foo.file863 ./baz/foo.file",864 );865866 te.assert_output(867 &["--prune", "foo"],868 "./foo869 ./bar/foo868 "./foo/869 ./bar/foo/870 ./bar/foo.file871 ./baz/foo.file",872 );873}
7 unmodified lines
881 &["--absolute-path"],882 &format!(883 "{abs_path}/a.foo884 {abs_path}/e1 e2885 {abs_path}/one885 {abs_path}/one/886 {abs_path}/one/b.foo887 {abs_path}/one/two887 {abs_path}/one/two/888 {abs_path}/one/two/c.foo889 {abs_path}/one/two/C.Foo2890 {abs_path}/one/two/three890 {abs_path}/one/two/three/891 {abs_path}/one/two/three/d.foo892 {abs_path}/one/two/three/directory_foo892 {abs_path}/one/two/three/directory_foo/893 {abs_path}/symlink",894 abs_path = &abs_path895 ),896 );
5 unmodified lines
902 {abs_path}/one/b.foo903 {abs_path}/one/two/c.foo904 {abs_path}/one/two/C.Foo2905 {abs_path}/one/two/three/d.foo906 {abs_path}/one/two/three/directory_foo",906 {abs_path}/one/two/three/directory_foo/",907 abs_path = &abs_path908 ),909 );910}
10 unmodified lines
921 {abs_path}/one/b.foo922 {abs_path}/one/two/c.foo923 {abs_path}/one/two/C.Foo2924 {abs_path}/one/two/three/d.foo925 {abs_path}/one/two/three/directory_foo",925 {abs_path}/one/two/three/directory_foo/",926 abs_path = &abs_path927 ),928 );929}
11 unmodified lines
941 {abs_path}/one/b.foo942 {abs_path}/one/two/c.foo943 {abs_path}/one/two/C.Foo2944 {abs_path}/one/two/three/d.foo945 {abs_path}/one/two/three/directory_foo",945 {abs_path}/one/two/three/directory_foo/",946 abs_path = &abs_path947 ),948 );949}
16 unmodified lines
966 te.assert_output(&["--type", "f", "e1"], "./e1 e2");967968 te.assert_output(969 &["--type", "d"],970 "./one971 ./one/two972 ./one/two/three973 ./one/two/three/directory_foo",970 "./one/971 ./one/two/972 ./one/two/three/973 ./one/two/three/directory_foo/",974 );975976 te.assert_output(977 &["--type", "d", "--type", "l"],978 "./one979 ./one/two980 ./one/two/three981 ./one/two/three/directory_foo978 "./one/979 ./one/two/980 ./one/two/three/981 ./one/two/three/directory_foo/982 ./symlink",983 );984985 te.assert_output(&["--type", "l"], "./symlink");
18 unmodified lines
10041005 te.assert_output(1006 &["--type", "executable", "--type", "directory"],1007 "./executable-file.sh1008 ./one1009 ./one/two1010 ./one/two/three1011 ./one/two/three/directory_foo",1008 ./one/1009 ./one/two/1010 ./one/two/three/1011 ./one/two/three/directory_foo/",1012 );1013}10141015/// Test `--type empty`
8 unmodified lines
10241025 te.assert_output(1026 &["--type", "empty"],1027 "./0_bytes.foo1028 ./dir_empty",1028 ./dir_empty/",1029 );10301031 te.assert_output(1032 &["--type", "empty", "--type", "file", "--type", "directory"],1033 "./0_bytes.foo1034 ./dir_empty",1034 ./dir_empty/",1035 );10361037 te.assert_output(&["--type", "empty", "--type", "file"], "./0_bytes.foo");10381039 te.assert_output(&["--type", "empty", "--type", "directory"], "./dir_empty");1039 te.assert_output(&["--type", "empty", "--type", "directory"], "./dir_empty/");1040}10411042/// File extension (--extension)1043#[test]
62 unmodified lines
11061107 te.assert_output(1108 &["^[^.]+$"],1109 "./aa1110 ./one1110 ./one/1111 ./one/bb1112 ./one/two1113 ./one/two/three1112 ./one/two/1113 ./one/two/three/1114 ./one/two/three/d1115 ./one/two/three/directory_foo1115 ./one/two/three/directory_foo/1116 ./symlink",1117 );11181119 te.assert_output(
31 unmodified lines
1151 &format!(1152 "{dir}/a.foo1153 {dir}/broken_symlink1154 {dir}/e1 e21155 {dir}/one1155 {dir}/one/1156 {dir}/one/b.foo1157 {dir}/one/two1157 {dir}/one/two/1158 {dir}/one/two/c.foo1159 {dir}/one/two/C.Foo21160 {dir}/one/two/three1160 {dir}/one/two/three/1161 {dir}/one/two/three/d.foo1162 {dir}/one/two/three/directory_foo1162 {dir}/one/two/three/directory_foo/1163 {dir}/symlink",1164 dir = &parent_parent1165 ),1166 );
10 unmodified lines
1177 &["--absolute-path"],1178 &format!(1179 "{abs_path}/{expected_path}/c.foo1180 {abs_path}/{expected_path}/C.Foo21181 {abs_path}/{expected_path}/three1181 {abs_path}/{expected_path}/three/1182 {abs_path}/{expected_path}/three/d.foo1183 {abs_path}/{expected_path}/three/directory_foo",1183 {abs_path}/{expected_path}/three/directory_foo/",1184 abs_path = &abs_path,1185 expected_path = expected_path1186 ),1187 );
7 unmodified lines
1195 &["", &format!("{abs_path}/symlink", abs_path = abs_path)],1196 &format!(1197 "{abs_path}/symlink/c.foo1198 {abs_path}/symlink/C.Foo21199 {abs_path}/symlink/three1199 {abs_path}/symlink/three/1200 {abs_path}/symlink/three/d.foo1201 {abs_path}/symlink/three/directory_foo",1201 {abs_path}/symlink/three/directory_foo/",1202 abs_path = &abs_path1203 ),1204 );1205}
13 unmodified lines
1219 "--full-path",1220 &format!("^{prefix}.*three", prefix = prefix),1221 ],1222 &format!(1223 "{abs_path}/{expected_path}/three1223 "{abs_path}/{expected_path}/three/1224 {abs_path}/{expected_path}/three/d.foo1225 {abs_path}/{expected_path}/three/directory_foo",1225 {abs_path}/{expected_path}/three/directory_foo/",1226 abs_path = &abs_path,1227 expected_path = expected_path1228 ),1229 );
10 unmodified lines
1240 &format!("^{prefix}.*symlink.*three", prefix = prefix),1241 &format!("{abs_path}/symlink", abs_path = abs_path),1242 ],1243 &format!(1244 "{abs_path}/symlink/three1244 "{abs_path}/symlink/three/1245 {abs_path}/symlink/three/d.foo1246 {abs_path}/symlink/three/directory_foo",1246 {abs_path}/symlink/three/directory_foo/",1247 abs_path = &abs_path1248 ),1249 );1250}
3 unmodified lines
1254 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);12551256 te.assert_output(1257 &["--exclude", "*.foo"],1258 "./one1259 ./one/two1258 "./one/1259 ./one/two/1260 ./one/two/C.Foo21261 ./one/two/three1262 ./one/two/three/directory_foo1261 ./one/two/three/1262 ./one/two/three/directory_foo/1263 ./e1 e21264 ./symlink",1265 );12661267 te.assert_output(1268 &["--exclude", "*.foo", "--exclude", "*.Foo2"],1269 "./one1270 ./one/two1271 ./one/two/three1272 ./one/two/three/directory_foo1269 "./one/1270 ./one/two/1271 ./one/two/three/1272 ./one/two/three/directory_foo/1273 ./e1 e21274 ./symlink",1275 );12761277 te.assert_output(1278 &["--exclude", "*.foo", "--exclude", "*.Foo2", "foo"],1279 "./one/two/three/directory_foo",1279 "./one/two/three/directory_foo/",1280 );12811282 te.assert_output(1283 &["--exclude", "one/two", "foo"],1283 &["--exclude", "one/two/", "foo"],1284 "./a.foo1285 ./one/b.foo",1286 );12871288 te.assert_output(1289 &["--exclude", "one/**/*.foo"],1290 "./a.foo1291 ./e1 e21292 ./one1293 ./one/two1292 ./one/1293 ./one/two/1294 ./one/two/C.Foo21295 ./one/two/three1296 ./one/two/three/directory_foo1295 ./one/two/three/1296 ./one/two/three/directory_foo/1297 ./symlink",1298 );1299}1300
564 unmodified lines
1865 "one=b.foo1866 one=two=c.foo1867 one=two=C.Foo21868 one=two=three=d.foo1869 one=two=three=directory_foo",1869 one=two=three=directory_foo=",1870 );1871}18721873#[test]
2 unmodified lines
18761877 te.assert_output(1878 &["--base-directory", "one"],1879 "./b.foo1880 ./two1880 ./two/1881 ./two/c.foo1882 ./two/C.Foo21883 ./two/three1883 ./two/three/1884 ./two/three/d.foo1885 ./two/three/directory_foo",1885 ./two/three/directory_foo/",1886 );18871888 te.assert_output(1889 &["--base-directory", "one/two", "foo"],1889 &["--base-directory", "one/two/", "foo"],1890 "./c.foo1891 ./C.Foo21892 ./three/d.foo1893 ./three/directory_foo",1893 ./three/directory_foo/",1894 );18951896 // Explicit root path1897 te.assert_output(1898 &["--base-directory", "one", "foo", "two"],1899 "two/c.foo1900 two/C.Foo21901 two/three/d.foo1902 two/three/directory_foo",1902 two/three/directory_foo/",1903 );19041905 // Ignore base directory when absolute path is used1906 let (te, abs_path) = get_test_env_with_abs_path(DEFAULT_DIRS, DEFAULT_FILES);1907 let abs_base_dir = &format!("{abs_path}/one/two", abs_path = &abs_path);1907 let abs_base_dir = &format!("{abs_path}/one/two/", abs_path = &abs_path);1908 te.assert_output(1909 &["--base-directory", abs_base_dir, "foo", &abs_path],1910 &format!(1911 "{abs_path}/a.foo1912 {abs_path}/one/b.foo1913 {abs_path}/one/two/c.foo1914 {abs_path}/one/two/C.Foo21915 {abs_path}/one/two/three/d.foo1916 {abs_path}/one/two/three/directory_foo",1916 {abs_path}/one/two/three/directory_foo/",1917 abs_path = &abs_path1918 ),1919 );1920}
147 unmodified lines
2068 te.assert_output(2069 &["--strip-cwd-prefix", "."],2070 "a.foo2071 e1 e22072 one2072 one/2073 one/b.foo2074 one/two2074 one/two/2075 one/two/c.foo2076 one/two/C.Foo22077 one/two/three2077 one/two/three/2078 one/two/three/d.foo2079 one/two/three/directory_foo2079 one/two/three/directory_foo/2080 symlink",2081 );2082}
modified:CHANGELOG.md+1 added
12 unmodified lines
1314## Changes1516- Changed `-u` flag to be equivalent to `-HI`. Multiple `-u` flags still allowed but do nothing, see #840 (@jacksontheel)17- Directories are now printed with an additional path separator at the end: `foo/bar/`, see #436 and #812 (@yyogo)1819## Other2021- Added installation instructions for RHEL8, see #989 (@ethsol)
572 unmodified lines