]> Kevux Git Server - rit/commitdiff
mingw: ensure sockets are initialized before calling gethostname
authorPat Thoyts <patthoyts@users.sourceforge.net>
Sat, 15 Oct 2011 14:05:20 +0000 (15:05 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 16 Oct 2011 03:14:39 +0000 (20:14 -0700)
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 <patthoyts@users.sourceforge.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.c
compat/mingw.h

index 6ef0cc4..8e17dae 100644 (file)
@@ -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)
 {
index ce9dd98..fecf0d0 100644 (file)
@@ -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