summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2018-07-29 08:30:53 -0400
committerAndrew Gallant <jamslam@gmail.com>2018-07-29 08:30:53 -0400
commit0863c75a5a819dc94754f3465246366ffd5d541f (patch)
treeec493cc3b6ead150845e43218e92f2169dfa7a69
parentd94d99f657b10d40a2f4ec0233d7b05e5c317bc6 (diff)
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
-rw-r--r--ignore/src/gitignore.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/ignore/src/gitignore.rs b/ignore/src/gitignore.rs
index 2a3016b8..d661c848 100644
--- a/ignore/src/gitignore.rs
+++ b/ignore/src/gitignore.rs
@@ -220,6 +220,11 @@ impl Gitignore {
/// determined by a common suffix of the directory containing this
/// gitignore) is stripped. If there is no common suffix/prefix overlap,
/// 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>>(
&self,
path: P,
@@ -229,10 +234,8 @@ impl Gitignore {
return Match::None;
}
let mut path = self.strip(path.as_ref());
- debug_assert!(
- !path.has_root(),
- "path is expect to be under the root"
- );
+ assert!(!path.has_root(), "path is expect to be under the root");
+
match self.matched_stripped(path, is_dir) {
Match::None => (), // walk up
a_match => return a_match,