From b7e077320dfd8293e593e72e2b437b12b4845146 Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Wed, 22 Dec 2021 22:38:00 -0800 Subject: [PATCH] Fix logic for --no-ignore-parent (#908) Make sure that using `--no-ignore-vcs` or `--no-ignore` don't also enable `--no-ignore-parent`. So that if `--no-ignore-vcs` is enabled, it continues to respect .fdignore and .ignore in the parent directories. Fixes: #907 Fixes: #901 --- src/main.rs | 5 +---- src/walk.rs | 2 +- tests/tests.rs | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4f4ab14..56d6bfb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -260,10 +260,7 @@ fn construct_config(matches: clap::ArgMatches, pattern_regex: &str) -> Result, config: Arc) -> R walker .hidden(config.ignore_hidden) .ignore(config.read_fdignore) - .parents(config.read_parent_ignore) + .parents(config.read_parent_ignore && (config.read_fdignore || config.read_vcsignore)) .git_ignore(config.read_vcsignore) .git_global(config.read_vcsignore) .git_exclude(config.read_vcsignore) diff --git a/tests/tests.rs b/tests/tests.rs index 807b91b..e6cee6c 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -614,6 +614,22 @@ fn test_no_ignore_vcs() { ); } +/// Test that --no-ignore-vcs still respects .fdignored in parent directory +#[test] +fn test_no_ignore_vcs_child_dir() { + let te = TestEnv::new( + &["inner"], + &["inner/fdignored.foo", "inner/foo", "inner/gitignored.foo"], + ); + + te.assert_output_subdirectory( + "inner", + &["--no-ignore-vcs", "foo"], + "./foo + ./gitignored.foo", + ); +} + /// Custom ignore files (--ignore-file) #[test] fn test_custom_ignore_files() {