From: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
To: git@vger.kernel.org
Cc: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>,
Patrick Steinhardt <ps@pks.im>,
"D . Ben Knoble" <ben.knoble@gmail.com>
Subject: [GSoC PATCH v2] userdiff: add builtin driver for gitconfig syntax
Date: Sun, 23 Mar 2025 23:11:01 -0300 [thread overview]
Message-ID: <20250324021101.7483-1-lucasseikioshiro@gmail.com> (raw)
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
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)
next reply other threads:[~2025-03-24 2:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-24 2:11 Lucas Seiki Oshiro [this message]
2025-03-24 7:18 ` [GSoC PATCH v2] userdiff: add builtin driver for gitconfig syntax Johannes Sixt
2025-03-24 20:23 ` D. Ben Knoble
2025-03-25 18:34 ` Lucas Seiki Oshiro
2025-03-24 9:43 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250324021101.7483-1-lucasseikioshiro@gmail.com \
--to=lucasseikioshiro@gmail.com \
--cc=ben.knoble@gmail.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).