From 0863c75a5a819dc94754f3465246366ffd5d541f Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 29 Jul 2018 08:30:53 -0400 Subject: [PATCH] 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 --- ignore/src/gitignore.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ignore/src/gitignore.rs b/ignore/src/gitignore.rs index 2a3016b..d661c84 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>( &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,