From Documentation/config.adoc:
Add a new builtin driver for gitconfig files, where:
- the funcname regular expression matches sections and subsections, i. e. the pattern [SECTION] or [SECTION "SUBSECTION"], where the section is composed by alphanumeric numbers, `-` and `.`, and subsection names may be composed by any characters;
- word_regex is more permissive than the syntax specification, matching any word with one or more non-whitespace characters without checking if it is a valid variable name or value.
A more detailed description on the format of gitconfig syntax can be seen by running `git show cfd409:Documentation/config.txt`.
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> ---
Hi!
This v2 removes the quoted text from the commit message, using a reference to the documentation file and the commit that last changed the lines where it was copied before.
I'm also adding the missing newlines at the end of the test files.
t/t4018/gitconfig-section | 6 ++++++ t/t4018/gitconfig-section-noindent | 6 ++++++ t/t4018/gitconfig-subsection | 8 ++++++++ t/t4018/gitconfig-subsection-noindent | 8 ++++++++ userdiff.c | 4 ++++ 5 files changed, 32 insertions(+) create mode 100644 t/t4018/gitconfig-section create mode 100644 t/t4018/gitconfig-section-noindent create mode 100644 t/t4018/gitconfig-subsection create mode 100644 t/t4018/gitconfig-subsection-noindent
Show changes to 5 files +32 −0
t/t4018/gitconfig-section, t/t4018/gitconfig-section-noindent, t/t4018/gitconfig-subsection, t/t4018/gitconfig-subsection-noindent, userdiff.c
diff --git a/t/t4018/gitconfig-section b/t/t4018/gitconfig-section new file mode 100644 index 0000000000..18c85eb613 --- /dev/null +++ b/t/t4018/gitconfig-section @@ -0,0 +1,6 @@ +[RIGHT] + # comment + ; comment + name = value + ChangeMe + diff --git a/t/t4018/gitconfig-section-noindent b/t/t4018/gitconfig-section-noindent new file mode 100644 index 0000000000..5c58a7ac92 --- /dev/null +++ b/t/t4018/gitconfig-section-noindent @@ -0,0 +1,6 @@ +[RIGHT] +# comment +; comment +name = value +ChangeMe + diff --git a/t/t4018/gitconfig-subsection b/t/t4018/gitconfig-subsection new file mode 100644 index 0000000000..569be04a32 --- /dev/null +++ b/t/t4018/gitconfig-subsection @@ -0,0 +1,8 @@ +[LEFT] + +[LEFT "RIGHT"] + # comment + ; comment + name = value + ChangeMe + diff --git a/t/t4018/gitconfig-subsection-noindent b/t/t4018/gitconfig-subsection-noindent new file mode 100644 index 0000000000..85c5074f47 --- /dev/null +++ b/t/t4018/gitconfig-subsection-noindent @@ -0,0 +1,8 @@ +[LEFT] + +[LEFT "RIGHT"] +# comment +; comment +name = value +ChangeMe + diff --git a/userdiff.c b/userdiff.c index 340c4eb4f7..5bbcc2b690 100644 --- a/userdiff.c +++ b/userdiff.c @@ -198,6 +198,10 @@ IPATTERN("fountain", "^((\\.[^.]|(int|ext|est|int\\.?/ext|i/e)[. ]).*)$", /* -- */ "[^ \t-]+"), +PATTERNS("gitconfig", + "^\\[[a-zA-Z0-9]+\\]|\\[[a-zA-Z0-9]+[ \t]+\".+\"\\]$", + /* -- */ + "[^ \t]+"), PATTERNS("golang", /* Functions */ "^[ \t]*(func[ \t]*.*(\\{[ \t]*)?)\n"
-- 2.39.5 (Apple Git-154)