* [GSoC PATCH 0/2] add userdiff driver for gitconfig @ 2025-03-19 17:20 Lucas Seiki Oshiro 2025-03-19 17:20 ` [GSoC PATCH 1/2] userdiff: add builtin driver for gitconfig syntax Lucas Seiki Oshiro 2025-03-19 17:20 ` [GSoC PATCH 2/2] t4018: add tests for gitconfig in userdiff Lucas Seiki Oshiro 0 siblings, 2 replies; 7+ messages in thread From: Lucas Seiki Oshiro @ 2025-03-19 17:20 UTC (permalink / raw) To: git; +Cc: Lucas Seiki Oshiro Hi! Here's a simple patch, adding a userdiff driver for gitconfig files. This can be useful for people who use Git for versioning configuration files, like a dotfiles repository. This patchset also includes tests for it. Lucas Seiki Oshiro (2): userdiff: add builtin driver for gitconfig syntax t4018: add tests for gitconfig in userdiff t/t4018/gitconfig-section | 5 +++++ t/t4018/gitconfig-section-noindent | 5 +++++ t/t4018/gitconfig-subsection | 7 +++++++ t/t4018/gitconfig-subsection-noindent | 7 +++++++ userdiff.c | 4 ++++ 5 files changed, 28 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 -- 2.39.5 (Apple Git-154) ^ permalink raw reply [flat|nested] 7+ messages in thread
* [GSoC PATCH 1/2] userdiff: add builtin driver for gitconfig syntax 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 2025-03-20 8:38 ` Patrick Steinhardt 2025-03-19 17:20 ` [GSoC PATCH 2/2] t4018: add tests for gitconfig in userdiff Lucas Seiki Oshiro 1 sibling, 1 reply; 7+ messages in thread From: Lucas Seiki Oshiro @ 2025-03-19 17:20 UTC (permalink / raw) To: git; +Cc: Lucas Seiki Oshiro 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) ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [GSoC PATCH 1/2] userdiff: add builtin driver for gitconfig syntax 2025-03-19 17:20 ` [GSoC PATCH 1/2] userdiff: add builtin driver for gitconfig syntax Lucas Seiki Oshiro @ 2025-03-20 8:38 ` Patrick Steinhardt 2025-03-21 2:11 ` D. Ben Knoble 0 siblings, 1 reply; 7+ messages in thread From: Patrick Steinhardt @ 2025-03-20 8:38 UTC (permalink / raw) To: Lucas Seiki Oshiro; +Cc: git On Wed, Mar 19, 2025 at 02:20:15PM -0300, Lucas Seiki Oshiro wrote: > 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. > """ I don't think it's necessary to quote this whole paragraph here, as most of us should be quite familiar with its format. I'd rather summarize the info a bit and explain how we can use the userdiff patterns for the general structure of the config. And in case there are any subtleties in the format it may make sense to specifically point out those instead of quoting the whole manual. > 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; Okay, makes sense. > - word_regex is more permissive, matching any word with one or more > non-whitespace characters. It would be nice to provide context _why_ it is more permissive and what the effect is. The order of the commit message in our project is typically a bit different than what you have here: we first explain the actual problem that we aim to solve before discussing how you solve it. The code change itself looks sensible to me. Patrick ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [GSoC PATCH 1/2] userdiff: add builtin driver for gitconfig syntax 2025-03-20 8:38 ` Patrick Steinhardt @ 2025-03-21 2:11 ` D. Ben Knoble 0 siblings, 0 replies; 7+ messages in thread From: D. Ben Knoble @ 2025-03-21 2:11 UTC (permalink / raw) To: Patrick Steinhardt; +Cc: Lucas Seiki Oshiro, git On Thu, Mar 20, 2025 at 4:41 AM Patrick Steinhardt <ps@pks.im> wrote: > > On Wed, Mar 19, 2025 at 02:20:15PM -0300, Lucas Seiki Oshiro wrote: > > 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. > > """ > > I don't think it's necessary to quote this whole paragraph here, as most > of us should be quite familiar with its format. I'd rather summarize the > info a bit and explain how we can use the userdiff patterns for the > general structure of the config. And in case there are any subtleties in > the format it may make sense to specifically point out those instead of > quoting the whole manual. And, if we really felt it important to direct readers to the full text, we could instruct them to do something like `git show <sensible-hash>:Documentation/config.adoc`—in other words, the text is a part of this commit (and its parent) even if we don't (fully) quote it here. Cheers, Ben ^ permalink raw reply [flat|nested] 7+ messages in thread
* [GSoC PATCH 2/2] t4018: add tests for gitconfig in userdiff 2025-03-19 17:20 [GSoC PATCH 0/2] add userdiff driver for gitconfig Lucas Seiki Oshiro 2025-03-19 17:20 ` [GSoC PATCH 1/2] userdiff: add builtin driver for gitconfig syntax Lucas Seiki Oshiro @ 2025-03-19 17:20 ` Lucas Seiki Oshiro 2025-03-20 8:38 ` Patrick Steinhardt 1 sibling, 1 reply; 7+ messages in thread From: Lucas Seiki Oshiro @ 2025-03-19 17:20 UTC (permalink / raw) To: git; +Cc: Lucas Seiki Oshiro Add userdiff tests for gitconfig files. These files define sections and subsections, with and without indentation. Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> --- t/t4018/gitconfig-section | 5 +++++ t/t4018/gitconfig-section-noindent | 5 +++++ t/t4018/gitconfig-subsection | 7 +++++++ t/t4018/gitconfig-subsection-noindent | 7 +++++++ 4 files changed, 24 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..866aa70b24 --- /dev/null +++ b/t/t4018/gitconfig-section @@ -0,0 +1,5 @@ +[RIGHT] + # comment + ; comment + name = value + ChangeMe \ No newline at end of file diff --git a/t/t4018/gitconfig-section-noindent b/t/t4018/gitconfig-section-noindent new file mode 100644 index 0000000000..75a401b24b --- /dev/null +++ b/t/t4018/gitconfig-section-noindent @@ -0,0 +1,5 @@ +[RIGHT] +# comment +; comment +name = value +ChangeMe \ No newline at end of file diff --git a/t/t4018/gitconfig-subsection b/t/t4018/gitconfig-subsection new file mode 100644 index 0000000000..06243db626 --- /dev/null +++ b/t/t4018/gitconfig-subsection @@ -0,0 +1,7 @@ +[LEFT] + +[LEFT "RIGHT"] + # comment + ; comment + name = value + ChangeMe \ No newline at end of file diff --git a/t/t4018/gitconfig-subsection-noindent b/t/t4018/gitconfig-subsection-noindent new file mode 100644 index 0000000000..a100b81cf1 --- /dev/null +++ b/t/t4018/gitconfig-subsection-noindent @@ -0,0 +1,7 @@ +[LEFT] + +[LEFT "RIGHT"] +# comment +; comment +name = value +ChangeMe \ No newline at end of file -- 2.39.5 (Apple Git-154) ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [GSoC PATCH 2/2] t4018: add tests for gitconfig in userdiff 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 0 siblings, 1 reply; 7+ messages in thread From: Patrick Steinhardt @ 2025-03-20 8:38 UTC (permalink / raw) To: Lucas Seiki Oshiro; +Cc: git On Wed, Mar 19, 2025 at 02:20:16PM -0300, Lucas Seiki Oshiro wrote: > Add userdiff tests for gitconfig files. These files define sections and > subsections, with and without indentation. I think it would make sense to suqash this commit into the first one. > diff --git a/t/t4018/gitconfig-section b/t/t4018/gitconfig-section > new file mode 100644 > index 0000000000..866aa70b24 > --- /dev/null > +++ b/t/t4018/gitconfig-section > @@ -0,0 +1,5 @@ > +[RIGHT] > + # comment > + ; comment > + name = value > + ChangeMe > \ No newline at end of file You're missing newlines at the end of al test files. I don't think this is intentional, is it? Patrick ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [GSoC PATCH 2/2] t4018: add tests for gitconfig in userdiff 2025-03-20 8:38 ` Patrick Steinhardt @ 2025-03-23 16:08 ` Lucas Seiki Oshiro 0 siblings, 0 replies; 7+ messages in thread From: Lucas Seiki Oshiro @ 2025-03-23 16:08 UTC (permalink / raw) To: Patrick Steinhardt; +Cc: git > I think it would make sense to suqash this commit into the first one. Ok! I'll do that in a v2. > You're missing newlines at the end of al test files. I don't think this > is intentional, is it? No... somehow my text editor is not configured to do that. I'll fix it. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-03-23 16:08 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-03-19 17:20 [GSoC PATCH 0/2] add userdiff driver for gitconfig Lucas Seiki Oshiro 2025-03-19 17:20 ` [GSoC PATCH 1/2] userdiff: add builtin driver for gitconfig syntax Lucas Seiki Oshiro 2025-03-20 8:38 ` 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
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).