userdiff: add builtin driver for INI files
Add a new builtin driver for generic INI files (e. g. the gitconfig files), where: - the funcname regular expression matches section names, i. e. any string between brackets at the beginning of the line, with or without indentation; - word_regex matches any word with one or more non-whitespace characters without checking if it is a valid variable name or value. Also add tests for the new userdiff driver. These files define sections and subsections, with and without indentation. Helped-by: Patrick Steinhardt <ps@pks.im> Helped-by: D. Ben Knoble <ben.knoble@gmail.com> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Lucas Seiki Oshiro committed
Mar 31, 2025 at 00:13 UTC
43380056df44aed6e074689dc8bc940f9dc6e2c8
6 files changed
+42
t/t4018/ini-section
new
+5
@@ -0,0 +1,5 @@
1
+[RIGHT]
2
+ # comment
3
+ ; comment
4
+ name = value
5
+ ChangeMe
t/t4018/ini-section-noindent
new
+5
@@ -0,0 +1,5 @@
1
+[RIGHT]
2
+# comment
3
+; comment
4
+name = value
5
+ChangeMe
t/t4018/ini-section-same-line
new
+4
@@ -0,0 +1,4 @@
1
+[RIGHT] name = value
2
+ # comment
3
+ ; comment
4
+ ChangeMe
t/t4018/ini-subsection
new
+12
@@ -0,0 +1,12 @@
1
+[LEFT]
2
+
3
+ [LEFT "CENTER"]
4
+ # comment
5
+ ; comment
6
+ name = value
7
+
8
+ [LEFT "RIGHT"]
9
+ # comment
10
+ ; comment
11
+ name = value
12
+ ChangeMe
t/t4018/ini-subsection-noindent
new
+12
@@ -0,0 +1,12 @@
1
+[LEFT]
2
+
3
+[LEFT "CENTER"]
4
+# comment
5
+; comment
6
+name = value
7
+
8
+[LEFT "RIGHT"]
9
+# comment
10
+; comment
11
+name = value
12
+ChangeMe
userdiff.c
+4
@@ -211,6 +211,10 @@ PATTERNS("html",
211
"^[ \t]*(<[Hh][1-6]([ \t].*)?>.*)$",
212
/* -- */
213
"[^<>= \t]+"),
214
+PATTERNS("ini",
215
+ "^[ \t]*\\[[^]]+\\]",
216
+ /* -- */
217
+ "[^ \t]+"),
218
PATTERNS("java",
219
"!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
220
/* Class, enum, interface, and record declarations */