[ignore] Fix matched_path_or_any_parents() for patterns ending in slash
In `matched_path_or_any_parents()` implementation, we missed the point that when we start walking up the tree, we have to set `is_dir` to `true`, so path `ROOT/a/b/c` matches pattern `/a/`, although the original path is not a dir.
This commit is contained in:
committed by
Andrew Gallant
parent
1c03298903
commit
0668c74ed4
@@ -220,15 +220,17 @@ impl Gitignore {
|
||||
!path.has_root(),
|
||||
"path is expect to be under the root"
|
||||
);
|
||||
loop {
|
||||
match self.matched_stripped(path, is_dir) {
|
||||
Match::None => match path.parent() {
|
||||
Some(parent) => path = parent,
|
||||
None => return Match::None,
|
||||
},
|
||||
match self.matched_stripped(path, is_dir) {
|
||||
Match::None => (), // walk up
|
||||
a_match => return a_match,
|
||||
}
|
||||
while let Some(parent) = path.parent() {
|
||||
match self.matched_stripped(parent, /* is_dir */ true) {
|
||||
Match::None => path = parent, // walk up
|
||||
a_match => return a_match,
|
||||
}
|
||||
}
|
||||
Match::None
|
||||
}
|
||||
|
||||
/// Like matched, but takes a path that has already been stripped.
|
||||
|
||||
Reference in New Issue
Block a user