mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-07-25 17:21:57 -07:00
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
This commit is contained in:
committed by
Andrew Gallant
parent
0c3b673e4c
commit
6f2b79f584
@@ -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());
|
||||
});
|
||||
|
Reference in New Issue
Block a user