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>
This commit is contained in:
committed by
Junio C Hamano
parent
683c54c999
commit
43380056df
5
t/t4018/ini-section
Normal file
5
t/t4018/ini-section
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[RIGHT]
|
||||||
|
# comment
|
||||||
|
; comment
|
||||||
|
name = value
|
||||||
|
ChangeMe
|
||||||
5
t/t4018/ini-section-noindent
Normal file
5
t/t4018/ini-section-noindent
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[RIGHT]
|
||||||
|
# comment
|
||||||
|
; comment
|
||||||
|
name = value
|
||||||
|
ChangeMe
|
||||||
4
t/t4018/ini-section-same-line
Normal file
4
t/t4018/ini-section-same-line
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[RIGHT] name = value
|
||||||
|
# comment
|
||||||
|
; comment
|
||||||
|
ChangeMe
|
||||||
12
t/t4018/ini-subsection
Normal file
12
t/t4018/ini-subsection
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[LEFT]
|
||||||
|
|
||||||
|
[LEFT "CENTER"]
|
||||||
|
# comment
|
||||||
|
; comment
|
||||||
|
name = value
|
||||||
|
|
||||||
|
[LEFT "RIGHT"]
|
||||||
|
# comment
|
||||||
|
; comment
|
||||||
|
name = value
|
||||||
|
ChangeMe
|
||||||
12
t/t4018/ini-subsection-noindent
Normal file
12
t/t4018/ini-subsection-noindent
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[LEFT]
|
||||||
|
|
||||||
|
[LEFT "CENTER"]
|
||||||
|
# comment
|
||||||
|
; comment
|
||||||
|
name = value
|
||||||
|
|
||||||
|
[LEFT "RIGHT"]
|
||||||
|
# comment
|
||||||
|
; comment
|
||||||
|
name = value
|
||||||
|
ChangeMe
|
||||||
@@ -211,6 +211,10 @@ PATTERNS("html",
|
|||||||
"^[ \t]*(<[Hh][1-6]([ \t].*)?>.*)$",
|
"^[ \t]*(<[Hh][1-6]([ \t].*)?>.*)$",
|
||||||
/* -- */
|
/* -- */
|
||||||
"[^<>= \t]+"),
|
"[^<>= \t]+"),
|
||||||
|
PATTERNS("ini",
|
||||||
|
"^[ \t]*\\[[^]]+\\]",
|
||||||
|
/* -- */
|
||||||
|
"[^ \t]+"),
|
||||||
PATTERNS("java",
|
PATTERNS("java",
|
||||||
"!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
|
"!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
|
||||||
/* Class, enum, interface, and record declarations */
|
/* Class, enum, interface, and record declarations */
|
||||||
|
|||||||
Reference in New Issue
Block a user