Re: [PATCH v16 08/10] imap-send: display port alongwith host when git credential is invoked
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 9, 2025, 18:55 UTC
- Message-ID
- <xmqq8qm0rbgo.fsf@gitster.g>
- In-Reply-To
- <PN3PR01MB9597AF90BA3D4B3295ECC278B86BA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM>
Aditya Garg <gargaditya08@live.com> 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);
elsehere?
> + cred->host = xstrfmt("%s:%d", srvc->host, srvc->port);> > cred->username = xstrdup_or_null(srvc->user); > cred->password = xstrdup_or_null(srvc->pass);