Skip to content
Myr

Fixes for tmccombs review comments.

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

authored by Ami Fischman · committed by Ami Fischman · parent d05a718 · Browse files · 5 files+36 added−20 removed
This commit

State

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

Diff stats

5 files+36 added−20 removed

  • tests:+18 added−2 removed
  • other:+18 added−18 removed

5 files+36 added−20 removed

modified:doc/fd.1+4 added
263 unmodified lines
264Examples:265 \-\-exclude '*.pyc'266 \-\-exclude node_modules267.TP268.BI "\-\-ignore-contain " name269Exclude directories that (directly) contain the given name.270This option can be specified multiple times.271.TP272.BI "\-\-ignore-file " path273Add a custom ignore-file in '.gitignore' format.274These files have a low precedence.275.TP
303 unmodified lines
modified:src/cli.rs+2 added-5 removed
529 unmodified lines
530531 /// Ignore directories containing the named entry.532 #[arg(533 long,534 value_name = "name",535 hide_short_help = true,536 help = "Ignore directories containing this name",537 long_help534 value_name = "name"535 )]539 pub ignore_contain: Option<String>,536 pub ignore_contain: Vec<String>,537538 /// Set number of threads to use for searching & executing (default: number539 /// of available CPU cores)540 #[arg(long, short = 'j', value_name = "num", hide_short_help = true, value_parser = str::parse::<NonZeroUsize>)]
408 unmodified lines
modified:src/config.rs+2 added-2 removed
129 unmodified lines
130131 /// Whether or not to use hyperlinks on paths132 pub hyperlink: bool,133134 /// A name that should stop traversal down its parent. (e.g. https://bford.info/cachedir/).135 pub ignore_contain: Option<String>,134 /// Names that should stop traversal down their parent. (e.g. https://bford.info/cachedir/).135 pub ignore_contain: Vec<String>,136}137138impl Config {139 /// Check whether results are being printed.
4 unmodified lines
modified:src/walk.rs+10 added-11 removed
496 unmodified lines
497 };498 }499 };500501 // Check the depth & name first, since they don't require metadata.502 let entry_path = entry.path();503504 // Filter out directories containing a given name.505 if entry_path.is_dir()506 && config.ignore_contain.iter().any(|ic| entry_path.join(ic).exists())507 {508 return WalkState::Skip;509 }510511 if let Some(min_depth) = config.min_depth512 && entry.depth().is_none_or(|d| d < min_depth)513 {514 return WalkState::Continue;515 }516507 // Check the name first, since it doesn't require metadata508 let entry_path = entry.path();509517 let search_str: Cow<OsStr> = if config.search_full_path {518 let path_abs_buf = filesystem::path_absolute_form(entry_path)519 .expect("Retrieving absolute path succeeds");520 Cow::Owned(path_abs_buf.as_os_str().to_os_string())
45 unmodified lines
566 }567 }568 }569563 // Filter out directories containing a given name.564 if let Some(ref ignore_contain) = config.ignore_contain565 && entry_path.is_dir()566 && entry_path.join(ignore_contain).exists()567 {568 return WalkState::Skip;569 }570570 // Filter out unwanted sizes if it is a file and we have been given size constraints.571 if !config.size_constraints.is_empty() {572 if entry_path.is_file() {573 if let Some(metadata) = entry.metadata() {
103 unmodified lines
modified:tests/tests.rs+18 added-2 removed
2709 unmodified lines
27102711#[test]2712fn test_ignore_contain() {2713 let te = TestEnv::new(2714 &["include", "exclude", "exclude/sub"],2714 &["include", "exclude", "exclude/sub", "other"],2715 &[2716 "top",2717 "include/foo",2718 "exclude/CACHEDIR.TAG",2719 "exclude/sub/nope",2720 "other/ignoremyparent",2721 ],2722 );2723 let expected = "include/2724 include/foo2725 symlink2726 top";2726 te.assert_output(&["--ignore-contain=CACHEDIR.TAG", "."], expected);2727 te.assert_output(&["--ignore-contain=CACHEDIR.TAG", "--ignore-contain=ignoremyparent", "."], expected);2728}27292730#[test]2731fn test_ignore_contain_has_highest_precedence() {2732 let te = TestEnv::new(2733 &["include", "exclude", "exclude/sub"],2734 &[2735 "top",2736 "include/foo",2737 "exclude/CACHEDIR.TAG",2738 "exclude/sub/nope",2739 ],2740 );2741 let expected = "include/foo";2742 te.assert_output(&["--ignore-contain=CACHEDIR.TAG", "--min-depth=2", "."], expected);2743}