summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2020-02-17 14:43:22 -0500
committerAndrew Gallant <jamslam@gmail.com>2020-02-17 17:16:28 -0500
commit711426a632aee0affb7009cd8e3492c4ff7273e8 (patch)
treec208b97d618f7867a55171fb2d7c2928a6ccfe37 /tests
parent01eeec56bb0a67dd402aed0f5650525076b26657 (diff)
cli: add --no-require-git flag
This flag prevents ripgrep from requiring one to search a git repository in order to respect git-related ignore rules (global, .gitignore and local excludes). This actually corresponds to behavior ripgrep had long ago, but #934 changed that. It turns out that users were relying on this buggy behavior. In most cases, fixing it as simple as converting one's rules to .ignore or .rgignore files. Unfortunately, there are other use cases---like Perforce automatically respecting .gitignore files---that make a strong case for ripgrep to at least support this. The UX of a flag like this is absolutely atrocious. It's so obscure that it's really not worth explicitly calling it out anywhere. Moreover, the error cases that occur when this flag isn't used (but its behavior is desirable) will not be intuitive, do not seem easily detectable and will not guide users to this flag. Nevertheless, the motivation for this is just barely strong enough for me to begrudgingly accept this. Fixes #1414, Closes #1416
Diffstat (limited to 'tests')
-rw-r--r--tests/feature.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/feature.rs b/tests/feature.rs
index 33ab4e17..3d61f459 100644
--- a/tests/feature.rs
+++ b/tests/feature.rs
@@ -728,6 +728,34 @@ rgtest!(f1207_ignore_encoding, |dir: Dir, mut cmd: TestCommand| {
eqnice!("\u{FFFD}\u{FFFD}\x00b\n", cmd.stdout());
});
+// See: https://github.com/BurntSushi/ripgrep/issues/1414
+rgtest!(f1414_no_require_git, |dir: Dir, mut cmd: TestCommand| {
+ dir.create(".gitignore", "foo");
+ dir.create("foo", "");
+ dir.create("bar", "");
+
+ let stdout = cmd.args(&[
+ "--sort", "path",
+ "--files",
+ ]).stdout();
+ eqnice!("bar\nfoo\n", stdout);
+
+ let stdout = cmd.args(&[
+ "--sort", "path",
+ "--files",
+ "--no-require-git",
+ ]).stdout();
+ eqnice!("bar\n", stdout);
+
+ let stdout = cmd.args(&[
+ "--sort", "path",
+ "--files",
+ "--no-require-git",
+ "--require-git",
+ ]).stdout();
+ eqnice!("bar\nfoo\n", stdout);
+});
+
// See: https://github.com/BurntSushi/ripgrep/pull/1420
rgtest!(f1420_no_ignore_dot, |dir: Dir, mut cmd: TestCommand| {
dir.create_dir(".git/info");