From: Phillip Wood <phillip.wood123@gmail.com>
To: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>,
Phillip Wood <phillip.wood@dunelm.org.uk>,
git@vger.kernel.org
Cc: Jeff King <peff@peff.net>
Subject: Re: [PATCH] var: add GIT_COMMENT_STRING
Date: Wed, 25 Nov 2026 16:19:57 +0000 [thread overview]
Message-ID: <608b25cc-6ec8-4f0a-8eeb-863ed44bd0db@gmail.com> (raw)
In-Reply-To: <b8c40805-90f2-414c-ae70-e2f79a19170e@app.fastmail.com>
On 24/11/2026 15:02, Kristoffer Haugsbakk wrote:
> On Tue, Nov 24, 2026, at 11:37, Phillip Wood wrote:
>> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>>
>> Add GIT_COMMENT_STRING to "git var" to make it easier for scripts to
>> determine the comment character.
>
> s/determine the comment character/determine the comment string/ ?
Yes, that would be more consistent
>> diff --git a/Documentation/git-var.adoc b/Documentation/git-var.adoc
>> index 5f240eb56e3..04aeccd7aa6 100644
>> --- a/Documentation/git-var.adoc
>> +++ b/Documentation/git-var.adoc
>> @@ -130,6 +130,10 @@ endif::git-default-pager[]
>> The path to the global (per-user) configuration files, if any.
>> This variable can have multiple values.
>>
>> +`GIT_COMMENT_STRING`::
>> + The comment string used in template commit messages and rebase todo
>> + lists etc.
>
> This could also mention the config variables and git-config(1)?
I had decided not do to that as the point of GIT_COMMENT_STRING is to be
able to query the comment string without the user having to worry about
the intricacies of the config setting or what the default value is. I
guess saying "see `core.commentString` and `core.commentChar`in
git-config(1)" doesn't really do any harm but I don't think users are
going to get much additional useful information by reading the config
documentation. Perhaps saying "as set by `core.commentString`" would be
more better as it does not promise the reader that the config
documentation contains additional, useful, information?
The documentation for GIT_PAGER, GIT_EDITOR and GIT_SEQUENCE_EDITOR
mention the relevant config settings when describing how we determine
which program to use, but the documentation for things like
GIT_DEFAULT_BRANCH does do not.
I have added a note to the documentation for `core.commentString` that
the comment string can be queried with `git var GIT_COMMENT_STRING`
Thanks
Phillip
>
>> +
>> `GIT_HOSTNAME`::
>> The hostname of the machine, as reported by the operating system.
>> This is the hostname matched by `includeIf "hostname:..."` (see
>> diff --git a/builtin/var.c b/builtin/var.c
>> index eb85a985b15..6dc8ec4ba9f 100644
>> --- a/builtin/var.c
>> +++ b/builtin/var.c
>> @@ -188,6 +188,11 @@ static char *hostname(int ident_flag UNUSED)
>> return xstrdup(buf);
>> }
>>
>> +static char *comment_string(int ident_flag UNUSED)
>> +{
>> + return xstrdup(comment_line_str);
>> +}
>> +
>> struct git_var {
>> const char *name;
>> char *(*read)(int);
>> @@ -262,6 +267,10 @@ static struct git_var git_vars[] = {
>> .name = "GIT_CONFIG_GLOBAL",
>> .multiread = git_config_val_global,
>> },
>> + {
>> + .name = "GIT_COMMENT_STRING",
>> + .read = comment_string,
>> + },
>> {
>> .name = "GIT_HOSTNAME",
>> .read = hostname,
>> diff --git a/t/t0007-git-var.sh b/t/t0007-git-var.sh
>> index 883a45399e2..f228cb5bb6f 100755
>> --- a/t/t0007-git-var.sh
>> +++ b/t/t0007-git-var.sh
>> @@ -434,4 +434,14 @@ test_expect_success 'git var -l lists the identity
>> components' '
>> test_grep "^GIT_COMMITTER_DATE=" actual
>> '
>>
>> +test_expect_success 'GIT_COMMENT_STRING' '
>> + git var GIT_COMMENT_STRING >actual &&
>> + echo "#" >expect &&
>> + test_cmp expect actual &&
>
> This tests the default.
>
>> + git -c core.commentChar=: -c core.commentString=%% \
>> + var GIT_COMMENT_STRING >actual &&
>> + echo %%>expect &&
>> + test_cmp expect actual
>
> Then it tests that `commentString` overriding `*Char` works as it
> should. That makes sense and seems to cover all testing bases.
>
> This happens if you have an invalid comment string:
>
> $ bin-wrappers/git -c core.commentString= var GIT_COMMENT_STRING
> error: core.commentstring must have at least one character
> fatal: unable to parse 'core.commentstring' from command-line config
>
> With non-zero exit status.
>
>> +'
>> +
>> test_done
>> --
>> 2.56.1.576.g0cfbda1d5c7.dirty
>
next prev parent reply other threads:[~2026-11-25 16:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 10:37 [PATCH] var: add GIT_COMMENT_STRING Phillip Wood
2026-11-24 15:02 ` Kristoffer Haugsbakk
2026-11-25 16:19 ` Phillip Wood [this message]
2026-11-25 20:09 ` Kristoffer Haugsbakk
2026-11-26 16:29 ` Phillip Wood
2026-11-24 20:24 ` Junio C Hamano
2026-11-26 16:25 ` [PATCH v2] " Phillip Wood
2026-11-26 20:56 ` Junio C Hamano
2026-11-27 16:42 ` Phillip Wood
2026-11-26 21:14 ` Kristoffer Haugsbakk
2026-11-29 16:18 ` [PATCH v3] " Phillip Wood
2026-11-29 19:15 ` 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=608b25cc-6ec8-4f0a-8eeb-863ed44bd0db@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=kristofferhaugsbakk@fastmail.com \
--cc=peff@peff.net \
--cc=phillip.wood@dunelm.org.uk \
/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.