All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
To: git@vger.kernel.org
Cc: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Subject: [GSoC PATCH 1/2] userdiff: add builtin driver for gitconfig syntax
Date: Wed, 19 Mar 2025 14:20:15 -0300	[thread overview]
Message-ID: <20250319172016.2115-2-lucasseikioshiro@gmail.com> (raw)
In-Reply-To: <20250319172016.2115-1-lucasseikioshiro@gmail.com>

From Documentation/config.adoc:

"""
The file consists of sections and variables. A section begins with
the name of the section in square brackets and continues until the next
section begins. Section names are case-insensitive. Only alphanumeric
characters, `-` and `.` are allowed in section names. Each variable
must belong to some section, which means that there must be a section
header before the first setting of a variable.

[...]

Subsection names are case sensitive and can contain any characters except
newline and the null byte.

The variable names are case-insensitive, allow only alphanumeric characters
and `-`, and must start with an alphabetic character.
"""

Then, 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, matching any word with one or more
  non-whitespace characters.

Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
 userdiff.c | 4 ++++
 1 file changed, 4 insertions(+)

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)


  reply	other threads:[~2025-03-19 17:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-19 17:20 [GSoC PATCH 0/2] add userdiff driver for gitconfig Lucas Seiki Oshiro
2025-03-19 17:20 ` Lucas Seiki Oshiro [this message]
2025-03-20  8:38   ` [GSoC PATCH 1/2] userdiff: add builtin driver for gitconfig syntax Patrick Steinhardt
2025-03-21  2:11     ` D. Ben Knoble
2025-03-19 17:20 ` [GSoC PATCH 2/2] t4018: add tests for gitconfig in userdiff Lucas Seiki Oshiro
2025-03-20  8:38   ` Patrick Steinhardt
2025-03-23 16:08     ` Lucas Seiki Oshiro

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=20250319172016.2115-2-lucasseikioshiro@gmail.com \
    --to=lucasseikioshiro@gmail.com \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.