diff options
author | Thayne McCombs <astrothayne@gmail.com> | 2021-12-22 22:38:00 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-22 23:38:00 -0700 |
commit | b7e077320dfd8293e593e72e2b437b12b4845146 (patch) | |
tree | 4b80b099354e0000c68c50d4ba1954f4a3e2d5ba | |
parent | 81669f4c10a70a1c105ae487fa20cb2d686d0d1a (diff) |
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
-rw-r--r-- | src/main.rs | 5 | ||||
-rw-r--r-- | src/walk.rs | 2 | ||||
-rw-r--r-- | 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<Co read_vcsignore: !(matches.is_present("no-ignore") || matches.is_present("rg-alias-hidden-ignore") || matches.is_present("no-ignore-vcs")), - read_parent_ignore: !(matches.is_present("no-ignore") - || matches.is_present("rg-alias-hidden-ignore") - || matches.is_present("no-ignore-vcs") - || matches.is_present("no-ignore-parent")), + read_parent_ignore: !matches.is_present("no-ignore-parent"), read_global_ignore: !(matches.is_present("no-ignore") || matches.is_present("rg-alias-hidden-ignore") || matches.is_present("no-global-ignore-file")), diff --git a/src/walk.rs b/src/walk.rs index d69c813..037baae 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -72,7 +72,7 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<Config>) -> 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() { |