summaryrefslogtreecommitdiff
path: root/compat/mingw.c
diff options
context:
space:
mode:
authorPat Thoyts <patthoyts@users.sourceforge.net>2011-10-15 14:05:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-10-16 03:14:39 (GMT)
commit13d24b018f348401cceca45da5c0dd6d17411268 (patch)
tree9569fe30551a57e7b69a29128b37a3da4bf95725 /compat/mingw.c
parent8850c3da95d17bb23576ee5ee3484bfd3d486444 (diff)
downloadgit-13d24b018f348401cceca45da5c0dd6d17411268.zip
git-13d24b018f348401cceca45da5c0dd6d17411268.tar.gz
git-13d24b018f348401cceca45da5c0dd6d17411268.tar.bz2
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 <patthoyts@users.sourceforge.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/mingw.c')
-rw-r--r--compat/mingw.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/compat/mingw.c b/compat/mingw.c
index 6ef0cc4..8e17dae 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)
{