mirror of
https://github.com/sharkdp/fd
synced 2024-10-06 07:49:18 +00:00
Add --no-ignore-vcs option
When passed, .gitignore files will not be respected.
This commit is contained in:
parent
c0bfc65d88
commit
9bd1d12c00
7
doc/fd.1
7
doc/fd.1
|
@ -30,9 +30,10 @@ is a simple, fast and user-friendly alternative to
|
||||||
Search hidden files and directories.
|
Search hidden files and directories.
|
||||||
.TP
|
.TP
|
||||||
.B \-I, \-\-no\-ignore
|
.B \-I, \-\-no\-ignore
|
||||||
Do not respect any
|
Don't respect ignore files (.gitignore, .ignore, etc.)
|
||||||
.BR gitignore (5)
|
.TP
|
||||||
files.
|
.B \-\-no\-ignore\-vcs
|
||||||
|
Don't respect version control ignore files (e.g., .gitignore).
|
||||||
.TP
|
.TP
|
||||||
.B \-s, \-\-case\-sensitive
|
.B \-s, \-\-case\-sensitive
|
||||||
Perform a case-sensitive search (default: smart case).
|
Perform a case-sensitive search (default: smart case).
|
||||||
|
|
|
@ -42,6 +42,7 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
.setting(AppSettings::DeriveDisplayOrder)
|
.setting(AppSettings::DeriveDisplayOrder)
|
||||||
.arg(arg("hidden").long("hidden").short("H"))
|
.arg(arg("hidden").long("hidden").short("H"))
|
||||||
.arg(arg("no-ignore").long("no-ignore").short("I"))
|
.arg(arg("no-ignore").long("no-ignore").short("I"))
|
||||||
|
.arg(arg("no-ignore-vcs").long("no-ignore-vcs"))
|
||||||
.arg(
|
.arg(
|
||||||
arg("rg-alias-hidden-ignore")
|
arg("rg-alias-hidden-ignore")
|
||||||
.short("u")
|
.short("u")
|
||||||
|
@ -137,6 +138,10 @@ fn usage() -> HashMap<&'static str, Help> {
|
||||||
, "Do not respect .(git)ignore files"
|
, "Do not respect .(git)ignore files"
|
||||||
, "Show search results from files and directories that would otherwise be ignored by \
|
, "Show search results from files and directories that would otherwise be ignored by \
|
||||||
'.*ignore' files.");
|
'.*ignore' files.");
|
||||||
|
doc!(h, "no-ignore-vcs"
|
||||||
|
, "Do not respect .gitignore files"
|
||||||
|
, "Show search results from files and directories that would otherwise be ignored by \
|
||||||
|
'.gitignore' files.");
|
||||||
doc!(h, "case-sensitive"
|
doc!(h, "case-sensitive"
|
||||||
, "Case-sensitive search (default: smart case)"
|
, "Case-sensitive search (default: smart case)"
|
||||||
, "Perform a case-sensitive search. By default, fd uses case-insensitive searches, \
|
, "Perform a case-sensitive search. By default, fd uses case-insensitive searches, \
|
||||||
|
|
|
@ -37,9 +37,12 @@ pub struct FdOptions {
|
||||||
/// Whether to ignore hidden files and directories (or not).
|
/// Whether to ignore hidden files and directories (or not).
|
||||||
pub ignore_hidden: bool,
|
pub ignore_hidden: bool,
|
||||||
|
|
||||||
/// Whether to respect VCS ignore files (`.gitignore`, `.ignore`, ..) or not.
|
/// Whether to respect ignore files (`.gitignore`, `.ignore`, ..) or not.
|
||||||
pub read_ignore: bool,
|
pub read_ignore: bool,
|
||||||
|
|
||||||
|
/// Whether to respect VCS ignore files (`.gitignore`, ..) or not.
|
||||||
|
pub read_gitignore: bool,
|
||||||
|
|
||||||
/// Whether to follow symlinks or not.
|
/// Whether to follow symlinks or not.
|
||||||
pub follow_links: bool,
|
pub follow_links: bool,
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,9 @@ fn main() {
|
||||||
matches.occurrences_of("rg-alias-hidden-ignore") >= 2),
|
matches.occurrences_of("rg-alias-hidden-ignore") >= 2),
|
||||||
read_ignore: !(matches.is_present("no-ignore") ||
|
read_ignore: !(matches.is_present("no-ignore") ||
|
||||||
matches.is_present("rg-alias-hidden-ignore")),
|
matches.is_present("rg-alias-hidden-ignore")),
|
||||||
|
read_gitignore: !(matches.is_present("no-ignore") ||
|
||||||
|
matches.is_present("rg-alias-hidden-ignore") ||
|
||||||
|
matches.is_present("no-ignore-vcs")),
|
||||||
follow_links: matches.is_present("follow"),
|
follow_links: matches.is_present("follow"),
|
||||||
null_separator: matches.is_present("null_separator"),
|
null_separator: matches.is_present("null_separator"),
|
||||||
max_depth: matches.value_of("depth").and_then(|n| {
|
max_depth: matches.value_of("depth").and_then(|n| {
|
||||||
|
|
|
@ -67,10 +67,10 @@ pub fn scan(root: &Path, pattern: Arc<Regex>, config: Arc<FdOptions>) {
|
||||||
let walker = WalkBuilder::new(root)
|
let walker = WalkBuilder::new(root)
|
||||||
.hidden(config.ignore_hidden)
|
.hidden(config.ignore_hidden)
|
||||||
.ignore(config.read_ignore)
|
.ignore(config.read_ignore)
|
||||||
.git_ignore(config.read_ignore)
|
.git_ignore(config.read_gitignore)
|
||||||
.parents(config.read_ignore)
|
.parents(config.read_ignore || config.read_gitignore)
|
||||||
.git_global(config.read_ignore)
|
.git_global(config.read_gitignore)
|
||||||
.git_exclude(config.read_ignore)
|
.git_exclude(config.read_gitignore)
|
||||||
.overrides(overrides)
|
.overrides(overrides)
|
||||||
.follow_links(config.follow_links)
|
.follow_links(config.follow_links)
|
||||||
.max_depth(config.max_depth)
|
.max_depth(config.max_depth)
|
||||||
|
|
|
@ -50,6 +50,7 @@ fn create_working_directory() -> Result<TempDir, io::Error> {
|
||||||
fs::File::create(root.join("one/two/three/d.foo"))?;
|
fs::File::create(root.join("one/two/three/d.foo"))?;
|
||||||
fs::create_dir(root.join("one/two/three/directory_foo"))?;
|
fs::create_dir(root.join("one/two/three/directory_foo"))?;
|
||||||
fs::File::create(root.join("ignored.foo"))?;
|
fs::File::create(root.join("ignored.foo"))?;
|
||||||
|
fs::File::create(root.join("gitignored.foo"))?;
|
||||||
fs::File::create(root.join(".hidden.foo"))?;
|
fs::File::create(root.join(".hidden.foo"))?;
|
||||||
fs::File::create(root.join("e1 e2"))?;
|
fs::File::create(root.join("e1 e2"))?;
|
||||||
|
|
||||||
|
@ -62,6 +63,10 @@ fn create_working_directory() -> Result<TempDir, io::Error> {
|
||||||
fs::File::create(root.join(".ignore"))?.write_all(
|
fs::File::create(root.join(".ignore"))?.write_all(
|
||||||
b"ignored.foo",
|
b"ignored.foo",
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
fs::File::create(root.join(".gitignore"))?.write_all(
|
||||||
|
b"gitignored.foo",
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(temp_dir)
|
Ok(temp_dir)
|
||||||
|
|
|
@ -228,6 +228,7 @@ fn test_no_ignore() {
|
||||||
&["--no-ignore", "foo"],
|
&["--no-ignore", "foo"],
|
||||||
"a.foo
|
"a.foo
|
||||||
ignored.foo
|
ignored.foo
|
||||||
|
gitignored.foo
|
||||||
one/b.foo
|
one/b.foo
|
||||||
one/two/c.foo
|
one/two/c.foo
|
||||||
one/two/C.Foo2
|
one/two/C.Foo2
|
||||||
|
@ -240,6 +241,24 @@ fn test_no_ignore() {
|
||||||
".hidden.foo
|
".hidden.foo
|
||||||
a.foo
|
a.foo
|
||||||
ignored.foo
|
ignored.foo
|
||||||
|
gitignored.foo
|
||||||
|
one/b.foo
|
||||||
|
one/two/c.foo
|
||||||
|
one/two/C.Foo2
|
||||||
|
one/two/three/d.foo
|
||||||
|
one/two/three/directory_foo",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// VCS ignored files (--no-ignore-vcs)
|
||||||
|
#[test]
|
||||||
|
fn test_no_ignore_vcs() {
|
||||||
|
let te = TestEnv::new();
|
||||||
|
|
||||||
|
te.assert_output(
|
||||||
|
&["--no-ignore-vcs", "foo"],
|
||||||
|
"a.foo
|
||||||
|
gitignored.foo
|
||||||
one/b.foo
|
one/b.foo
|
||||||
one/two/c.foo
|
one/two/c.foo
|
||||||
one/two/C.Foo2
|
one/two/C.Foo2
|
||||||
|
@ -257,6 +276,7 @@ fn test_no_ignore_aliases() {
|
||||||
&["-u", "foo"],
|
&["-u", "foo"],
|
||||||
"a.foo
|
"a.foo
|
||||||
ignored.foo
|
ignored.foo
|
||||||
|
gitignored.foo
|
||||||
one/b.foo
|
one/b.foo
|
||||||
one/two/c.foo
|
one/two/c.foo
|
||||||
one/two/C.Foo2
|
one/two/C.Foo2
|
||||||
|
@ -269,6 +289,7 @@ fn test_no_ignore_aliases() {
|
||||||
".hidden.foo
|
".hidden.foo
|
||||||
a.foo
|
a.foo
|
||||||
ignored.foo
|
ignored.foo
|
||||||
|
gitignored.foo
|
||||||
one/b.foo
|
one/b.foo
|
||||||
one/two/c.foo
|
one/two/c.foo
|
||||||
one/two/C.Foo2
|
one/two/C.Foo2
|
||||||
|
|
Loading…
Reference in a new issue