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 09:07:57 +0200

On Thu, May 13 2021, 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?

Yes, we should be moving towards that. Currently we're not there, the
closest we've got is the generated config-list.h.

If we closed that loop properly you should be able to do:

    git config --get --type=dwim clean.requireForce # or auto, or no --type

Or whatever, instead of:

    git config --get --type=bool clean.requireForce

But we're not there yet, there's also edge cases here and there that
make a plain exhaustive registry hard, and send-email is one of them.

In its case the value of sendemail.identity=something (if any)
determines if/how e.g. sendemail.something.smtpEncryption is
interpreted.

I think we can do it with just a list of config variables where the
variable is either a string or a regex (in this case,
"^sendemail(?:[^.]+\.)?\.smtpEncryption$"), but I haven't tried. There
may be other tricky special-cases.