From: Pat Thoyts Date: Sat, 15 Oct 2011 14:05:20 +0000 (+0100) Subject: mingw: ensure sockets are initialized before calling gethostname X-Git-Tag: v1.7.8-rc0~46^2~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=13d24b018f348401cceca45da5c0dd6d17411268;p=git.git mingw: ensure sockets are initialized before calling gethostname If the Windows sockets subsystem has not been initialized yet then an attempt to get the hostname returns an error and prints a warning to the console. This solves this issue for msysGit as seen with 'git fetch'. Signed-off-by: Pat Thoyts Signed-off-by: Junio C Hamano --- diff --git a/compat/mingw.c b/compat/mingw.c index 6ef0cc4f9..8e17daeac 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1321,6 +1321,13 @@ static void ensure_socket_initialization(void) initialized = 1; } +#undef gethostname +int mingw_gethostname(char *name, int namelen) +{ + ensure_socket_initialization(); + return gethostname(name, namelen); +} + #undef gethostbyname struct hostent *mingw_gethostbyname(const char *host) { diff --git a/compat/mingw.h b/compat/mingw.h index ce9dd980e..fecf0d077 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -190,6 +190,9 @@ char *mingw_getcwd(char *pointer, int len); char *mingw_getenv(const char *name); #define getenv mingw_getenv +int mingw_gethostname(char *host, int namelen); +#define gethostname mingw_gethostname + struct hostent *mingw_gethostbyname(const char *host); #define gethostbyname mingw_gethostbyname