Re: [PATCH] contrib: Honor symbolic port in git-credential-netrc.

Maxim Cournoyer
2025-06-21T13:29:45Z

Hi,

"brian m. carlson" <sandals@crustytoothpaste.net> writes:

> On 2025-06-20 at 04:12:39, Maxim Cournoyer wrote:
>> Symbolic ports were previously silently dropped, which made it
>> impossible to use them with git-credential-netrc. This is a supported
>> use case according to 'man git-send-email', for --smtp-server-port:
>>
>> [...] symbolic port names (e.g. "submission" instead of 587) are
>> also accepted.
>
> Does this work with credential managers in general (that is, in
> non-email contexts, such as HTTP)? Also, do credential managers in
> general properly find credentials when they're stored in one form and
> looked up in another? If so, is that still true when the lookup is in
> the URL form (e.g., `smtp://mail.example.com:587/`)? Is this documented
> to work in the credential manual page?

I'm quite new to the credential-manager of git, so I do not have an
answer to these excellent questions. But, as some perhaps useful
datapoint, at least using Emacs's auth-source library with a
~/.authinfo.gpg file (which is in the netrc format), if you use a
symbolic port name, you have to use it everywhere if you want
auth-source to match it correctly (it doesn't translate smtps to 465 for
example). If you put 'port smtps' in the .authinfo.gpg but specify the
SMTP port in the your Emacs MTA to a integer like 465, it won't match.

This could be considered a bug in auth-source.el, and git
credential-manager can do better by converting all port input values to
their integer form, as you suggested. Then mismatched configurations
(e.g.: smtps in netrc and sendemail.smtpServerPort = 465 or vice-versa)
would be handled correctly.

> (To be clear, I would be very
> surprised if the answer to any of these were "yes" because I've
> literally never seen this usage before with Git, but I am open to
> updating my knowledge if that's the case.)
>
> If not, then I think the proper thing to do is to have `git send-email`
> rewrite the name into a port instead of having the netrc credential
> helper learn to handle non-numeric ports.

Did I understand correctly with my suggestion/rewording of yours above?
git-credential-netrc reads its input from the netrc file, which may well
have a symbolic port, so it should itself convert from symbolic to
actual port numbers, IIUC.

--
Thanks,
Maxim