git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
MCMaxim Cournoyer <maxim@guixotic.coop>
Date
Jun 23, 2025, 03:28 UTC
Message-ID
<874iw7f86n.fsf@terra.mail-host-address-is-not-set>
In-Reply-To
<xmqqmsa27cdn.fsf@gitster.g>
Hi Junio,
tldr; all changes discussed implemented in posted v2.
Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
> Maxim Cournoyer <maxim@guixotic.coop> writes:
>
>> Subject: Re: [PATCH] contrib: Honor symbolic port in git-credential-netrc.
>
> Please downcase "Honor" and drop the final full stop, per convention
> (see "git shortlog --no-merges --since=2.months" for examples).
Done.
Show 6 quoted lines
>> Symbolic ports were previously silently dropped, which made it
>> impossible to use them with git-credential-netrc.
>
> Wouldn't it make sense to issue a warning message when a defined
> $nentry->{port} is not unrecognized?  Wouldn't it make sense to
> do so even before we add this new feature?

I agree it's subpar that the current code silently drops the port when it doesn't match the expected form. Since port values aren't validated in 'git-send-email' at the moment, a proper fix would be to have routine to validate ports in a common library and applied everywhere a port is read from the user or a config file, ideally, in git-send-email or elsewhere. Maybe it could live in Git.pm ?

Edit: Done.
Show 8 quoted lines
>> 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.
>> ---
>
> Missing sign-off?  See Documentation/SubmittingPatches
Done.
Show 18 quoted lines
>>  contrib/credential/netrc/git-credential-netrc.perl | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/contrib/credential/netrc/git-credential-netrc.perl
>> b/contrib/credential/netrc/git-credential-netrc.perl
>> index 9fb998ae09..ad06000b9f 100755
>> --- a/contrib/credential/netrc/git-credential-netrc.perl
>> +++ b/contrib/credential/netrc/git-credential-netrc.perl
>> @@ -1,4 +1,4 @@
>> -#!/usr/bin/perl
>> +#!/usr/bin/env perl
>
> An unrelated change to introduce the use of /usr/bin/env in this
> patch is unwelcome.  Besides, this is a source that is processed
> by the nearby Makefile, which uses the toplevel genererate-perl.sh
> to turn the "#!.../perl" line to name the correct $PERL_PATH before
> the build product gets installed, so I suspect that this change is
> totally unnecessary.

It was necessary on my system to test the uninstalled version, which I simply symlinked to ~/.local/bin/git-credential-netrc for ease of testing. I've split this small change in its own commit. Using env in shebangs instead of hard-coded locations is good for portability in general, and the generate-perl.sh substitution will work still.

Show 12 quoted lines
>> @@ -267,7 +267,9 @@ sub load_netrc {
>>  		if (!defined $nentry->{machine}) {
>>  			next;
>>  		}
>> -		if (defined $nentry->{port} && $nentry->{port} =~ m/^\d+$/) {
>> +		if (defined $nentry->{port} && $nentry->{port} =~ m/^[[:alnum:]]+$/) {
>> +			# Port may be either an integer or a symbolic
>> +			# name, e.g. "smtps".
>
> Do we know symbolic port names are always limited to alnums?  Or on
> some systems some byte values in the fringe, like "_" or "-", are
> also allowed?

Looking at /etc/services on my system, I see hyphens, indeed, e.g.: 're-mail-ck'. That's now handled by the `is_port' predicate, which uses the libc `getservbyname' call to determine if a non-numeric port is a valid service/symbolic port name.

I've sent a v2 revision which hopefully includes all of the above suggestion/changes.

-- 
Maxim
Previous: Maxim CournoyerNext: Maxim Cournoyer
Message 6 of 31 in “contrib: Honor symbolic port in git-credential-netrc.”
  1. contrib: Honor symbolic port in git-credential-netrc.Maxim Cournoyer, Jun 20, 2025
  2. Junio C HamanoJun 20, 2025
  3. Andreas SchwabJun 20, 2025
  4. Junio C HamanoJun 20, 2025
  5. Maxim CournoyerJun 21, 2025
  6. Maxim CournoyerJun 23, 2025
  7. Maxim CournoyerJun 23, 2025
  8. brian m. carlsonJun 20, 2025
  9. Maxim CournoyerJun 21, 2025
  10. brian m. carlsonJun 21, 2025
  11. 1/3 contrib: use a more portable shebang for git-credential-netrcMaxim Cournoyer, Jun 22, 2025
  12. 0/3 git-credential-netrc: better symbolic port names supportMaxim Cournoyer, Jun 22, 2025
  13. 3/3 contrib: better support symbolic port names in git-credential-netrcMaxim Cournoyer, Jun 22, 2025
  14. Junio C HamanoJun 23, 2025
  15. Maxim CournoyerJun 24, 2025
  16. 2/3 contrib: warn for invalid netrc file ports in git-credential-netrcMaxim Cournoyer, Jun 22, 2025
  17. 1/3 contrib: use a more portable shebang for git-credential-netrcMaxim Cournoyer, Jun 24, 2025
  18. 0/3 git-credential-netrc: better symbolic port names supportMaxim Cournoyer, Jun 24, 2025
  19. Junio C HamanoJun 24, 2025
  20. Maxim CournoyerJun 24, 2025
  21. Junio C HamanoJun 25, 2025
  22. Maxim CournoyerJun 25, 2025
  23. 0/3 git-credential-netrc: better symbolic port names supportMaxim Cournoyer, Jun 25, 2025
  24. 2/3 contrib: warn for invalid netrc file ports in git-credential-netrcMaxim Cournoyer, Jun 25, 2025
  25. 3/3 contrib: better support symbolic port names in git-credential-netrcMaxim Cournoyer, Jun 25, 2025
  26. 1/3 contrib: use a more portable shebang for git-credential-netrcMaxim Cournoyer, Jun 25, 2025
  27. Junio C HamanoJun 25, 2025
  28. Maxim CournoyerJun 26, 2025
  29. 3/3 contrib: better support symbolic port names in git-credential-netrcMaxim Cournoyer, Jun 24, 2025
  30. Junio C HamanoJun 24, 2025
  31. 2/3 contrib: warn for invalid netrc file ports in git-credential-netrcMaxim Cournoyer, Jun 24, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.