From: Maxim Cournoyer <maxim@guixotic.coop>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] contrib: Honor symbolic port in git-credential-netrc.
Date: Mon, 23 Jun 2025 12:34:17 +0900 [thread overview]
Message-ID: <871prbf7wm.fsf@terra.mail-host-address-is-not-set> (raw)
In-Reply-To: <xmqqmsa27cdn.fsf@gitster.g> (Junio C. Hamano's message of "Fri, 20 Jun 2025 06:48:04 -0700")
Hi Junio,
tldr; all changes discussed implemented in posted v2.
Junio C Hamano <gitster@pobox.com> writes:
> 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.
>> 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.
>> 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.
>> 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.
>> @@ -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 getservbyname(3) call to determine if a non-numeric port is a
valid service/symbolic port name.
I've sent a v2 revision which hopefully addresses all of the above
suggestions/changes.
--
Maxim
next prev parent reply other threads:[~2025-06-23 3:35 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 4:12 [PATCH] contrib: Honor symbolic port in git-credential-netrc Maxim Cournoyer
2025-06-20 13:48 ` Junio C Hamano
2025-06-20 14:22 ` Andreas Schwab
2025-06-20 16:39 ` Junio C Hamano
2025-06-21 13:57 ` Maxim Cournoyer
2025-06-23 3:28 ` Maxim Cournoyer
2025-06-23 3:34 ` Maxim Cournoyer [this message]
2025-06-20 19:03 ` brian m. carlson
2025-06-21 13:29 ` Maxim Cournoyer
2025-06-21 15:52 ` brian m. carlson
2025-06-22 15:25 ` [PATCH v2 0/3] git-credential-netrc: better symbolic port names support Maxim Cournoyer
2025-06-22 15:25 ` [PATCH v2 1/3] contrib: use a more portable shebang for git-credential-netrc Maxim Cournoyer
2025-06-22 15:25 ` [PATCH v2 2/3] contrib: warn for invalid netrc file ports in git-credential-netrc Maxim Cournoyer
2025-06-22 15:25 ` [PATCH v2 3/3] contrib: better support symbolic port names " Maxim Cournoyer
2025-06-23 18:03 ` Junio C Hamano
2025-06-24 1:51 ` Maxim Cournoyer
2025-06-24 1:48 ` [PATCH v3 0/3] git-credential-netrc: better symbolic port names support Maxim Cournoyer
2025-06-24 16:04 ` Junio C Hamano
2025-06-24 23:55 ` Maxim Cournoyer
2025-06-25 0:24 ` Junio C Hamano
2025-06-25 1:03 ` Maxim Cournoyer
2025-06-25 14:25 ` [PATCH v4 " Maxim Cournoyer
2025-06-25 14:25 ` [PATCH v4 1/3] contrib: use a more portable shebang for git-credential-netrc Maxim Cournoyer
2025-06-25 14:25 ` [PATCH v4 2/3] contrib: warn for invalid netrc file ports in git-credential-netrc Maxim Cournoyer
2025-06-25 14:25 ` [PATCH v4 3/3] contrib: better support symbolic port names " Maxim Cournoyer
2025-06-25 16:49 ` [PATCH v4 0/3] git-credential-netrc: better symbolic port names support Junio C Hamano
2025-06-26 1:15 ` Maxim Cournoyer
2025-06-24 1:48 ` [PATCH v3 1/3] contrib: use a more portable shebang for git-credential-netrc Maxim Cournoyer
2025-06-24 1:48 ` [PATCH v3 2/3] contrib: warn for invalid netrc file ports in git-credential-netrc Maxim Cournoyer
2025-06-24 1:48 ` [PATCH v3 3/3] contrib: better support symbolic port names " Maxim Cournoyer
2025-06-24 16:06 ` Junio C Hamano
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871prbf7wm.fsf@terra.mail-host-address-is-not-set \
--to=maxim@guixotic.coop \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).