Skip to content
Myr

Add --no-ignore-vcs option

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

When passed, .gitignore files will not be respected.

authored by ptzz · committed by David Peter · parent c0bfc65 · Browse files · 7 files+46 added−8 removed
This commit

State

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

Diff stats

7 files+46 added−8 removed

  • tests:+26 added−0 removed
  • other:+20 added−8 removed

7 files+46 added−8 removed

modified:doc/fd.1+4 added-3 removed
28 unmodified lines
29.B \-H, \-\-hidden30Search hidden files and directories.31.TP32.B \-I, \-\-no\-ignore33Do not respect any34.BR gitignore (5)35files.33Don't respect ignore files (.gitignore, .ignore, etc.)34.TP35.B \-\-no\-ignore\-vcs36Don't respect version control ignore files (e.g., .gitignore).37.TP38.B \-s, \-\-case\-sensitive39Perform a case-sensitive search (default: smart case).40.TP41.B \-i, \-\-ignore\-case
96 unmodified lines
modified:src/app.rs+5 added
40 unmodified lines
41 .setting(AppSettings::ColoredHelp)42 .setting(AppSettings::DeriveDisplayOrder)43 .arg(arg("hidden").long("hidden").short("H"))44 .arg(arg("no-ignore").long("no-ignore").short("I"))45 .arg(arg("no-ignore-vcs").long("no-ignore-vcs"))46 .arg(47 arg("rg-alias-hidden-ignore")48 .short("u")49 .multiple(true)
87 unmodified lines
137 doc!(h, "no-ignore"138 , "Do not respect .(git)ignore files"139 , "Show search results from files and directories that would otherwise be ignored by \140 '.*ignore' files.");141 doc!(h, "no-ignore-vcs"142 , "Do not respect .gitignore files"143 , "Show search results from files and directories that would otherwise be ignored by \144 '.gitignore' files.");145 doc!(h, "case-sensitive"146 , "Case-sensitive search (default: smart case)"147 , "Perform a case-sensitive search. By default, fd uses case-insensitive searches, \148 unless the pattern contains an uppercase character (smart case).");
74 unmodified lines
modified:src/internal.rs+4 added-1 removed
35 unmodified lines
3637 /// Whether to ignore hidden files and directories (or not).38 pub ignore_hidden: bool,3940 /// Whether to respect VCS ignore files (`.gitignore`, `.ignore`, ..) or not.40 /// Whether to respect ignore files (`.gitignore`, `.ignore`, ..) or not.41 pub read_ignore: bool,4243 /// Whether to respect VCS ignore files (`.gitignore`, ..) or not.44 pub read_gitignore: bool,4546 /// Whether to follow symlinks or not.47 pub follow_links: bool,4849 /// Whether elements of output should be separated by a null character
68 unmodified lines
modified:src/main.rs+3 added
112 unmodified lines
113 ignore_hidden: !(matches.is_present("hidden") ||114 matches.occurrences_of("rg-alias-hidden-ignore") >= 2),115 read_ignore: !(matches.is_present("no-ignore") ||116 matches.is_present("rg-alias-hidden-ignore")),117 read_gitignore: !(matches.is_present("no-ignore") ||118 matches.is_present("rg-alias-hidden-ignore") ||119 matches.is_present("no-ignore-vcs")),120 follow_links: matches.is_present("follow"),121 null_separator: matches.is_present("null_separator"),122 max_depth: matches.value_of("depth").and_then(|n| {123 usize::from_str_radix(n, 10).ok()
39 unmodified lines
modified:src/walk.rs+4 added-4 removed
65 unmodified lines
6667 let walker = WalkBuilder::new(root)68 .hidden(config.ignore_hidden)69 .ignore(config.read_ignore)70 .git_ignore(config.read_ignore)71 .parents(config.read_ignore)72 .git_global(config.read_ignore)73 .git_exclude(config.read_ignore)70 .git_ignore(config.read_gitignore)71 .parents(config.read_ignore || config.read_gitignore)72 .git_global(config.read_gitignore)73 .git_exclude(config.read_gitignore)74 .overrides(overrides)75 .follow_links(config.follow_links)76 .max_depth(config.max_depth)77 .threads(threads)
164 unmodified lines
modified:tests/testenv/mod.rs+5 added
48 unmodified lines
49 fs::File::create(root.join("one/two/C.Foo2"))?;50 fs::File::create(root.join("one/two/three/d.foo"))?;51 fs::create_dir(root.join("one/two/three/directory_foo"))?;52 fs::File::create(root.join("ignored.foo"))?;53 fs::File::create(root.join("gitignored.foo"))?;54 fs::File::create(root.join(".hidden.foo"))?;55 fs::File::create(root.join("e1 e2"))?;5657 #[cfg(unix)] unix::fs::symlink(root.join("one/two"), root.join("symlink"))?;
4 unmodified lines
6263 fs::File::create(root.join(".ignore"))?.write_all(64 b"ignored.foo",65 )?;6667 fs::File::create(root.join(".gitignore"))?.write_all(68 b"gitignored.foo",69 )?;70 }7172 Ok(temp_dir)73}
124 unmodified lines
modified:tests/tests.rs+21 added
226 unmodified lines
227 te.assert_output(228 &["--no-ignore", "foo"],229 "a.foo230 ignored.foo231 gitignored.foo232 one/b.foo233 one/two/c.foo234 one/two/C.Foo2235 one/two/three/d.foo
4 unmodified lines
240 &["--hidden", "--no-ignore", "foo"],241 ".hidden.foo242 a.foo243 ignored.foo244 gitignored.foo245 one/b.foo246 one/two/c.foo247 one/two/C.Foo2248 one/two/three/d.foo249 one/two/three/directory_foo",250 );251}252253/// VCS ignored files (--no-ignore-vcs)254#[test]255fn test_no_ignore_vcs() {256 let te = TestEnv::new();257258 te.assert_output(259 &["--no-ignore-vcs", "foo"],260 "a.foo261 gitignored.foo262 one/b.foo263 one/two/c.foo264 one/two/C.Foo2265 one/two/three/d.foo266 one/two/three/directory_foo",267 );268}269270/// Ignored files with ripgrep aliases (-u / -uu)271#[test]272fn test_no_ignore_aliases() {273 let te = TestEnv::new();
1 unmodified line
275 te.assert_output(276 &["-u", "foo"],277 "a.foo278 ignored.foo279 gitignored.foo280 one/b.foo281 one/two/c.foo282 one/two/C.Foo2283 one/two/three/d.foo
4 unmodified lines
288 &["-uu", "foo"],289 ".hidden.foo290 a.foo291 ignored.foo292 gitignored.foo293 one/b.foo294 one/two/c.foo295 one/two/C.Foo2296 one/two/three/d.foo
398 unmodified lines