From: Lucas Seiki Oshiro Date: Mon, 31 Mar 2025 03:13:09 +0000 (-0300) Subject: userdiff: add builtin driver for INI files X-Git-Tag: v2.50.0-rc0~122^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=43380056df44aed6e074689dc8bc940f9dc6e2c8;p=thirdparty%2Fgit.git 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 Helped-by: D. Ben Knoble Signed-off-by: Lucas Seiki Oshiro Signed-off-by: Junio C Hamano --- diff --git a/t/t4018/ini-section b/t/t4018/ini-section new file mode 100644 index 0000000000..c895ad9b4f --- /dev/null +++ b/t/t4018/ini-section @@ -0,0 +1,5 @@ +[RIGHT] + # comment + ; comment + name = value + ChangeMe diff --git a/t/t4018/ini-section-noindent b/t/t4018/ini-section-noindent new file mode 100644 index 0000000000..733d23c801 --- /dev/null +++ b/t/t4018/ini-section-noindent @@ -0,0 +1,5 @@ +[RIGHT] +# comment +; comment +name = value +ChangeMe diff --git a/t/t4018/ini-section-same-line b/t/t4018/ini-section-same-line new file mode 100644 index 0000000000..522a1fa4a1 --- /dev/null +++ b/t/t4018/ini-section-same-line @@ -0,0 +1,4 @@ +[RIGHT] name = value + # comment + ; comment + ChangeMe diff --git a/t/t4018/ini-subsection b/t/t4018/ini-subsection new file mode 100644 index 0000000000..3d47349e60 --- /dev/null +++ b/t/t4018/ini-subsection @@ -0,0 +1,12 @@ +[LEFT] + + [LEFT "CENTER"] + # comment + ; comment + name = value + + [LEFT "RIGHT"] + # comment + ; comment + name = value + ChangeMe diff --git a/t/t4018/ini-subsection-noindent b/t/t4018/ini-subsection-noindent new file mode 100644 index 0000000000..698ea00ea3 --- /dev/null +++ b/t/t4018/ini-subsection-noindent @@ -0,0 +1,12 @@ +[LEFT] + +[LEFT "CENTER"] +# comment +; comment +name = value + +[LEFT "RIGHT"] +# comment +; comment +name = value +ChangeMe diff --git a/userdiff.c b/userdiff.c index 340c4eb4f7..da75625020 100644 --- a/userdiff.c +++ b/userdiff.c @@ -211,6 +211,10 @@ PATTERNS("html", "^[ \t]*(<[Hh][1-6]([ \t].*)?>.*)$", /* -- */ "[^<>= \t]+"), +PATTERNS("ini", + "^[ \t]*\\[[^]]+\\]", + /* -- */ + "[^ \t]+"), PATTERNS("java", "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n" /* Class, enum, interface, and record declarations */