Skip to content

Commit 05df1cd

Browse files
committed
Pred: parse add pathspec patterns of the form 'add <PATTERN>'
These are equivalent to the non prefixed patterns and are added only for completeness.
1 parent 3f543fb commit 05df1cd

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/pred.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ let error_msg s =
3737
Printf.sprintf "bad pattern: %s\n\
3838
A pattern must be introduced by one of the following keywords:\n\
3939
\032 Regex, Name, Path, BelowPath, NameString, String, BelowString\n\
40-
\032 (or del <KEYWORD> or assoc <KEYWORD>)." s
40+
\032 (or add <KEYWORD> or del <KEYWORD> or assoc <KEYWORD>)." s
4141

42+
let addPref = "add "
4243
let delPref = "del "
4344
let assocPref = "assoc "
4445

@@ -58,6 +59,7 @@ let rec select_pattern str l err =
5859
[] -> err str
5960
| (pref, g)::r ->
6061
if Util.startswith str pref then `Alt (rest pref g)
62+
else if Util.startswith str (addPref^pref) then `Alt (rest (addPref^pref) g)
6163
else if Util.startswith str (delPref^pref) then `Dif (rest (delPref^pref) g)
6264
else if Util.startswith str (assocPref^pref) then `Nul (rest (assocPref^pref) g)
6365
else select_pattern str r err

src/pred.mli

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
Seven assoc only patterns "assoc <TYPE>" are also recognized that record the
3737
associated string but do not set the preference for the paths matching the
3838
given pattern.
39+
40+
Seven patterns "add <TYPE>" are also recognized that are equivalent to the
41+
non prefixed patterns.
3942
*)
4043

4144

0 commit comments

Comments
 (0)