Subject: Re: [PATCH/RFD] fix connection via git protocol

From: Junio C Hamano <[email-masked]>
Date: Tue, 18 Apr 2023 13:47:34 -0700

Jeff King <[email-masked]> writes:

> All of that makes me wonder if we wouldn't be just as happy with it as a
> string in the first place. In three out of four locations that use it,
> they want the string anyway (to feed to getaddrinfo). And in the final
> one (git-daemon), we need to convert from the user's "--port" anyway, so
> there's always some string-to-int parsing. And depending on the #ifdefs,
> in most cases we turn it back into a string anyway to feed to...you
> guessed it, getaddrinfo!
>
> The exception is when NO_IPV6 is defined, in which we do want the
> numeric value. But we could delay parsing until that point (and
> otherwise let getaddrinfo handle, which seems more correct anyway).
>
> Something like this (though I'd probably split it into a few patches to
> reason about the motivation and implications of each):

The updated code keeps the "port" as a string and turns it into a
short integer only when it is needed, which is nice.  In the future,
parse_port() may even want to be extended to call something like
getservbyname(), to allow something silly like

	#define DEFAULT_GIT_PORT "git"