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

--files doesn't correctly handle .gitignore'd directories when supplied paths are absolute #65

Closed
nickstenning opened this issue Sep 24, 2016 · 2 comments

Comments

@nickstenning
Copy link
Contributor

It seems that specifying a path in a .gitignore which has a trailing slash, such as

a/

(as opposed to simply a) causes rg --files to fail to correctly ignore files within that directory. This only happens when an absolute path is supplied as an argument.

Steps to reproduce

Here's a shell session that shows the problem. In it I create a directory, ignore it, and then show that the files within that directory are correctly ignored if I run rg --files or rg --files ignored . (see #64 for why I've included the word ignored in that invocation), but not if I run rg --files ignored $PWD.

If I either specify the path as ., or remove the trailing slash from the line in .gitignore, the directory is correctly ignored.

$ uname -mrsv
Darwin 15.6.0 Darwin Kernel Version 15.6.0: Mon Aug 29 20:21:34 PDT 2016; root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64
$ rg --version
0.1.17
$ mkdir a
$ touch x y a/x a/y
$ echo a/ > .gitignore
$ ag . -l -g ''
x
y
$ ag $PWD -l -g ''
/Users/redacted/mess/current/example/x
/Users/redacted/mess/current/example/y
$ rg --files ignored .
./x
./y
$ rg --files ignored $PWD
/Users/redacted/mess/current/example/a/x
/Users/redacted/mess/current/example/a/y
/Users/redacted/mess/current/example/x
/Users/redacted/mess/current/example/y
$ echo a > .gitignore
$ rg --files ignored .
./x
./y
$ rg --files ignored $PWD
/Users/redacted/mess/current/example/x
/Users/redacted/mess/current/example/y
@BurntSushi
Copy link
Owner

Nice find. This is a dupe of #16.

@BurntSushi
Copy link
Owner

(Fix incoming.)

BurntSushi added a commit that referenced this issue Sep 24, 2016
We were erroneously neglecting to prefix a pattern like `foo/`
with `**/` (to make `**/foo/`) because it had a slash in it. In fact, the
only reason to neglect a **/ prefix is if the pattern already starts
with **/, or if the pattern is absolute.

Fixes #16, #49, #50, #65
amsharma91 added a commit to amsharma91/ripgrep that referenced this issue Sep 27, 2016
We were erroneously neglecting to prefix a pattern like `foo/`
with `**/` (to make `**/foo/`) because it had a slash in it. In fact, the
only reason to neglect a **/ prefix is if the pattern already starts
with **/, or if the pattern is absolute.

Fixes BurntSushi#16, BurntSushi#49, BurntSushi#50, BurntSushi#65
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

No branches or pull requests

2 participants