Skip to content

Commit

Permalink
doc: add docs about .ignore/.rgignore in parent directories
Browse files Browse the repository at this point in the history
Closes #2479
  • Loading branch information
BurntSushi committed Nov 22, 2023
1 parent 198206d commit 2b5dd0a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
14 changes: 9 additions & 5 deletions GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,23 @@ 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.

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
Expand Down Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion crates/core/flags/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions crates/core/flags/doc/template.rg.1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 2b5dd0a

Please sign in to comment.