Subject: Re: [PATCH v16 08/10] imap-send: display port alongwith host when git credential is invoked

From: Junio C Hamano <[email-masked]>
Date: Mon, 09 Jun 2025 11:55:51 -0700

Aditya Garg <[email-masked]> writes:

> FWIW, if no port is specified by the user, the default port, 993 for
> IMAPS and 143 for IMAP is used by the code. So, the case of no port
> defined for the helper is not possible, and therefore is not added.

Shouldn't we do a bit better than being so pessimistic?

If the user left the port unspecified, or if the more knowledgeable
user redundantly specified the default port explicitly, showing to
such a user :993 for imaps at the end adds no useful information.

>  	cred->protocol = xstrdup(srvc->use_ssl ? "imaps" : "imap");
> -	cred->host = xstrdup(srvc->host);

Perhaps something like

	if ((srvc->use_ssl ? 993 : 143) == srvc->port)
        	cred->host = xstrdup(srvc->host);
	else

here?

> +	cred->host = xstrfmt("%s:%d", srvc->host, srvc->port);

>  
>  	cred->username = xstrdup_or_null(srvc->user);
>  	cred->password = xstrdup_or_null(srvc->pass);