From 58e7d2ea6375860fa09a043d6a1ba20518dfb462 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 21 Nov 2023 20:18:22 -0500 Subject: doc: add docs about .ignore/.rgignore in parent directories Closes #2479 --- CHANGELOG.md | 2 ++ GUIDE.md | 14 +++++++++----- crates/core/flags/defs.rs | 2 +- crates/core/flags/doc/template.rg.1 | 10 +++++++--- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 607430b8..658a9b86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,8 @@ Bug fixes: Make `-p/--pretty` override flags like `--no-line-number`. * [BUG #2392](https://github.com/BurntSushi/ripgrep/issues/2392): Improve global git config parsing of the `excludesFile` field. +* [BUG #2479](https://github.com/BurntSushi/ripgrep/issues/2479): + Add documentation about `.ignore`/`.rgignore` files in parent directories. * [BUG #2480](https://github.com/BurntSushi/ripgrep/issues/2480): Fix bug when using inline regex flags with `-e/--regexp`. * [BUG #2519](https://github.com/BurntSushi/ripgrep/issues/2519): diff --git a/GUIDE.md b/GUIDE.md index d81db04b..6d51e460 100644 --- a/GUIDE.md +++ b/GUIDE.md @@ -178,11 +178,15 @@ search. By default, when you search a directory, ripgrep will ignore all of the following: 1. Files and directories that match glob patterns in these three categories: - 1. gitignore globs (including global and repo-specific globs). + 1. `.gitignore` globs (including global and repo-specific globs). This + includes `.gitignore` files in parent directories that are part of the + same `git` repository. (Unless the `--no-require-git` flag is given.) 2. `.ignore` globs, which take precedence over all gitignore globs - when there's a conflict. + when there's a conflict. This includes `.ignore` files in parent + directories. 3. `.rgignore` globs, which take precedence over all `.ignore` globs - when there's a conflict. + when there's a conflict. This includes `.rgignore` files in parent + directories. 2. Hidden files and directories. 3. Binary files. (ripgrep considers any file with a `NUL` byte to be binary.) 4. Symbolic links aren't followed. @@ -190,7 +194,7 @@ the following: All of these things can be toggled using various flags provided by ripgrep: 1. You can disable all ignore-related filtering with the `--no-ignore` flag. -2. Hidden files and directories can be searched with the `--hidden` (`-.` for +2. Hidden files and directories can be searched with the `--hidden` (`-.` for short) flag. 3. Binary files can be searched via the `--text` (`-a` for short) flag. Be careful with this flag! Binary files may emit control characters to your @@ -997,7 +1001,7 @@ used options that will likely impact how you use ripgrep on a regular basis. if the pattern contains any uppercase letters. Usually this flag is put into alias or a config file. * `-F/--fixed-strings`: Disable regular expression matching and treat the pattern - as a literal string. + as a literal string. * `-w/--word-regexp`: Require that all matches of the pattern be surrounded by word boundaries. That is, given `pattern`, the `--word-regexp` flag will cause ripgrep to behave as if `pattern` were actually `\b(?:pattern)\b`. diff --git a/crates/core/flags/defs.rs b/crates/core/flags/defs.rs index ed78c28a..38611759 100644 --- a/crates/core/flags/defs.rs +++ b/crates/core/flags/defs.rs @@ -4734,7 +4734,7 @@ impl Flag for NoRequireGit { fn doc_long(&self) -> &'static str { r" When this flag is given, source control ignore files such as \fB.gitignore\fP -are respect even if no \fBgit\fP repository is present. +are respected even if no \fBgit\fP repository is present. .sp By default, ripgrep will only respect filter rules from source control ignore files when ripgrep detects that the search is executed inside a source control diff --git a/crates/core/flags/doc/template.rg.1 b/crates/core/flags/doc/template.rg.1 index 5c7fbdb8..6c3359d6 100644 --- a/crates/core/flags/doc/template.rg.1 +++ b/crates/core/flags/doc/template.rg.1 @@ -165,7 +165,9 @@ this includes the following: Any global rules, e.g., in \fB$HOME/.config/git/ignore\fP. . .IP \(bu 3n -Any rules in relevant \fB.gitignore\fP files. +Any rules in relevant \fB.gitignore\fP files. This includes \fB.gitignore\fP +files in parent directories that are part of the same \fBgit\fP repository. +(Unless \fB\-\-no\-require\-git\fP is given.) . .IP \(bu 3n Any local rules, e.g., in \fB.git/info/exclude\fP. @@ -180,10 +182,12 @@ precisely, or otherwise use \fBgit grep\fP for search. Additional ignore rules can be provided outside of a \fBgit\fP context: . .IP \(bu 3n -Any rules in \fB.ignore\fP. +Any rules in \fB.ignore\fP. ripgrep will also respect \fB.ignore\fP files in +parent directories. . .IP \(bu 3n -Any rules in \fB.rgignore\fP. +Any rules in \fB.rgignore\fP. ripgrep will also respect \fB.rgignore\fP files +in parent directories. . .IP \(bu 3n Any rules in files specified with the \fB\-\-ignore\-file\fP flag. -- cgit v1.2.3