From cc90511ab29d3c37e873acac0fd80f90473f54bb Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Fri, 23 Sep 2016 22:44:17 -0400 Subject: [PATCH] Switch from .rgignore to .ignore. But don't actually remove support for .rgignore until the next semver bump. Note that this puts us in line with the silver searcher: https://github.com/ggreer/the_silver_searcher/pull/974 Fixes #40 --- README.md | 6 +++--- doc/rg.1 | 4 ++-- doc/rg.1.md | 2 +- src/args.rs | 2 +- src/gitignore.rs | 2 +- src/ignore.rs | 3 ++- tests/tests.rs | 5 +++++ 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6332e607..2319503e 100644 --- a/README.md +++ b/README.md @@ -145,9 +145,9 @@ files, ignore hidden files and directories and skip binary files: $ rg foobar ``` -The above command also respects all `.rgignore` files, including in parent -directories. `.rgignore` files can be used when `.gitignore` files are -insufficient. In all cases, `.rgignore` patterns take precedence over +The above command also respects all `.ignore` files, including in parent +directories. `.ignore` files can be used when `.gitignore` files are +insufficient. In all cases, `.ignore` patterns take precedence over `.gitignore`. To ignore all ignore files, use `-u`. To additionally search hidden files diff --git a/doc/rg.1 b/doc/rg.1 index 300ad1b1..9d47e27c 100644 --- a/doc/rg.1 +++ b/doc/rg.1 @@ -211,8 +211,8 @@ Never use memory maps, even when they might be faster. .RE .TP .B \-\-no\-ignore -Don\[aq]t respect ignore files (.gitignore, .rgignore, etc.) This -implies \-\-no\-ignore\-parent. +Don\[aq]t respect ignore files (.gitignore, .ignore, etc.) This implies +\-\-no\-ignore\-parent. .RS .RE .TP diff --git a/doc/rg.1.md b/doc/rg.1.md index 81e974eb..224ff1a9 100644 --- a/doc/rg.1.md +++ b/doc/rg.1.md @@ -137,7 +137,7 @@ the raw speed of grep. : Never use memory maps, even when they might be faster. --no-ignore -: Don't respect ignore files (.gitignore, .rgignore, etc.) +: Don't respect ignore files (.gitignore, .ignore, etc.) This implies --no-ignore-parent. --no-ignore-parent diff --git a/src/args.rs b/src/args.rs index 777556dc..4b5052ac 100644 --- a/src/args.rs +++ b/src/args.rs @@ -137,7 +137,7 @@ Less common options: Never use memory maps, even when they might be faster. --no-ignore - Don't respect ignore files (.gitignore, .rgignore, etc.) + Don't respect ignore files (.gitignore, .ignore, etc.) This implies --no-ignore-parent. --no-ignore-parent diff --git a/src/gitignore.rs b/src/gitignore.rs index 76e0be76..2bbebd62 100644 --- a/src/gitignore.rs +++ b/src/gitignore.rs @@ -9,7 +9,7 @@ The motivation for this submodule is performance and portability: 2. We could shell out to a `git` sub-command like ls-files or status, but it seems better to not rely on the existence of external programs for a search tool. Besides, we need to implement this logic anyway to support things like - an .rgignore file. + an .ignore file. The key implementation detail here is that a single gitignore file is compiled into a single RegexSet, which can be used to report which globs match a diff --git a/src/ignore.rs b/src/ignore.rs index d784f994..01954205 100644 --- a/src/ignore.rs +++ b/src/ignore.rs @@ -5,7 +5,7 @@ whether a *single* file path should be searched or not. In general, there are two ways to ignore a particular file: 1. Specify an ignore rule in some "global" configuration, such as a - $HOME/.rgignore or on the command line. + $HOME/.ignore or on the command line. 2. A specific ignore file (like .gitignore) found during directory traversal. The `IgnoreDir` type handles ignore patterns for any one particular directory @@ -24,6 +24,7 @@ use types::Types; const IGNORE_NAMES: &'static [&'static str] = &[ ".gitignore", + ".ignore", ".rgignore", ]; diff --git a/tests/tests.rs b/tests/tests.rs index e2aedc33..3823cee4 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -377,6 +377,11 @@ sherlock!(ignore_git, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { wd.assert_err(&mut cmd); }); +sherlock!(ignore_generic, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { + wd.create(".ignore", "sherlock\n"); + wd.assert_err(&mut cmd); +}); + sherlock!(ignore_ripgrep, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { wd.create(".rgignore", "sherlock\n"); wd.assert_err(&mut cmd);