git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 7/7] mingw: ensure sockets are initialized before calling gethostname

From
Pat Thoyts <patthoyts@users.sourceforge.net>
Date
Oct 15, 2011, 14:05 UTC
Message-ID
<1318687520-19522-8-git-send-email-patthoyts@users.sourceforge.net>
In-Reply-To
<1318687520-19522-1-git-send-email-patthoyts@users.sourceforge.net>

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>
---
 compat/mingw.c |    7 +++++++
 compat/mingw.h |    3 +++
 2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index 8947418..efdc703 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 ce9dd98..fecf0d0 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
 
-- 
1.7.7.1.gbba15
Previous: Pat ThoytsNext: Junio C Hamano
Message 8 of 9 in “Some patches from msysGit (round 2)”
  1. 0/7 Some patches from msysGit (round 2)Pat Thoyts, Oct 15, 2011
  2. 1/7 t1020: disable the pwd test on MinGWPat Thoyts, Oct 15, 2011
  3. 2/7 t9001: do not fail only due to CR/LF issuesPat Thoyts, Oct 15, 2011
  4. 3/7 git-svn: On MSYS, escape and quote SVN_SSH also if set by the userPat Thoyts, Oct 15, 2011
  5. 4/7 t9901: fix line-ending dependency on windowsPat Thoyts, Oct 15, 2011
  6. 5/7 t9300: do not run --cat-blob-fd related tests on MinGWPat Thoyts, Oct 15, 2011
  7. 6/7 mergetools: use the correct tool for Beyond Compare 3 on WindowsPat Thoyts, Oct 15, 2011
  8. 7/7 mingw: ensure sockets are initialized before calling gethostnamePat Thoyts, Oct 15, 2011
  9. Junio C HamanoOct 16, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.