Skip to content

Commit

Permalink
fix double-star matches (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Apr 13, 2022
1 parent e5a7995 commit 43371b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
5 changes: 3 additions & 2 deletions git-glob/src/wildmatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub(crate) mod function {
}
}
STAR => {
let match_slash = mode.contains(Mode::SLASH_IS_LITERAL).then(|| false).unwrap_or(true);
let mut match_slash = mode.contains(Mode::SLASH_IS_LITERAL).then(|| false).unwrap_or(true);
match p.next() {
Some((next_p_idx, next_p_ch)) => {
let next;
Expand All @@ -91,6 +91,7 @@ pub(crate) mod function {
{
return Match;
}
match_slash = true;
}
} else {
next = Some((next_p_idx, next_p_ch));
Expand All @@ -102,7 +103,7 @@ pub(crate) mod function {
NoMatch
} else {
Match
}
};
}
Some((next_p_idx, next_p_ch)) => {
(p_idx, p_ch) = (next_p_idx, next_p_ch);
Expand Down
9 changes: 1 addition & 8 deletions git-glob/tests/wildmatch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,9 @@ fn corpus() {
// 1 1 1 1 foo/bba/arr 'foo**'
}

#[test]
fn simple_star_boundary() {
let (_pattern, actual) = multi_match("*foo*", "foo");
assert!(!actual.any_panicked());
assert_eq!(actual, expect_multi(1, 1, 1, 1));
}

#[test]
fn simple_double_star() {
let (_pattern, actual) = multi_match("some/**/needle.txt", "some/one/needle.txt");
let (_pattern, actual) = multi_match("foo/**/bar", "foo/a/b/bar");
assert!(!actual.any_panicked());
assert_eq!(actual, expect_multi(1, 1, 1, 1));
}
Expand Down

0 comments on commit 43371b6

Please sign in to comment.