git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
Cc: git@vger.kernel.org, levraiphilippeblain@gmail.com
Subject: Re: [PATCH] imap-send: parse default git config
Date: Wed, 25 Nov 2020 00:31:41 -0800	[thread overview]
Message-ID: <xmqqh7pdg7ma.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <8a21b031-fbfd-81c2-1f91-eff8c03bafb7@suse.com> (Nicolas Morey-Chaisemartin's message of "Wed, 25 Nov 2020 09:05:52 +0100")

Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com> writes:

> 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???).


  reply	other threads:[~2020-11-25  8:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24 15:20 [BUG] git imap-send does not honor 'core.askpass' Philippe Blain
2020-11-25  8:05 ` [PATCH] imap-send: parse default git config Nicolas Morey-Chaisemartin
2020-11-25  8:31   ` Junio C Hamano [this message]
2020-11-25  8:43     ` Nicolas Morey-Chaisemartin
2020-11-25 19:18       ` 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=xmqqh7pdg7ma.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=levraiphilippeblain@gmail.com \
    --cc=nmoreychaisemartin@suse.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).