]> git.ipfire.org Git - thirdparty/git.git/commitdiff
userdiff: comment on the builtin patterns
authorJunio C Hamano <gitster@pobox.com>
Tue, 10 Aug 2021 22:12:01 +0000 (15:12 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 11 Aug 2021 18:02:59 +0000 (11:02 -0700)
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 <gitster@pobox.com>
userdiff.c

index 3c3bbe38b048dbbcf968699bb65a83fb2646032e..2eb8d7b8ef3204fdf690c641520dad2c1757de1d 100644 (file)
@@ -13,6 +13,16 @@ static int drivers_alloc;
 #define IPATTERN(name, pattern, word_regex)                    \
        { name, NULL, -1, { pattern, REG_EXTENDED | REG_ICASE }, \
          word_regex "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+" }
+
+/*
+ * Built-in drivers for various languages, sorted by their names
+ * (except that the "default" is left at the end).
+ *
+ * When writing or updating patterns, assume that the contents these
+ * patterns are applied to are syntactically correct.  The patterns
+ * can be simple without implementing all syntactical corner cases, as
+ * long as they are sufficiently permissive.
+ */
 static struct userdiff_driver builtin_drivers[] = {
 IPATTERN("ada",
         "!^(.*[ \t])?(is[ \t]+new|renames|is[ \t]+separate)([ \t].*)?$\n"