Re: [PATCH] imap-send: parse default git config
Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com> writes:
Show 19 quoted lines
> git imap-send does not parse the default git config settings and thus ignore
> core.askpass value.
> Fix it by calling git_config(git_default_config)
>
> Reported-by: Philippe Blain <levraiphilippeblain@gmail.com>
> Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
> ---
> imap-send.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/imap-send.c b/imap-send.c
> index 5764dd812ca7..790780b76da2 100644
> --- a/imap-send.c
> +++ b/imap-send.c
> @@ -1367,6 +1367,7 @@ static void git_imap_config(void)
> git_config_get_int("imap.port", &server.port);
> git_config_get_string("imap.tunnel", &server.tunnel);
> git_config_get_string("imap.authmethod", &server.auth_method);
> + git_config(git_default_config, NULL);There are two styles of parsing configuration variables to get values. The way imap-send.c works is to grab individual values by calling git_config_get_*() functions. The other is to give a callback function to git_config() to iterate over all configuration variables and pick the relevant ones.
Once we start doing the latter, the existing git_config_get_*() calls we see above should also be folded into it to avoid mixing two styles for code clarity.
IOW, I'd expect
(1) The call to git_imap_config() near the beginning of cmd_main()
is changed to a call to git_config(git_imap_config, NULL); (2) git_imap_config() function is updated to begin like so:
static void git_imap_config(const char *var, const char *value, void *cb)
{
if (!strcmp("imap.sslverify", var))
server.ssl_verify = git_config_bool(var, value);
else if (!strcmp("imap.preformattedhtml", var))
server.ssl_verify = git_config_bool(var, value);
else if (!strcmp("imap.preformattedhtml", var))
server.use_html = git_config_bool(var, value);
... to parse the "imap.*" variables the function currently parses,
and end like so: ...
else
return git_default_config(var, value, cb);
return 0;
}
to delegate the parsing of other configuration variables that
ought to be read by default.Of course you could also unify in the other direction and instead of running git_config(git_defauilt_config, NULL), pick the exact variables you care about (did you say askpass???).