Subject: Re: [PATCH 9/9] send-email: move trivial config handling to Perl

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Thu, 13 May 2021 13:45:06 +0200

On Thu, May 13 2021, Felipe Contreras wrote:

> Jeff King wrote:
>> On Thu, May 13, 2021 at 02:04:08AM -0500, Felipe Contreras wrote:
>> 
>> > Jeff King wrote:
>> > > It is a bit unfortunate to have to go through these contortions, but
>> > > this is definitely the best we can do for now. I think in the long run
>> > > it would be nice to have a "--stdin" mode for git-config, where we could
>> > > do something like:
>> > > 
>> > >   git config --stdin <<\EOF
>> > >   key=foo.bar
>> > >   type=bool
>> > >   default=false
>> > > 
>> > >   key=another.key
>> > >   type=color
>> > >   default=red
>> > >   EOF
>> > 
>> > Why do we even have to specify the type? Shouldn't there be a registry
>> > of configurations (a schema), so that all users don't have to do this?
>> 
>> One of the purposes of git-config is to serve third-party scripts that
>> store their own config keys that Git does not know about. So we can't
>> know the set of all possible types that will be asked about.
>
> Yes, I know, I maintain several tools that have such configurations. For
> those you would need to specify the type (or find some way to install
> the schema so that git parses it).
>
> But I'm talking about git.git configurations. If you don't specify the
> type in --stdin it should fetch it from some database. That would be
> much more user-friendly.

For what it's worth my idea of hacking a plumbing thingy for
git-send-email here before ultimately deciding that my simpler caching
approach was easier and gave me 95% of the win, was to just teach it a
mode where it spews out all config variables \0-delimited with all
possible interpretations of it. I.e.:

    some.variable	123	bool	true	path	123	string	123	[...]

It's rather cheap to do the "interpret this as --type=X for me" on the
C-level, so we might as well spew out all possible interpretations.

That means that any external tool would be guaranteed to only need one
"git config" invocation to parse any of its config, i.e. in a case where
variable X decides if variable Y is a bool or path or whatever. They'd
already have all possible values.

Something like:

	git config -l -z --type=bool,path
	git config -l -z --type=ALL