Skip to content

Commit 4338005

Browse files
lucasoshirogitster
authored andcommitted
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 <[email protected]> Helped-by: D. Ben Knoble <[email protected]> Signed-off-by: Lucas Seiki Oshiro <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 683c54c commit 4338005

File tree

6 files changed

+42
-0
lines changed

6 files changed

+42
-0
lines changed

t/t4018/ini-section

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[RIGHT]
2+
# comment
3+
; comment
4+
name = value
5+
ChangeMe

t/t4018/ini-section-noindent

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[RIGHT]
2+
# comment
3+
; comment
4+
name = value
5+
ChangeMe

t/t4018/ini-section-same-line

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[RIGHT] name = value
2+
# comment
3+
; comment
4+
ChangeMe

t/t4018/ini-subsection

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ PATTERNS("html",
211211
"^[ \t]*(<[Hh][1-6]([ \t].*)?>.*)$",
212212
/* -- */
213213
"[^<>= \t]+"),
214+
PATTERNS("ini",
215+
"^[ \t]*\\[[^]]+\\]",
216+
/* -- */
217+
"[^ \t]+"),
214218
PATTERNS("java",
215219
"!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
216220
/* Class, enum, interface, and record declarations */

0 commit comments

Comments
 (0)