mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-03-03 14:32:22 +02:00
ignore: fix bug in matched_path_or_any_parents
This method was supposed to panic whenever the given path wasn't under the root of the gitignore patcher. Instead of using assert!, it was using debug_assert!. This actually caused tests to fail when running under release mode, because the debug_assert! wouldn't trip. Fixes #671
This commit is contained in:
parent
d94d99f657
commit
0863c75a5a
@ -220,6 +220,11 @@ impl Gitignore {
|
|||||||
/// determined by a common suffix of the directory containing this
|
/// determined by a common suffix of the directory containing this
|
||||||
/// gitignore) is stripped. If there is no common suffix/prefix overlap,
|
/// gitignore) is stripped. If there is no common suffix/prefix overlap,
|
||||||
/// then `path` is assumed to be relative to this matcher.
|
/// then `path` is assumed to be relative to this matcher.
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// This method panics if the given file path is not under the root path
|
||||||
|
/// of this matcher.
|
||||||
pub fn matched_path_or_any_parents<P: AsRef<Path>>(
|
pub fn matched_path_or_any_parents<P: AsRef<Path>>(
|
||||||
&self,
|
&self,
|
||||||
path: P,
|
path: P,
|
||||||
@ -229,10 +234,8 @@ impl Gitignore {
|
|||||||
return Match::None;
|
return Match::None;
|
||||||
}
|
}
|
||||||
let mut path = self.strip(path.as_ref());
|
let mut path = self.strip(path.as_ref());
|
||||||
debug_assert!(
|
assert!(!path.has_root(), "path is expect to be under the root");
|
||||||
!path.has_root(),
|
|
||||||
"path is expect to be under the root"
|
|
||||||
);
|
|
||||||
match self.matched_stripped(path, is_dir) {
|
match self.matched_stripped(path, is_dir) {
|
||||||
Match::None => (), // walk up
|
Match::None => (), // walk up
|
||||||
a_match => return a_match,
|
a_match => return a_match,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user