Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
Cc: <git@vger.kernel.org>, <peff@peff.net>
Subject: Re: [PATCH v3 2/4] imap-send: add wrapper to get server credentials if needed
Date: Wed, 23 Aug 2017 13:13:47 -0700	[thread overview]
Message-ID: <xmqqtw0yxcsk.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <9df045f4-71bd-92a1-20bb-4931e25b22c3@morey-chaisemartin.com> (Nicolas Morey-Chaisemartin's message of "Tue, 22 Aug 2017 17:56:24 +0200")

Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com> writes:

> Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
> ---
>  imap-send.c | 34 ++++++++++++++++++++--------------
>  1 file changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/imap-send.c b/imap-send.c
> index 09f29ea95..448a4a0b3 100644
> --- a/imap-send.c
> +++ b/imap-send.c
> @@ -926,6 +926,25 @@ static int auth_cram_md5(struct imap_store *ctx, struct imap_cmd *cmd, const cha
>  	return 0;
>  }
>  
> +static void server_fill_credential(struct imap_server_conf *srvc, struct credential *cred)
> +{
> +	if (srvc->user && srvc->pass)
> +		return;
> +
> +	cred->protocol = xstrdup(srvc->use_ssl ? "imaps" : "imap");
> +	cred->host = xstrdup(srvc->host);
> +
> +	cred->username = xstrdup_or_null(srvc->user);
> +	cred->password = xstrdup_or_null(srvc->pass);
> +
> +	credential_fill(cred);
> +
> +	if (!srvc->user)
> +		srvc->user = xstrdup(cred->username);
> +	if (!srvc->pass)
> +		srvc->pass = xstrdup(cred->password);
> +}
> +

This looks straight-forward code movement.  The only thing that
makes me wonder is if this is "server".  The existing naming of the
variables screams at me that this is not "server" but is "service".

>  static struct imap_store *imap_open_store(struct imap_server_conf *srvc, char *folder)
>  {
>  	struct credential cred = CREDENTIAL_INIT;
> @@ -1078,20 +1097,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, char *f
>  		}
>  #endif
>  		imap_info("Logging in...\n");
> -		if (!srvc->user || !srvc->pass) {
> -			cred.protocol = xstrdup(srvc->use_ssl ? "imaps" : "imap");
> -			cred.host = xstrdup(srvc->host);
> -
> -			cred.username = xstrdup_or_null(srvc->user);
> -			cred.password = xstrdup_or_null(srvc->pass);
> -
> -			credential_fill(&cred);
> -
> -			if (!srvc->user)
> -				srvc->user = xstrdup(cred.username);
> -			if (!srvc->pass)
> -				srvc->pass = xstrdup(cred.password);
> -		}
> +		server_fill_credential(srvc, &cred);
>  
>  		if (srvc->auth_method) {
>  			struct imap_cmd_cb cb;

  reply	other threads:[~2017-08-23 20:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-22 15:55 [PATCH v3 0/4] imap-send: Fix and enable curl by default Nicolas Morey-Chaisemartin
2017-08-22 15:56 ` [PATCH v3 1/4] imap-send: return with error if curl failed Nicolas Morey-Chaisemartin
2017-08-23 20:10   ` Junio C Hamano
2017-08-23 20:12   ` Junio C Hamano
2017-08-24  6:57     ` Nicolas Morey-Chaisemartin
2017-08-22 15:56 ` [PATCH v3 2/4] imap-send: add wrapper to get server credentials if needed Nicolas Morey-Chaisemartin
2017-08-23 20:13   ` Junio C Hamano [this message]
2017-08-24  6:08     ` Nicolas Morey-Chaisemartin
2017-08-24 18:54       ` Junio C Hamano
2017-08-22 15:56 ` [PATCH v3 3/4] imap_send: setup_curl: retreive credentials if not set in config file Nicolas Morey-Chaisemartin
2017-08-22 15:56 ` [PATCH v3 4/4] imap-send: use curl by default Nicolas Morey-Chaisemartin
2017-08-23 20:28   ` Junio C Hamano
2017-08-24  7:24     ` Nicolas Morey-Chaisemartin

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=xmqqtw0yxcsk.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=nicolas@morey-chaisemartin.com \
    --cc=peff@peff.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox