Skip to content

Commit

Permalink
fix another issue around double-star (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Apr 13, 2022
1 parent 09095df commit d15c2fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions git-glob/src/wildmatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,10 @@ pub(crate) mod function {
&& next.map_or(true, |(_, c)| {
c == SLASH || (c == BACKSLASH && p.peek().map(|t| t.1) == Some(SLASH))
})
&& next.map_or(false, |t| t.1 == SLASH)
{
if match_recursive(
pattern[next.expect("checked prior").0 + 1..].as_bstr(),
text[t_idx..].as_bstr(),
mode,
) == Match
if next.map_or(NoMatch, |(idx, _)| {
match_recursive(pattern[idx + 1..].as_bstr(), text[t_idx..].as_bstr(), mode)
}) == Match
{
return Match;
}
Expand Down
4 changes: 2 additions & 2 deletions git-glob/tests/wildmatch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ fn corpus() {

#[test]
fn simple_double_star() {
let (_pattern, actual) = multi_match("**/bar**", "foo/bar/baz");
let (_pattern, actual) = multi_match("test/**", "test/one/two");
assert!(!actual.any_panicked());
assert_eq!(actual, expect_multi(0, 0, 1, 1));
assert_eq!(actual, expect_multi(1, 1, 1, 1));
}

fn multi_match(pattern_text: &str, text: &str) -> (Pattern, MultiMatch) {
Expand Down

0 comments on commit d15c2fb

Please sign in to comment.