contrib: warn for invalid netrc file ports in git-credential-netrc

Invalid ports were previously silently dropped; now a warning message
is produced.

Signed-off-by: Maxim Cournoyer <maxim@guixotic.coop>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Maxim Cournoyer
2025-06-25 23:25:10 +09:00
committed by Junio C Hamano
parent 3570fba943
commit 53ca38298d

View File

@@ -267,9 +267,14 @@ sub load_netrc {
if (!defined $nentry->{machine}) {
next;
}
if (defined $nentry->{port} && $nentry->{port} =~ m/^\d+$/) {
$num_port = $nentry->{port};
delete $nentry->{port};
if (defined $nentry->{port}) {
if ($nentry->{port} =~ m/^\d+$/) {
$num_port = $nentry->{port};
delete $nentry->{port};
} else {
printf(STDERR "ignoring invalid port `%s' " .
"from netrc file\n", $nentry->{port});
}
}
# create the new entry for the credential helper protocol