Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rg does not ignore files listed in .git/info/exclude in git linked worktrees #1445

Closed
krobelus opened this issue Dec 10, 2019 · 0 comments
Closed

Comments

@krobelus
Copy link
Contributor

krobelus commented Dec 10, 2019

What version of ripgrep are you using?

ripgrep 11.0.2 (same in master I think)

How did you install ripgrep?

https://www.archlinux.org/packages/community/x86_64/ripgrep/

What operating system are you using ripgrep on?

Arch Linux

Describe your question, feature request, or bug.

If I exclude a file privately in .git/info/exclude, ripgrep ignores that file as expected - but only when searching inside the main worktree. In linked worktrees, the file is not ignored.

If this is a bug, what are the steps to reproduce the behavior?

#!/bin/sh
rm -rf repro repro-worktree

git init repro
cd repro
touch committed
git add committed
git commit -m 'initial commit'
echo ignored > .git/info/exclude
git worktree add ../repro-worktree
cd ../repro-worktree
touch ignored

echo
echo '$ rg --files'
rg --files
echo '$ git ls-files; git ls-files --exclude-standard --others'
git ls-files; git ls-files --exclude-standard --others

If this is a bug, what is the actual behavior?

$ rg --files
ignored
committed

If this is a bug, what is the expected behavior?

I think it should behave like git ls-files; git ls-files --exclude-standard --others:

$ rg --files
committed
krobelus added a commit to krobelus/ripgrep that referenced this issue Dec 11, 2019
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 BurntSushi#1445
BurntSushi pushed a commit that referenced this issue Feb 17, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant