Skip to content

Commit b6029b3

Browse files
committed
userdiff: comment on the builtin patterns
Remind developers that they do not need to go overboard to implement patterns to prepare for invalid constructs. They only have to be sufficiently permissive, assuming that the payload is syntactically correct, and that may allow them to be simpler. Text stolen mostly from, and further improved by, Johannes Sixt. Signed-off-by: Junio C Hamano <[email protected]>
1 parent ebf3c04 commit b6029b3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

userdiff.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ static int drivers_alloc;
1313
#define IPATTERN(name, pattern, word_regex) \
1414
{ name, NULL, -1, { pattern, REG_EXTENDED | REG_ICASE }, \
1515
word_regex "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+" }
16+
17+
/*
18+
* Built-in drivers for various languages, sorted by their names
19+
* (except that the "default" is left at the end).
20+
*
21+
* When writing or updating patterns, assume that the contents these
22+
* patterns are applied to are syntactically correct. The patterns
23+
* can be simple without implementing all syntactical corner cases, as
24+
* long as they are sufficiently permissive.
25+
*/
1626
static struct userdiff_driver builtin_drivers[] = {
1727
IPATTERN("ada",
1828
"!^(.*[ \t])?(is[ \t]+new|renames|is[ \t]+separate)([ \t].*)?$\n"

0 commit comments

Comments
 (0)