From 447506ebe02f1475734b66137feb02ae0fd9decf Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 15 Mar 2020 10:28:59 -0400 Subject: [PATCH] doc: clarify globing behavior Fixes #1442, Fixes #1478 --- CHANGELOG.md | 3 +++ crates/core/app.rs | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7a0f512..ce0c2fda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,9 @@ Bug fixes: Improve documentation for ripgrep's automatic stdin detection. * [BUG #1441](https://github.com/BurntSushi/ripgrep/issues/1441): Remove CPU features from man page. +* [BUG #1442](https://github.com/BurntSushi/ripgrep/issues/1442), + [BUG #1478](https://github.com/BurntSushi/ripgrep/issues/1478): + Improve documentation of the `-g/--glob` flag. * [BUG #1445](https://github.com/BurntSushi/ripgrep/issues/1445): ripgrep now respects ignore rules from .git/info/exclude in worktrees. * [BUG #1485](https://github.com/BurntSushi/ripgrep/issues/1485): diff --git a/crates/core/app.rs b/crates/core/app.rs index 04bcf878..410cb0c1 100644 --- a/crates/core/app.rs +++ b/crates/core/app.rs @@ -1364,7 +1364,13 @@ fn flag_glob(args: &mut Vec) { Include or exclude files and directories for searching that match the given glob. This always overrides any other ignore logic. Multiple glob flags may be used. Globbing rules match .gitignore globs. Precede a glob with a ! to exclude -it. +it. If multiple globs match a file or directory, the glob given later in the +command line takes precedence. + +When this flag is set, every file and directory is applied to it to test for +a match. So for example, if you only want to search in a particular directory +'foo', then *-g foo* is incorrect because 'foo/bar' does not match the glob +'foo'. Instead, you should use *-g +++'foo/**'+++*. " ); let arg = RGArg::flag("glob", "GLOB")