Skip to content

filters don't work correctly when a search path is specified #278

@nu4nu

Description

@nu4nu

ripgrep seems to ignore unintended files when the base directory is not the current directory.

How to reproduce:

% mkdir -p ../test/foo
% echo '.*' >../test/.gitignore
% echo baz >../test/foo/bar

% rg baz ../test
../test/foo/bar
1:baz

% rg baz ../test/foo
No files were searched, which means ripgrep probably applied a filter you didn't expect. Try running again with --debug.

I found the following lines in ignore/src/dir.rs don't make sense because path on the right side is a relative path from the current directory, not from abs_parent_path.

339         if let Some(abs_parent_path) = self.absolute_base() {
340             let path = abs_parent_path.join(path);

A possible fix to run the example above correctly is the following. However, I'm not sure this fixes other cases.

let path = path.canonicalize().unwrap()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bug.gitignoreBugs related to gitignore problems.iceboxA feature that is recognized as possibly desirable, but is unlikely to implemented any time soon.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions