summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2018-07-22 10:29:18 -0400
committerAndrew Gallant <jamslam@gmail.com>2018-07-22 10:33:23 -0400
commite65ca21a6cebceb9ba79fcd164da24478cc01fb0 (patch)
tree9d371d1a088fcfe913be97567310b2b5748d09a0 /tests
parent6771626553934f16306e8409aee78f7a63e43738 (diff)
ignore: only respect .gitignore in git repos
This commit fixes an interesting bug in the `ignore` crate where it would basically respect any `.gitignore` file anywhere (including global gitignores in `~/.config/git/ignore`), regardless of whether we were searching in a git repository or not. This commit rectifies that behavior to only respect gitignore rules when in a git repo. The key change here is to move the logic of whether to traverse parents into the directory matcher rather than putting the onus on the directory traverser. In particular, we now need to traverse parent directories in more cases than we previously did, since we need to determine whether we're in a git repository or not. Fixes #934
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index 6a5bf73f..9b6154d2 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -710,6 +710,7 @@ sherlock!(no_parent_ignore_git, "Sherlock", ".",
|wd: WorkDir, mut cmd: Command| {
// Set up a directory hierarchy like this:
//
+ // .git/
// .gitignore
// foo/
// .gitignore
@@ -727,6 +728,7 @@ sherlock!(no_parent_ignore_git, "Sherlock", ".",
// In other words, we should only see results from `sherlock`, not from
// `watson`.
wd.remove("sherlock");
+ wd.create_dir(".git");
wd.create(".gitignore", "sherlock\n");
wd.create_dir("foo");
wd.create("foo/.gitignore", "watson\n");