git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[GSoC PATCH 1/2] userdiff: add builtin driver for gitconfig syntax

From
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Date
Mar 19, 2025, 17:20 UTC
Message-ID
<20250319172016.2115-2-lucasseikioshiro@gmail.com>
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)
Previous: Lucas Seiki OshiroNext: Patrick Steinhardt
Message 2 of 7 in “add userdiff driver for gitconfig”
  1. 0/2 add userdiff driver for gitconfigLucas Seiki Oshiro, Mar 19, 2025
  2. 1/2 userdiff: add builtin driver for gitconfig syntaxLucas Seiki Oshiro, Mar 19, 2025
  3. Patrick SteinhardtMar 20, 2025
  4. D. Ben KnobleMar 21, 2025
  5. 2/2 t4018: add tests for gitconfig in userdiffLucas Seiki Oshiro, Mar 19, 2025
  6. Patrick SteinhardtMar 20, 2025
  7. Lucas Seiki OshiroMar 23, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.