summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2019-12-11 17:41:04 +0100
committerAndrew Gallant <jamslam@gmail.com>2020-02-17 17:16:28 -0500
commit6f2b79f5847f941aec44ed5813c0dae16c2b2946 (patch)
tree05efee20472972ee228d378f2a5450306af8dbbc /tests
parent0c3b673e4c64c6e9c580b15ff8cf9c2a21c29cbd (diff)
ignore: use git commondir for sourcing .git/info/exclude
Git looks for this file in GIT_COMMON_DIR, which is usually the same as GIT_DIR (.git). However, when searching inside a linked worktree, .git is usually a file that contains the path of the actual git dir, which in turn contains a file "commondir" which references the directory where info/exclude may reside, alongside other configuration shared across all worktrees. This directory is usually the git dir of the main worktree. Unlike git this does *not* read environment variables GIT_DIR and GIT_COMMON_DIR, because it is not clear how to interpret them when searching multiple repositories. Fixes #1445, Closes #1446
Diffstat (limited to 'tests')
-rw-r--r--tests/regression.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/regression.rs b/tests/regression.rs
index e8c915ae..6d925744 100644
--- a/tests/regression.rs
+++ b/tests/regression.rs
@@ -738,3 +738,19 @@ rgtest!(r1334_crazy_literals, |dir: Dir, mut cmd: TestCommand| {
cmd.arg("-Ff").arg("patterns").arg("corpus").stdout()
);
});
+
+// See: https://github.com/BurntSushi/ripgrep/pull/1446
+rgtest!(r1446_respect_excludes_in_worktree, |dir: Dir, mut cmd: TestCommand| {
+ dir.create_dir("repo/.git/info");
+ dir.create("repo/.git/info/exclude", "ignored");
+ dir.create_dir("repo/.git/worktrees/repotree");
+ dir.create("repo/.git/worktrees/repotree/commondir", "../..");
+
+ dir.create_dir("repotree");
+ dir.create("repotree/.git", "gitdir: repo/.git/worktrees/repotree");
+ dir.create("repotree/ignored", "");
+ dir.create("repotree/not-ignored", "");
+
+ cmd.arg("--sort").arg("path").arg("--files").arg("repotree");
+ eqnice!("repotree/not-ignored\n", cmd.stdout());
+});