mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-07-11 14:30:24 +02:00
Fix: strip standalone "." directory path
The problem is that in Ignore::matched, the perfix "./" is stripped from files. In Ignore::matched_ignore, the directory path is then stripped from file paths. Now imagine we have a hidden file "./.foo" and pass "." as the search path. "./.foo" gets first stripped to ".foo" and then it would have been stripped to "foo".
This commit is contained in:
@ -462,9 +462,13 @@ impl Ignore {
|
|||||||
// it does fix a nasty bug. It should do fine until we overhaul
|
// it does fix a nasty bug. It should do fine until we overhaul
|
||||||
// this crate.
|
// this crate.
|
||||||
let dirpath = self.0.dir.as_path();
|
let dirpath = self.0.dir.as_path();
|
||||||
let path_prefix = match strip_prefix("./", dirpath) {
|
let path_prefix = if dirpath == Path::new(".") {
|
||||||
|
Path::new("")
|
||||||
|
} else {
|
||||||
|
match strip_prefix("./", dirpath) {
|
||||||
None => dirpath,
|
None => dirpath,
|
||||||
Some(stripped_dot_slash) => stripped_dot_slash,
|
Some(stripped_dot_slash) => stripped_dot_slash,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let path = match strip_prefix(path_prefix, path) {
|
let path = match strip_prefix(path_prefix, path) {
|
||||||
None => abs_parent_path.join(path),
|
None => abs_parent_path.join(path),
|
||||||
|
Reference in New Issue
Block a user