You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.7 KiB
48 lines
1.7 KiB
7 years ago
|
From e4f995b59622a66bc6f02274f0db09634603dc17 Mon Sep 17 00:00:00 2001
|
||
|
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
|
||
|
Date: Sun, 29 Jul 2018 20:12:43 +0200
|
||
|
Subject: [PATCH 1/3] 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
|
||
|
|
||
|
(cherry picked from commit e65ca21a6cebceb9ba79fcd164da24478cc01fb0)
|
||
|
---
|
||
|
tests/tests.rs | 2 ++
|
||
|
1 file changed, 2 insertions(+)
|
||
|
|
||
|
diff --git a/tests/tests.rs b/tests/tests.rs
|
||
|
index 34bf08e..903c470 100644
|
||
|
--- a/tests/tests.rs
|
||
|
+++ b/tests/tests.rs
|
||
|
@@ -662,6 +662,7 @@ sherlock!(no_parent_ignore_git, "Sherlock", ".",
|
||
|
|wd: WorkDir, mut cmd: Command| {
|
||
|
// Set up a directory hierarchy like this:
|
||
|
//
|
||
|
+ // .git/
|
||
|
// .gitignore
|
||
|
// foo/
|
||
|
// .gitignore
|
||
|
@@ -679,6 +680,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");
|
||
|
--
|
||
|
2.18.0
|
||
|
|