From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: Andrew Pleeter via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org,
"brian m. carlson" <sandals@crustytoothpaste.net>,
Jeff King <peff@peff.net>,
Andrew Pleeter <andrewpleeter@gmail.com>
Subject: Re: [PATCH v3] var: support broken-down idents, default key, multiple args, and -z
Date: Fri, 04 Sep 2026 08:57:33 -0700 [thread overview]
Message-ID: <xmqqqzj957rm.fsf@gitster.g> (raw)
In-Reply-To: <5634fdc4-d0f8-493d-b401-3c9753524034@gmail.com> (Phillip Wood's message of "Fri, 4 Sep 2026 10:11:30 +0100")
Phillip Wood <phillip.wood123@gmail.com> writes:
>> if (value)
>> - printf("%s=%s\n", var, value);
>> + printf("%s=%s%c", var, value, eol);
>
> A key can contain "=" so this format is ambiguous. When the user passes
> "-z" we should use the same format as "git config list -z" which avoids
> that ambiguity
>
> printf("%s%c%s%c", var, eol == '\n' ? '=' : '\n', value, eol);
>
>> else
>> - printf("%s\n", var);
>> + printf("%s%c", var, eol);
>
> It would be worth checking what "git config list -z" does when there is
> no value and matching that. Does it print "key\n\0", or "key\0"?
By "key" do you mean "var"? The namespace of "var" for "git var"
proper (like GIT_COMMITTER_IDENT) are very much under our control,
but it also gives all the configuration variables, whose names can
indeed have '=' in a three-level varlable name. This is an
excellent suggestion.
> I think we should break out of the loop when arg is "--", or does not
> begin with '-', and treat the rest as variable names to print. There is
> not need to support "git var GIT_AUTHOR_NAME -z GIT_AUTHOR_EMAIL" in a
> plumbing command.
Not limited to plumbing, but anywhere in Git. Let's stick to and
force users adopt the simple rule that "git help cli" gives them.
Options first and then args, among which revs coe first and then
paths after disambiguating "--". I know as historical wart some
commands may take dashed options after args, but I am fine if we
tightened the rule at Git 3.0 boundary to more strictly enforced
the option/argument ordering rule.
>> [...]
>> - printf("%s\n", val);
>> - free(val);
>> + printf("%s%c", val, null_term ? '\0' : '\n');
>
> Multi-valued variables are a bit of a problem here, they're built on the
> assumption that the individual values do not contain a newline, but as
> they are paths I'm not sure that is necessarily true. With -z it would
> be better to print '\0' after each value as we do in list_vars().
> Ideally we wouldn't use a single string to pass multiple values around,
> but a simple fix would be to use '\0' to separate the individual values
> instead of '\n' so that we can split them unambiguously when we print them.
Hmph, what does "git config -l" do for multi-valued keys? We should
mimick it, I would think.
Another thing that might be worth doing is to see if we can separate
out "git config -l" handling out of "git var" with a breaking change
at big version boundary.
> Thanks for working on this, being able to specify multiple variables
> that are printed unambiguously is a really useful improvement.
Indeed. Thanks, both.
next prev parent reply other threads:[~2026-09-04 15:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 20:46 [PATCH] builtin/whoami: add new 'whoami' command Andrew Pleeter via GitGitGadget
2026-08-25 21:24 ` brian m. carlson
2026-08-25 21:41 ` Junio C Hamano
2026-08-31 23:59 ` [PATCH v2] builtin/ident: add new 'ident' command Andrew Pleeter via GitGitGadget
2026-09-01 4:39 ` Jeff King
2026-09-01 5:00 ` Junio C Hamano
2026-09-03 2:49 ` [PATCH v3] var: support broken-down idents, default key, multiple args, and -z Andrew Pleeter via GitGitGadget
2026-09-03 17:40 ` Junio C Hamano
2026-09-03 18:22 ` Ben Knoble
2026-09-04 9:11 ` Phillip Wood
2026-09-04 15:57 ` Junio C Hamano [this message]
2026-09-08 9:07 ` Phillip Wood
2026-09-08 4:09 ` [PATCH v4] var: support broken-down idents, signing " Andrew Pleeter via GitGitGadget
2026-09-08 13:54 ` Phillip Wood
2026-09-08 20:43 ` [PATCH v5] " Andrew Pleeter via GitGitGadget
2026-09-08 21:53 ` Junio C Hamano
2026-09-09 1:24 ` [PATCH v6] " Andrew Pleeter via GitGitGadget
2026-09-09 15:36 ` Phillip Wood
2026-09-09 16:42 ` Junio C Hamano
2026-09-10 3:09 ` [PATCH v7] " Andrew Pleeter via GitGitGadget
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=xmqqqzj957rm.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=andrewpleeter@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=peff@peff.net \
--cc=phillip.wood123@gmail.com \
--cc=sandals@crustytoothpaste.net \
/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.