diff --git a/docs/revsets.md b/docs/revsets.md index b32e97651..cbba30ed3 100644 --- a/docs/revsets.md +++ b/docs/revsets.md @@ -141,8 +141,8 @@ revsets (expressions) as arguments. Functions that perform string matching support the following pattern syntax. -* `"substring"`: Matches strings that contain `substring`. -* `literal:"string"`: Matches strings exactly equal to `string`. +* `"string"`, `substring:"string"`: Matches strings that contain `string`. +* `literal:"string"`: Matches strings exactly equal to `string`. ## Aliases diff --git a/lib/src/revset.rs b/lib/src/revset.rs index 5097578f4..efc3e95a3 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -1324,7 +1324,7 @@ fn parse_function_argument_to_string_pattern( }; match kind.as_ref() { "literal" => StringPattern::Literal(needle.clone()), - // TODO: maybe add explicit kind for substring match? + "substring" => StringPattern::Substring(needle.clone()), _ => { // TODO: error span can be narrowed to the lhs node return Err(make_error(format!( @@ -2699,6 +2699,12 @@ mod tests { "foo".to_owned() ))) ); + assert_eq!( + parse(r#"branches(substring:"foo")"#), + Ok(RevsetExpression::branches(StringPattern::Substring( + "foo".to_owned() + ))) + ); assert_eq!( parse(r#"branches("literal:foo")"#), Ok(RevsetExpression::branches(StringPattern::Substring(