From f3241fd657c83284f0ec17854e41cab9fe3ce446 Mon Sep 17 00:00:00 2001 From: Richard Sternagel Date: Sun, 8 May 2022 15:48:56 +0200 Subject: [PATCH] cli: '--no-ignore-dot' should also '.rgignore' Fixes #2198, Closes #2202 --- CHANGELOG.md | 3 ++- crates/core/args.rs | 2 +- tests/regression.rs | 13 +++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d80557f..7e013675 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ Bug fixes: Fix bug when using `-w` with a regex that can match the empty string. * [BUG #1911](https://github.com/BurntSushi/ripgrep/issues/1911): Disable mmap searching in all non-64-bit environments. +* [BUG #2198](https://github.com/BurntSushi/ripgrep/issues/2198): + Fix bug where `--no-ignore-dot` would not ignore `.rgignore`. * [BUG #2288](https://github.com/BurntSushi/ripgrep/issues/2288): `-A` and `-B` now only each partially override `-C`. * [BUG #2236](https://github.com/BurntSushi/ripgrep/issues/2236): @@ -29,7 +31,6 @@ Bug fixes: * [BUG #2523](https://github.com/BurntSushi/ripgrep/issues/2523): Make executable searching take `.com` into account on Windows. - 13.0.0 (2021-06-12) =================== ripgrep 13 is a new major version release of ripgrep that primarily contains diff --git a/crates/core/args.rs b/crates/core/args.rs index 883bf0fb..ad2ee2e8 100644 --- a/crates/core/args.rs +++ b/crates/core/args.rs @@ -872,7 +872,7 @@ impl ArgMatches { .git_exclude(!self.no_ignore_vcs() && !self.no_ignore_exclude()) .require_git(!self.is_present("no-require-git")) .ignore_case_insensitive(self.ignore_file_case_insensitive()); - if !self.no_ignore() { + if !self.no_ignore() && !self.no_ignore_dot() { builder.add_custom_ignore_filename(".rgignore"); } let sortby = self.sort_by()?; diff --git a/tests/regression.rs b/tests/regression.rs index 1cc7d5a2..b9076803 100644 --- a/tests/regression.rs +++ b/tests/regression.rs @@ -1090,6 +1090,19 @@ b=one eqnice!(expected, cmd.stdout()); }); +// See: https://github.com/BurntSushi/ripgrep/issues/2198 +rgtest!(r2198, |dir: Dir, mut cmd: TestCommand| { + dir.create(".ignore", "a"); + dir.create(".rgignore", "b"); + dir.create("a", ""); + dir.create("b", ""); + dir.create("c", ""); + + cmd.arg("--files").arg("--sort").arg("path"); + eqnice!("c\n", cmd.stdout()); + eqnice!("a\nb\nc\n", cmd.arg("--no-ignore-dot").stdout()); +}); + // See: https://github.com/BurntSushi/ripgrep/issues/2208 rgtest!(r2208, |dir: Dir, mut cmd: TestCommand| { dir.create("test", "# Compile requirements.txt files from all found or specified requirements.in files (compile).