{"thread":{"id":"37150","subject":"[PATCH 04/13] Win32: fix environment memory leaks","startedAt":"2014-07-17T15:37:53Z","lastAt":"2014-07-21T16:32:52Z","messageCount":23,"participants":["Stepan Kasal","Junio C Hamano","Karsten Blees"],"isPatch":true,"patchVersion":1,"patchTotal":13},"messages":[{"id":"246240","messageId":"1405611486-10176-1-git-send-email-kasal@ucw.cz","threadId":"37150","inReplyTo":null,"subject":"[PATCH 00/13] mingw unicode environment","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T15:37:53Z","receivedAt":"2014-07-17T15:37:53Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"Hello,\n\nthis is the remainder of Karsten's unicode branch, that is a time\nproven part of msysGit.  (If this code is accepted, only one patch\nwould only remain: gitk and git-gui fixes.)\n\nWhen rebasing Karsten's work, I have eliminated two commits:\nhttps://github.com/msysgit/git/commit/f967550\nhttps://github.com/msysgit/git/commit/290bf81\n\nThese commits only moved code down and up; this was not necessary, one\nforward declaration was all I needed.\n\nOne of the patches differs from the original version: \"Enable color...\"\nFollowing Karsten's suggestion, I have changed the value of env. var.\nTERM from \"winterm\" to \"cygwin\".  This is because the subprocesses see\nthe variable and may try to find it in (their copy of) termcap.\n\nEnjoy,\n   Stepan\n\nKarsten Blees (13):\n  Revert \"Windows: teach getenv to do a case-sensitive search\"\n  Win32: Unicode environment (outgoing)\n  Win32: Unicode environment (incoming)\n  Win32: fix environment memory leaks\n  Win32: unify environment case-sensitivity\n  Win32: unify environment function names\n  Win32: factor out environment block creation\n  Win32: don't copy the environment twice when spawning child processes\n  Win32: reduce environment array reallocations\n  Win32: use low-level memory allocation during initialization\n  Win32: keep the environment sorted\n  Win32: patch Windows environment on startup\n  Enable color output in Windows cmd.exe\n\n compat/mingw.c   | 290 +++++++++++++++++++++++++++++++------------------------\n compat/mingw.h   |  11 +--\n config.mak.uname |   2 -\n run-command.c    |  10 +-\n 4 files changed, 170 insertions(+), 143 deletions(-)\n\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246241","messageId":"1405611486-10176-2-git-send-email-kasal@ucw.cz","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 01/13] Revert \"Windows: teach getenv to do a case-sensitive search\"","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T15:37:54Z","receivedAt":"2014-07-17T15:37:54Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\n\nThis reverts commit df599e9612788b728ce43a03159b85f1fe624d6a.\n\nAs of 5e9637c6 \"i18n: add infrastructure for translating Git with gettext\",\neval_gettext uses MinGW envsubst.exe instead of git-sh-i18n--envsubst.exe\nfor variable substitution. This breaks git-submodule.sh messages and tests,\nas envsubst.exe doesn't support case-sensitive environment lookup (the same\nis true for almost everything on Windows, including MSys and Cygwin tools).\n\n30a615ac \"Windows/i18n: rename $path to prevent clashes with $PATH\" renames\nthe conflicting variable in git-submodule.sh, so that it works on Windows\n(i.e. with case-insensitive environment, regardless of the toolset).\n\nRevert to the documented behaviour of case-insensitive environment on\nWindows.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 23 +++--------------------\n 1 file changed, 3 insertions(+), 20 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex c19e3d9..ca1b6bd 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -1245,31 +1245,14 @@ char **make_augmented_environ(const char *const *vars)\n }\n \n #undef getenv\n-\n-/*\n- * The system's getenv looks up the name in a case-insensitive manner.\n- * This version tries a case-sensitive lookup and falls back to\n- * case-insensitive if nothing was found.  This is necessary because,\n- * as a prominent example, CMD sets 'Path', but not 'PATH'.\n- * Warning: not thread-safe.\n- */\n-static char *getenv_cs(const char *name)\n-{\n-\tsize_t len = strlen(name);\n-\tint i = lookup_env(environ, name, len);\n-\tif (i >= 0)\n-\t\treturn environ[i] + len + 1;\t/* skip past name and '=' */\n-\treturn getenv(name);\n-}\n-\n char *mingw_getenv(const char *name)\n {\n-\tchar *result = getenv_cs(name);\n+\tchar *result = getenv(name);\n \tif (!result && !strcmp(name, \"TMPDIR\")) {\n \t\t/* on Windows it is TMP and TEMP */\n-\t\tresult = getenv_cs(\"TMP\");\n+\t\tresult = getenv(\"TMP\");\n \t\tif (!result)\n-\t\t\tresult = getenv_cs(\"TEMP\");\n+\t\t\tresult = getenv(\"TEMP\");\n \t}\n \treturn result;\n }\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246248","messageId":"1405611486-10176-3-git-send-email-kasal@ucw.cz","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 02/13] Win32: Unicode environment (outgoing)","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T15:37:55Z","receivedAt":"2014-07-17T15:37:55Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\n\nConvert environment from UTF-8 to UTF-16 when creating other processes.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 24 +++++++++++++-----------\n 1 file changed, 13 insertions(+), 11 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex ca1b6bd..bd45950 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -919,9 +919,9 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n {\n \tSTARTUPINFOW si;\n \tPROCESS_INFORMATION pi;\n-\tstruct strbuf envblk, args;\n-\twchar_t wcmd[MAX_PATH], wdir[MAX_PATH], *wargs;\n-\tunsigned flags;\n+\tstruct strbuf args;\n+\twchar_t wcmd[MAX_PATH], wdir[MAX_PATH], *wargs, *wenvblk = NULL;\n+\tunsigned flags = CREATE_UNICODE_ENVIRONMENT;\n \tBOOL ret;\n \n \t/* Determine whether or not we are associated to a console */\n@@ -938,7 +938,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n \t\t * instead of CREATE_NO_WINDOW to make ssh\n \t\t * recognize that it has no console.\n \t\t */\n-\t\tflags = DETACHED_PROCESS;\n+\t\tflags |= DETACHED_PROCESS;\n \t} else {\n \t\t/* There is already a console. If we specified\n \t\t * DETACHED_PROCESS here, too, Windows would\n@@ -946,7 +946,6 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n \t\t * The same is true for CREATE_NO_WINDOW.\n \t\t * Go figure!\n \t\t */\n-\t\tflags = 0;\n \t\tCloseHandle(cons);\n \t}\n \tmemset(&si, 0, sizeof(si));\n@@ -985,6 +984,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n \tif (env) {\n \t\tint count = 0;\n \t\tchar **e, **sorted_env;\n+\t\tint size = 0, wenvsz = 0, wenvpos = 0;\n \n \t\tfor (e = env; *e; e++)\n \t\t\tcount++;\n@@ -994,20 +994,22 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n \t\tmemcpy(sorted_env, env, sizeof(*sorted_env) * (count + 1));\n \t\tqsort(sorted_env, count, sizeof(*sorted_env), env_compare);\n \n-\t\tstrbuf_init(&envblk, 0);\n+\t\t/* create environment block from temporary environment */\n \t\tfor (e = sorted_env; *e; e++) {\n-\t\t\tstrbuf_addstr(&envblk, *e);\n-\t\t\tstrbuf_addch(&envblk, '\\0');\n+\t\t\tsize = 2 * strlen(*e) + 2; /* +2 for final \\0 */\n+\t\t\tALLOC_GROW(wenvblk, (wenvpos + size) * sizeof(wchar_t), wenvsz);\n+\t\t\twenvpos += xutftowcs(&wenvblk[wenvpos], *e, size) + 1;\n \t\t}\n+\t\t/* add final \\0 terminator */\n+\t\twenvblk[wenvpos] = 0;\n \t\tfree(sorted_env);\n \t}\n \n \tmemset(&pi, 0, sizeof(pi));\n \tret = CreateProcessW(wcmd, wargs, NULL, NULL, TRUE, flags,\n-\t\tenv ? envblk.buf : NULL, dir ? wdir : NULL, &si, &pi);\n+\t\twenvblk, dir ? wdir : NULL, &si, &pi);\n \n-\tif (env)\n-\t\tstrbuf_release(&envblk);\n+\tfree(wenvblk);\n \tfree(wargs);\n \n \tif (!ret) {\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246246","messageId":"1405611486-10176-4-git-send-email-kasal@ucw.cz","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 03/13] Win32: Unicode environment (incoming)","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T15:37:56Z","receivedAt":"2014-07-17T15:37:56Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\n\nConvert environment from UTF-16 to UTF-8 on startup.\n\nNo changes to getenv() are necessary, as the MSVCRT version is implemented\non top of char **environ.\n\nHowever, putenv / _wputenv from MSVCRT no longer work, for two reasons:\n1. they try to keep environ, _wenviron and the Win32 process environment\nin sync, using the default system encoding instead of UTF-8 to convert\nbetween charsets\n2. msysgit and MSVCRT use different allocators, memory allocated in git\ncannot be freed by the CRT and vice versa\n\nImplement mingw_putenv using the env_setenv helper function from the\nenvironment merge code.\n\nNote that in case of memory allocation failure, putenv now dies with error\nmessage (due to xrealloc) instead of failing with ENOMEM. As git assumes\nsetenv / putenv to always succeed, this prevents it from continuing with\nincorrect settings.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 15 +++++++++++++++\n compat/mingw.h |  2 ++\n 2 files changed, 17 insertions(+)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex bd45950..eadba8a 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -1259,6 +1259,12 @@ char *mingw_getenv(const char *name)\n \treturn result;\n }\n \n+int mingw_putenv(const char *namevalue)\n+{\n+\tenviron = env_setenv(environ, namevalue);\n+\treturn 0;\n+}\n+\n /*\n  * Note, this isn't a complete replacement for getaddrinfo. It assumes\n  * that service contains a numerical port, or that it is null. It\n@@ -2051,6 +2057,11 @@ void mingw_startup()\n \tmaxlen = wcslen(_wpgmptr);\n \tfor (i = 1; i < argc; i++)\n \t\tmaxlen = max(maxlen, wcslen(wargv[i]));\n+\tfor (i = 0; wenv[i]; i++)\n+\t\tmaxlen = max(maxlen, wcslen(wenv[i]));\n+\n+\t/* nedmalloc can't free CRT memory, allocate resizable environment list */\n+\tenviron = xcalloc(i + 1, sizeof(char*));\n \n \t/* allocate buffer (wchar_t encodes to max 3 UTF-8 bytes) */\n \tmaxlen = 3 * maxlen + 1;\n@@ -2063,6 +2074,10 @@ void mingw_startup()\n \t\tlen = xwcstoutf(buffer, wargv[i], maxlen);\n \t\t__argv[i] = xmemdupz(buffer, len);\n \t}\n+\tfor (i = 0; wenv[i]; i++) {\n+\t\tlen = xwcstoutf(buffer, wenv[i], maxlen);\n+\t\tenviron[i] = xmemdupz(buffer, len);\n+\t}\n \tfree(buffer);\n \n \t/* initialize critical section for waitpid pinfo_t list */\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 510530c..c3889ca 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -210,6 +210,8 @@ char *mingw_getcwd(char *pointer, int len);\n \n char *mingw_getenv(const char *name);\n #define getenv mingw_getenv\n+int mingw_putenv(const char *namevalue);\n+#define putenv mingw_putenv\n \n int mingw_gethostname(char *host, int namelen);\n #define gethostname mingw_gethostname\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246236","messageId":"1405611486-10176-5-git-send-email-kasal@ucw.cz","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 04/13] Win32: fix environment memory leaks","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T15:37:57Z","receivedAt":"2014-07-17T15:37:57Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\n\nAll functions that modify the environment have memory leaks.\n\nDisable gitunsetenv in the Makefile and use env_setenv (via mingw_putenv)\ninstead (this frees removed environment entries).\n\nMove xstrdup from env_setenv to make_augmented_environ, so that\nmingw_putenv no longer copies the environment entries (according to POSIX\n[1], \"the string [...] shall become part of the environment\"). This also\nfixes the memory leak in gitsetenv, which expects a POSIX compliant putenv.\n\n[1] http://pubs.opengroup.org/onlinepubs/009695399/functions/putenv.html\n\nNote: This patch depends on taking control of char **environ and having\nour own mingw_putenv (both introduced in \"Win32: Unicode environment\n(incoming)\").\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c   | 10 ++++++----\n compat/mingw.h   |  1 +\n config.mak.uname |  2 --\n 3 files changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex eadba8a..47e866c 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -1219,14 +1219,14 @@ static char **env_setenv(char **env, const char *name)\n \t\t\tfor (i = 0; env[i]; i++)\n \t\t\t\t;\n \t\t\tenv = xrealloc(env, (i+2)*sizeof(*env));\n-\t\t\tenv[i] = xstrdup(name);\n+\t\t\tenv[i] = (char*) name;\n \t\t\tenv[i+1] = NULL;\n \t\t}\n \t}\n \telse {\n \t\tfree(env[i]);\n \t\tif (*eq)\n-\t\t\tenv[i] = xstrdup(name);\n+\t\t\tenv[i] = (char*) name;\n \t\telse\n \t\t\tfor (; env[i]; i++)\n \t\t\t\tenv[i] = env[i+1];\n@@ -1241,8 +1241,10 @@ char **make_augmented_environ(const char *const *vars)\n {\n \tchar **env = copy_environ();\n \n-\twhile (*vars)\n-\t\tenv = env_setenv(env, *vars++);\n+\twhile (*vars) {\n+\t\tconst char *v = *vars++;\n+\t\tenv = env_setenv(env, strchr(v, '=') ? xstrdup(v) : v);\n+\t}\n \treturn env;\n }\n \ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex c3889ca..ef94194 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -212,6 +212,7 @@ char *mingw_getenv(const char *name);\n #define getenv mingw_getenv\n int mingw_putenv(const char *namevalue);\n #define putenv mingw_putenv\n+#define unsetenv mingw_putenv\n \n int mingw_gethostname(char *host, int namelen);\n #define gethostname mingw_gethostname\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 00cf4c6..15ee15e 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -327,7 +327,6 @@ ifeq ($(uname_S),Windows)\n \tNO_IPV6 = YesPlease\n \tNO_UNIX_SOCKETS = YesPlease\n \tNO_SETENV = YesPlease\n-\tNO_UNSETENV = YesPlease\n \tNO_STRCASESTR = YesPlease\n \tNO_STRLCPY = YesPlease\n \tNO_MEMMEM = YesPlease\n@@ -480,7 +479,6 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tNO_SYMLINK_HEAD = YesPlease\n \tNO_UNIX_SOCKETS = YesPlease\n \tNO_SETENV = YesPlease\n-\tNO_UNSETENV = YesPlease\n \tNO_STRCASESTR = YesPlease\n \tNO_STRLCPY = YesPlease\n \tNO_MEMMEM = YesPlease\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246245","messageId":"1405611486-10176-6-git-send-email-kasal@ucw.cz","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 05/13] Win32: unify environment case-sensitivity","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T15:37:58Z","receivedAt":"2014-07-17T15:37:58Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\n\nThe environment on Windows is case-insensitive. Some environment functions\n(such as unsetenv and make_augmented_environ) have always used case-\nsensitive comparisons instead, while others (getenv, putenv, sorting in\nspawn*) were case-insensitive.\n\nPrevent potential inconsistencies by using case-insensitive comparison in\nlookup_env (used by putenv, unsetenv and make_augmented_environ).\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 47e866c..fe869ed 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -1198,8 +1198,7 @@ static int lookup_env(char **env, const char *name, size_t nmln)\n \tint i;\n \n \tfor (i = 0; env[i]; i++) {\n-\t\tif (0 == strncmp(env[i], name, nmln)\n-\t\t    && '=' == env[i][nmln])\n+\t\tif (!strncasecmp(env[i], name, nmln) && '=' == env[i][nmln])\n \t\t\t/* matches */\n \t\t\treturn i;\n \t}\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246249","messageId":"1405611486-10176-7-git-send-email-kasal@ucw.cz","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 06/13] Win32: unify environment function names","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T15:37:59Z","receivedAt":"2014-07-17T15:37:59Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\n\nEnvironment helper functions use random naming ('env' prefix or suffix or\nboth, with or without '_'). Change to POSIX naming scheme ('env' suffix,\nno '_').\n\nEnv_setenv has more in common with putenv than setenv. Change to do_putenv.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 14 +++++++-------\n 1 file changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex fe869ed..89fe62b 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -898,7 +898,7 @@ static char *path_lookup(const char *cmd, char **path, int exe_only)\n \treturn prog;\n }\n \n-static int env_compare(const void *a, const void *b)\n+static int compareenv(const void *a, const void *b)\n {\n \tchar *const *ea = a;\n \tchar *const *eb = b;\n@@ -992,7 +992,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n \t\t/* environment must be sorted */\n \t\tsorted_env = xmalloc(sizeof(*sorted_env) * (count + 1));\n \t\tmemcpy(sorted_env, env, sizeof(*sorted_env) * (count + 1));\n-\t\tqsort(sorted_env, count, sizeof(*sorted_env), env_compare);\n+\t\tqsort(sorted_env, count, sizeof(*sorted_env), compareenv);\n \n \t\t/* create environment block from temporary environment */\n \t\tfor (e = sorted_env; *e; e++) {\n@@ -1193,7 +1193,7 @@ void free_environ(char **env)\n \tfree(env);\n }\n \n-static int lookup_env(char **env, const char *name, size_t nmln)\n+static int lookupenv(char **env, const char *name, size_t nmln)\n {\n \tint i;\n \n@@ -1208,10 +1208,10 @@ static int lookup_env(char **env, const char *name, size_t nmln)\n /*\n  * If name contains '=', then sets the variable, otherwise it unsets it\n  */\n-static char **env_setenv(char **env, const char *name)\n+static char **do_putenv(char **env, const char *name)\n {\n \tchar *eq = strchrnul(name, '=');\n-\tint i = lookup_env(env, name, eq-name);\n+\tint i = lookupenv(env, name, eq-name);\n \n \tif (i < 0) {\n \t\tif (*eq) {\n@@ -1242,7 +1242,7 @@ char **make_augmented_environ(const char *const *vars)\n \n \twhile (*vars) {\n \t\tconst char *v = *vars++;\n-\t\tenv = env_setenv(env, strchr(v, '=') ? xstrdup(v) : v);\n+\t\tenv = do_putenv(env, strchr(v, '=') ? xstrdup(v) : v);\n \t}\n \treturn env;\n }\n@@ -1262,7 +1262,7 @@ char *mingw_getenv(const char *name)\n \n int mingw_putenv(const char *namevalue)\n {\n-\tenviron = env_setenv(environ, namevalue);\n+\tenviron = do_putenv(environ, namevalue);\n \treturn 0;\n }\n \n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246238","messageId":"1405611486-10176-8-git-send-email-kasal@ucw.cz","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 07/13] Win32: factor out environment block creation","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T15:38:00Z","receivedAt":"2014-07-17T15:38:00Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 55 ++++++++++++++++++++++++++++++++-----------------------\n 1 file changed, 32 insertions(+), 23 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 89fe62b..3f81c90 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -905,6 +905,36 @@ static int compareenv(const void *a, const void *b)\n \treturn strcasecmp(*ea, *eb);\n }\n \n+/*\n+ * Create environment block suitable for CreateProcess.\n+ */\n+static wchar_t *make_environment_block(char **env)\n+{\n+\twchar_t *wenvblk = NULL;\n+\tint count = 0;\n+\tchar **e, **tmpenv;\n+\tint size = 0, wenvsz = 0, wenvpos = 0;\n+\n+\tfor (e = env; *e; e++)\n+\t\tcount++;\n+\n+\t/* environment must be sorted */\n+\ttmpenv = xmalloc(sizeof(*tmpenv) * (count + 1));\n+\tmemcpy(tmpenv, env, sizeof(*tmpenv) * (count + 1));\n+\tqsort(tmpenv, count, sizeof(*tmpenv), compareenv);\n+\n+\t/* create environment block from temporary environment */\n+\tfor (e = tmpenv; *e; e++) {\n+\t\tsize = 2 * strlen(*e) + 2; /* +2 for final \\0 */\n+\t\tALLOC_GROW(wenvblk, (wenvpos + size) * sizeof(wchar_t), wenvsz);\n+\t\twenvpos += xutftowcs(&wenvblk[wenvpos], *e, size) + 1;\n+\t}\n+\t/* add final \\0 terminator */\n+\twenvblk[wenvpos] = 0;\n+\tfree(tmpenv);\n+\treturn wenvblk;\n+}\n+\n struct pinfo_t {\n \tstruct pinfo_t *next;\n \tpid_t pid;\n@@ -981,29 +1011,8 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n \txutftowcs(wargs, args.buf, 2 * args.len + 1);\n \tstrbuf_release(&args);\n \n-\tif (env) {\n-\t\tint count = 0;\n-\t\tchar **e, **sorted_env;\n-\t\tint size = 0, wenvsz = 0, wenvpos = 0;\n-\n-\t\tfor (e = env; *e; e++)\n-\t\t\tcount++;\n-\n-\t\t/* environment must be sorted */\n-\t\tsorted_env = xmalloc(sizeof(*sorted_env) * (count + 1));\n-\t\tmemcpy(sorted_env, env, sizeof(*sorted_env) * (count + 1));\n-\t\tqsort(sorted_env, count, sizeof(*sorted_env), compareenv);\n-\n-\t\t/* create environment block from temporary environment */\n-\t\tfor (e = sorted_env; *e; e++) {\n-\t\t\tsize = 2 * strlen(*e) + 2; /* +2 for final \\0 */\n-\t\t\tALLOC_GROW(wenvblk, (wenvpos + size) * sizeof(wchar_t), wenvsz);\n-\t\t\twenvpos += xutftowcs(&wenvblk[wenvpos], *e, size) + 1;\n-\t\t}\n-\t\t/* add final \\0 terminator */\n-\t\twenvblk[wenvpos] = 0;\n-\t\tfree(sorted_env);\n-\t}\n+\tif (env)\n+\t\twenvblk = make_environment_block(env);\n \n \tmemset(&pi, 0, sizeof(pi));\n \tret = CreateProcessW(wcmd, wargs, NULL, NULL, TRUE, flags,\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246244","messageId":"1405611486-10176-9-git-send-email-kasal@ucw.cz","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 08/13] Win32: don't copy the environment twice when spawning child processes","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T15:38:01Z","receivedAt":"2014-07-17T15:38:01Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\n\nWhen spawning child processes via start_command(), the environment and all\nenvironment entries are copied twice. First by make_augmented_environ /\ncopy_environ to merge with child_process.env. Then a second time by\nmake_environment_block to create a sorted environment block string as\nrequired by CreateProcess.\n\nMove the merge logic to make_environment_block so that we only need to copy\nthe environment once. This changes semantics of the env parameter: it now\nexpects a delta (such as child_process.env) rather than a full environment.\nThis is not a problem as the parameter is only used by start_command()\n(all other callers previously passed char **environ, and now pass NULL).\n\nThe merge logic no longer xstrdup()s the environment strings, so do_putenv\nmust not free them. Add a parameter to distinguish this from normal putenv.\n\nRemove the now unused make_augmented_environ / free_environ API.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 76 ++++++++++++++++++++--------------------------------------\n compat/mingw.h |  8 ++-----\n run-command.c  | 10 ++------\n 3 files changed, 30 insertions(+), 64 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 3f81c90..ffff592 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -898,6 +898,8 @@ static char *path_lookup(const char *cmd, char **path, int exe_only)\n \treturn prog;\n }\n \n+static char **do_putenv(char **env, const char *name, int free_old);\n+\n static int compareenv(const void *a, const void *b)\n {\n \tchar *const *ea = a;\n@@ -906,21 +908,30 @@ static int compareenv(const void *a, const void *b)\n }\n \n /*\n- * Create environment block suitable for CreateProcess.\n+ * Create environment block suitable for CreateProcess. Merges current\n+ * process environment and the supplied environment changes.\n  */\n-static wchar_t *make_environment_block(char **env)\n+static wchar_t *make_environment_block(char **deltaenv)\n {\n \twchar_t *wenvblk = NULL;\n \tint count = 0;\n \tchar **e, **tmpenv;\n \tint size = 0, wenvsz = 0, wenvpos = 0;\n \n-\tfor (e = env; *e; e++)\n+\twhile (environ[count])\n \t\tcount++;\n \n-\t/* environment must be sorted */\n+\t/* copy the environment */\n \ttmpenv = xmalloc(sizeof(*tmpenv) * (count + 1));\n-\tmemcpy(tmpenv, env, sizeof(*tmpenv) * (count + 1));\n+\tmemcpy(tmpenv, environ, sizeof(*tmpenv) * (count + 1));\n+\n+\t/* merge supplied environment changes into the temporary environment */\n+\tfor (e = deltaenv; e && *e; e++)\n+\t\ttmpenv = do_putenv(tmpenv, *e, 0);\n+\n+\t/* environment must be sorted */\n+\tfor (count = 0; tmpenv[count]; )\n+\t\tcount++;\n \tqsort(tmpenv, count, sizeof(*tmpenv), compareenv);\n \n \t/* create environment block from temporary environment */\n@@ -943,7 +954,7 @@ struct pinfo_t {\n static struct pinfo_t *pinfo = NULL;\n CRITICAL_SECTION pinfo_cs;\n \n-static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n+static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaenv,\n \t\t\t      const char *dir,\n \t\t\t      int prepend_cmd, int fhin, int fhout, int fherr)\n {\n@@ -1011,8 +1022,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n \txutftowcs(wargs, args.buf, 2 * args.len + 1);\n \tstrbuf_release(&args);\n \n-\tif (env)\n-\t\twenvblk = make_environment_block(env);\n+\twenvblk = make_environment_block(deltaenv);\n \n \tmemset(&pi, 0, sizeof(pi));\n \tret = CreateProcessW(wcmd, wargs, NULL, NULL, TRUE, flags,\n@@ -1050,10 +1060,10 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n \n static pid_t mingw_spawnv(const char *cmd, const char **argv, int prepend_cmd)\n {\n-\treturn mingw_spawnve_fd(cmd, argv, environ, NULL, prepend_cmd, 0, 1, 2);\n+\treturn mingw_spawnve_fd(cmd, argv, NULL, NULL, prepend_cmd, 0, 1, 2);\n }\n \n-pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env,\n+pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **deltaenv,\n \t\t     const char *dir,\n \t\t     int fhin, int fhout, int fherr)\n {\n@@ -1077,14 +1087,14 @@ pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env,\n \t\t\t\tpid = -1;\n \t\t\t}\n \t\t\telse {\n-\t\t\t\tpid = mingw_spawnve_fd(iprog, argv, env, dir, 1,\n+\t\t\t\tpid = mingw_spawnve_fd(iprog, argv, deltaenv, dir, 1,\n \t\t\t\t\t\t       fhin, fhout, fherr);\n \t\t\t\tfree(iprog);\n \t\t\t}\n \t\t\targv[0] = argv0;\n \t\t}\n \t\telse\n-\t\t\tpid = mingw_spawnve_fd(prog, argv, env, dir, 0,\n+\t\t\tpid = mingw_spawnve_fd(prog, argv, deltaenv, dir, 0,\n \t\t\t\t\t       fhin, fhout, fherr);\n \t\tfree(prog);\n \t}\n@@ -1181,27 +1191,6 @@ int mingw_kill(pid_t pid, int sig)\n \treturn -1;\n }\n \n-static char **copy_environ(void)\n-{\n-\tchar **env;\n-\tint i = 0;\n-\twhile (environ[i])\n-\t\ti++;\n-\tenv = xmalloc((i+1)*sizeof(*env));\n-\tfor (i = 0; environ[i]; i++)\n-\t\tenv[i] = xstrdup(environ[i]);\n-\tenv[i] = NULL;\n-\treturn env;\n-}\n-\n-void free_environ(char **env)\n-{\n-\tint i;\n-\tfor (i = 0; env[i]; i++)\n-\t\tfree(env[i]);\n-\tfree(env);\n-}\n-\n static int lookupenv(char **env, const char *name, size_t nmln)\n {\n \tint i;\n@@ -1217,7 +1206,7 @@ static int lookupenv(char **env, const char *name, size_t nmln)\n /*\n  * If name contains '=', then sets the variable, otherwise it unsets it\n  */\n-static char **do_putenv(char **env, const char *name)\n+static char **do_putenv(char **env, const char *name, int free_old)\n {\n \tchar *eq = strchrnul(name, '=');\n \tint i = lookupenv(env, name, eq-name);\n@@ -1232,7 +1221,8 @@ static char **do_putenv(char **env, const char *name)\n \t\t}\n \t}\n \telse {\n-\t\tfree(env[i]);\n+\t\tif (free_old)\n+\t\t\tfree(env[i]);\n \t\tif (*eq)\n \t\t\tenv[i] = (char*) name;\n \t\telse\n@@ -1242,20 +1232,6 @@ static char **do_putenv(char **env, const char *name)\n \treturn env;\n }\n \n-/*\n- * Copies global environ and adjusts variables as specified by vars.\n- */\n-char **make_augmented_environ(const char *const *vars)\n-{\n-\tchar **env = copy_environ();\n-\n-\twhile (*vars) {\n-\t\tconst char *v = *vars++;\n-\t\tenv = do_putenv(env, strchr(v, '=') ? xstrdup(v) : v);\n-\t}\n-\treturn env;\n-}\n-\n #undef getenv\n char *mingw_getenv(const char *name)\n {\n@@ -1271,7 +1247,7 @@ char *mingw_getenv(const char *name)\n \n int mingw_putenv(const char *namevalue)\n {\n-\tenviron = do_putenv(environ, namevalue);\n+\tenviron = do_putenv(environ, namevalue, 1);\n \treturn 0;\n }\n \ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex ef94194..df0e320 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -360,12 +360,8 @@ int mingw_offset_1st_component(const char *path);\n void mingw_open_html(const char *path);\n #define open_html mingw_open_html\n \n-/*\n- * helpers\n- */\n-\n-char **make_augmented_environ(const char *const *vars);\n-void free_environ(char **env);\n+void mingw_mark_as_git_dir(const char *dir);\n+#define mark_as_git_dir mingw_mark_as_git_dir\n \n /**\n  * Converts UTF-8 encoded string to UTF-16LE.\ndiff --git a/run-command.c b/run-command.c\nindex 614b8ac..8e558ad 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -454,7 +454,6 @@ fail_pipe:\n {\n \tint fhin = 0, fhout = 1, fherr = 2;\n \tconst char **sargv = cmd->argv;\n-\tchar **env = environ;\n \n \tif (cmd->no_stdin)\n \t\tfhin = open(\"/dev/null\", O_RDWR);\n@@ -479,24 +478,19 @@ fail_pipe:\n \telse if (cmd->out > 1)\n \t\tfhout = dup(cmd->out);\n \n-\tif (cmd->env)\n-\t\tenv = make_augmented_environ(cmd->env);\n-\n \tif (cmd->git_cmd)\n \t\tcmd->argv = prepare_git_cmd(cmd->argv);\n \telse if (cmd->use_shell)\n \t\tcmd->argv = prepare_shell_cmd(cmd->argv);\n \n-\tcmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, env, cmd->dir,\n-\t\t\t\t  fhin, fhout, fherr);\n+\tcmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, (char**) cmd->env,\n+\t\t\tcmd->dir, fhin, fhout, fherr);\n \tfailed_errno = errno;\n \tif (cmd->pid < 0 && (!cmd->silent_exec_failure || errno != ENOENT))\n \t\terror(\"cannot spawn %s: %s\", cmd->argv[0], strerror(errno));\n \tif (cmd->clean_on_exit && cmd->pid >= 0)\n \t\tmark_child_for_cleanup(cmd->pid);\n \n-\tif (cmd->env)\n-\t\tfree_environ(env);\n \tif (cmd->git_cmd)\n \t\tfree(cmd->argv);\n \n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246237","messageId":"1405611486-10176-10-git-send-email-kasal@ucw.cz","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 09/13] Win32: reduce environment array reallocations","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T15:38:02Z","receivedAt":"2014-07-17T15:38:02Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\n\nMove environment array reallocation from do_putenv to the respective\ncallers. Keep track of the environment size in a global variable. Use\nALLOC_GROW in mingw_putenv to reduce reallocations. Allocate a\nsufficiently sized environment array in make_environment_block to prevent\nreallocations.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 62 +++++++++++++++++++++++++++++++++-------------------------\n 1 file changed, 35 insertions(+), 27 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex ffff592..e63fd6a 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -898,7 +898,12 @@ static char *path_lookup(const char *cmd, char **path, int exe_only)\n \treturn prog;\n }\n \n-static char **do_putenv(char **env, const char *name, int free_old);\n+static int do_putenv(char **env, const char *name, int size, int free_old);\n+\n+/* used number of elements of environ array, including terminating NULL */\n+static int environ_size = 0;\n+/* allocated size of environ array, in bytes */\n+static int environ_alloc = 0;\n \n static int compareenv(const void *a, const void *b)\n {\n@@ -914,31 +919,28 @@ static int compareenv(const void *a, const void *b)\n static wchar_t *make_environment_block(char **deltaenv)\n {\n \twchar_t *wenvblk = NULL;\n-\tint count = 0;\n-\tchar **e, **tmpenv;\n-\tint size = 0, wenvsz = 0, wenvpos = 0;\n+\tchar **tmpenv;\n+\tint i = 0, size = environ_size, wenvsz = 0, wenvpos = 0;\n \n-\twhile (environ[count])\n-\t\tcount++;\n+\twhile (deltaenv && deltaenv[i])\n+\t\ti++;\n \n-\t/* copy the environment */\n-\ttmpenv = xmalloc(sizeof(*tmpenv) * (count + 1));\n-\tmemcpy(tmpenv, environ, sizeof(*tmpenv) * (count + 1));\n+\t/* copy the environment, leaving space for changes */\n+\ttmpenv = xmalloc((size + i) * sizeof(char*));\n+\tmemcpy(tmpenv, environ, size * sizeof(char*));\n \n \t/* merge supplied environment changes into the temporary environment */\n-\tfor (e = deltaenv; e && *e; e++)\n-\t\ttmpenv = do_putenv(tmpenv, *e, 0);\n+\tfor (i = 0; deltaenv && deltaenv[i]; i++)\n+\t\tsize = do_putenv(tmpenv, deltaenv[i], size, 0);\n \n \t/* environment must be sorted */\n-\tfor (count = 0; tmpenv[count]; )\n-\t\tcount++;\n-\tqsort(tmpenv, count, sizeof(*tmpenv), compareenv);\n+\tqsort(tmpenv, size - 1, sizeof(char*), compareenv);\n \n \t/* create environment block from temporary environment */\n-\tfor (e = tmpenv; *e; e++) {\n-\t\tsize = 2 * strlen(*e) + 2; /* +2 for final \\0 */\n+\tfor (i = 0; tmpenv[i]; i++) {\n+\t\tsize = 2 * strlen(tmpenv[i]) + 2; /* +2 for final \\0 */\n \t\tALLOC_GROW(wenvblk, (wenvpos + size) * sizeof(wchar_t), wenvsz);\n-\t\twenvpos += xutftowcs(&wenvblk[wenvpos], *e, size) + 1;\n+\t\twenvpos += xutftowcs(&wenvblk[wenvpos], tmpenv[i], size) + 1;\n \t}\n \t/* add final \\0 terminator */\n \twenvblk[wenvpos] = 0;\n@@ -1205,19 +1207,19 @@ static int lookupenv(char **env, const char *name, size_t nmln)\n \n /*\n  * If name contains '=', then sets the variable, otherwise it unsets it\n+ * Size includes the terminating NULL. Env must have room for size + 1 entries\n+ * (in case of insert). Returns the new size. Optionally frees removed entries.\n  */\n-static char **do_putenv(char **env, const char *name, int free_old)\n+static int do_putenv(char **env, const char *name, int size, int free_old)\n {\n \tchar *eq = strchrnul(name, '=');\n \tint i = lookupenv(env, name, eq-name);\n \n \tif (i < 0) {\n \t\tif (*eq) {\n-\t\t\tfor (i = 0; env[i]; i++)\n-\t\t\t\t;\n-\t\t\tenv = xrealloc(env, (i+2)*sizeof(*env));\n-\t\t\tenv[i] = (char*) name;\n-\t\t\tenv[i+1] = NULL;\n+\t\t\tenv[size - 1] = (char*) name;\n+\t\t\tenv[size] = NULL;\n+\t\t\tsize++;\n \t\t}\n \t}\n \telse {\n@@ -1225,11 +1227,13 @@ static char **do_putenv(char **env, const char *name, int free_old)\n \t\t\tfree(env[i]);\n \t\tif (*eq)\n \t\t\tenv[i] = (char*) name;\n-\t\telse\n+\t\telse {\n \t\t\tfor (; env[i]; i++)\n \t\t\t\tenv[i] = env[i+1];\n+\t\t\tsize--;\n+\t\t}\n \t}\n-\treturn env;\n+\treturn size;\n }\n \n #undef getenv\n@@ -1247,7 +1251,8 @@ char *mingw_getenv(const char *name)\n \n int mingw_putenv(const char *namevalue)\n {\n-\tenviron = do_putenv(environ, namevalue, 1);\n+\tALLOC_GROW(environ, (environ_size + 1) * sizeof(char*), environ_alloc);\n+\tenviron_size = do_putenv(environ, namevalue, environ_size, 1);\n \treturn 0;\n }\n \n@@ -2047,7 +2052,9 @@ void mingw_startup()\n \t\tmaxlen = max(maxlen, wcslen(wenv[i]));\n \n \t/* nedmalloc can't free CRT memory, allocate resizable environment list */\n-\tenviron = xcalloc(i + 1, sizeof(char*));\n+\tenviron = NULL;\n+\tenviron_size = i + 1;\n+\tALLOC_GROW(environ, environ_size * sizeof(char*), environ_alloc);\n \n \t/* allocate buffer (wchar_t encodes to max 3 UTF-8 bytes) */\n \tmaxlen = 3 * maxlen + 1;\n@@ -2064,6 +2071,7 @@ void mingw_startup()\n \t\tlen = xwcstoutf(buffer, wenv[i], maxlen);\n \t\tenviron[i] = xmemdupz(buffer, len);\n \t}\n+\tenviron[i] = NULL;\n \tfree(buffer);\n \n \t/* initialize critical section for waitpid pinfo_t list */\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246243","messageId":"1405611486-10176-11-git-send-email-kasal@ucw.cz","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 10/13] Win32: use low-level memory allocation during initialization","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T15:38:03Z","receivedAt":"2014-07-17T15:38:03Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\n\nAs of d41489a6 \"Add more large blob test cases\", git's high-level memory\nallocation functions (xmalloc, xmemdupz etc.) access the environment to\nsimulate limited memory in tests (see 'getenv(\"GIT_ALLOC_LIMIT\")' in\nmemory_limit_check()). These functions should not be used before the\nenvironment is fully initialized (particularly not to initialize the\nenvironment itself).\n\nThe current solution ('environ = NULL; ALLOC_GROW(environ...)') only works\nbecause MSVCRT's getenv() reinitializes environ when it is NULL (i.e. it\nleaves us with two sets of unusabe (non-UTF-8) and unfreeable (CRT-\nallocated) environments).\n\nAdd our own set of malloc-or-die functions to be used in startup code.\n\nAlso check the result of __wgetmainargs, which may fail if there's not\nenough memory for wide-char arguments and environment.\n\nThis patch is in preparation of the sorted environment feature, which\ncompletely replaces MSVCRT's getenv() implementation.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 43 ++++++++++++++++++++++++++++---------------\n 1 file changed, 28 insertions(+), 15 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex e63fd6a..757a6b1 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2032,9 +2032,23 @@ static NORETURN void die_startup()\n \texit(128);\n }\n \n+static void *malloc_startup(size_t size)\n+{\n+\tvoid *result = malloc(size);\n+\tif (!result)\n+\t\tdie_startup();\n+\treturn result;\n+}\n+\n+static char *wcstoutfdup_startup(char *buffer, const wchar_t *wcs, size_t len)\n+{\n+\tlen = xwcstoutf(buffer, wcs, len) + 1;\n+\treturn memcpy(malloc_startup(len), buffer, len);\n+}\n+\n void mingw_startup()\n {\n-\tint i, len, maxlen, argc;\n+\tint i, maxlen, argc;\n \tchar *buffer;\n \twchar_t **wenv, **wargv;\n \t_startupinfo si;\n@@ -2051,26 +2065,25 @@ void mingw_startup()\n \tfor (i = 0; wenv[i]; i++)\n \t\tmaxlen = max(maxlen, wcslen(wenv[i]));\n \n-\t/* nedmalloc can't free CRT memory, allocate resizable environment list */\n-\tenviron = NULL;\n+\t/*\n+\t * nedmalloc can't free CRT memory, allocate resizable environment\n+\t * list. Note that xmalloc / xmemdupz etc. call getenv, so we cannot\n+\t * use it while initializing the environment itself.\n+\t */\n \tenviron_size = i + 1;\n-\tALLOC_GROW(environ, environ_size * sizeof(char*), environ_alloc);\n+\tenviron_alloc = alloc_nr(environ_size * sizeof(char*));\n+\tenviron = malloc_startup(environ_alloc);\n \n \t/* allocate buffer (wchar_t encodes to max 3 UTF-8 bytes) */\n \tmaxlen = 3 * maxlen + 1;\n-\tbuffer = xmalloc(maxlen);\n+\tbuffer = malloc_startup(maxlen);\n \n \t/* convert command line arguments and environment to UTF-8 */\n-\tlen = xwcstoutf(buffer, _wpgmptr, maxlen);\n-\t__argv[0] = xmemdupz(buffer, len);\n-\tfor (i = 1; i < argc; i++) {\n-\t\tlen = xwcstoutf(buffer, wargv[i], maxlen);\n-\t\t__argv[i] = xmemdupz(buffer, len);\n-\t}\n-\tfor (i = 0; wenv[i]; i++) {\n-\t\tlen = xwcstoutf(buffer, wenv[i], maxlen);\n-\t\tenviron[i] = xmemdupz(buffer, len);\n-\t}\n+\t__argv[0] = wcstoutfdup_startup(buffer, _wpgmptr, maxlen);\n+\tfor (i = 1; i < argc; i++)\n+\t\t__argv[i] = wcstoutfdup_startup(buffer, wargv[i], maxlen);\n+\tfor (i = 0; wenv[i]; i++)\n+\t\tenviron[i] = wcstoutfdup_startup(buffer, wenv[i], maxlen);\n \tenviron[i] = NULL;\n \tfree(buffer);\n \n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246247","messageId":"1405611486-10176-12-git-send-email-kasal@ucw.cz","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 11/13] Win32: keep the environment sorted","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T15:38:04Z","receivedAt":"2014-07-17T15:38:04Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\n\nThe Windows environment is sorted, keep it that way for O(log n)\nenvironment access.\n\nChange compareenv to compare only the keys, so that it can be used to\nfind an entry irrespective of the value.\n\nChange lookupenv to binary seach for an entry. Return one's complement of\nthe insert position if not found (libc's bsearch returns NULL).\n\nReplace MSVCRT's getenv with a minimal do_getenv based on the binary search\nfunction.\n\nChange do_putenv to insert new entries at the correct position. Simplify\nthe function by swapping if conditions and using memmove instead of for\nloops.\n\nMove qsort from make_environment_block to mingw_startup. We still need to\nsort on startup to make sure that the environment is sorted according to\nour compareenv function (while Win32 / CreateProcess requires the\nenvironment block to be sorted case-insensitively, CreateProcess currently\ndoesn't enforce this, and some applications such as bash just don't care).\n\nNote that environment functions are _not_ thread-safe and are not required\nto be so by POSIX, the application is responsible for synchronizing access\nto the environment. MSVCRT's getenv and our new getenv implementation are\nbetter than that in that they are thread-safe with respect to other getenv\ncalls as long as the environment is not modified. Git's indiscriminate use\nof getenv in background threads currently requires this property.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 104 +++++++++++++++++++++++++++++++++++----------------------\n 1 file changed, 65 insertions(+), 39 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 757a6b1..9dc6bf6 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -905,13 +905,6 @@ static int environ_size = 0;\n /* allocated size of environ array, in bytes */\n static int environ_alloc = 0;\n \n-static int compareenv(const void *a, const void *b)\n-{\n-\tchar *const *ea = a;\n-\tchar *const *eb = b;\n-\treturn strcasecmp(*ea, *eb);\n-}\n-\n /*\n  * Create environment block suitable for CreateProcess. Merges current\n  * process environment and the supplied environment changes.\n@@ -933,9 +926,6 @@ static wchar_t *make_environment_block(char **deltaenv)\n \tfor (i = 0; deltaenv && deltaenv[i]; i++)\n \t\tsize = do_putenv(tmpenv, deltaenv[i], size, 0);\n \n-\t/* environment must be sorted */\n-\tqsort(tmpenv, size - 1, sizeof(char*), compareenv);\n-\n \t/* create environment block from temporary environment */\n \tfor (i = 0; tmpenv[i]; i++) {\n \t\tsize = 2 * strlen(tmpenv[i]) + 2; /* +2 for final \\0 */\n@@ -1193,16 +1183,42 @@ int mingw_kill(pid_t pid, int sig)\n \treturn -1;\n }\n \n-static int lookupenv(char **env, const char *name, size_t nmln)\n-{\n-\tint i;\n+/*\n+ * Compare environment entries by key (i.e. stopping at '=' or '\\0').\n+ */\n+static int compareenv(const void *v1, const void *v2)\n+{\n+\tconst char *e1 = *(const char**)v1;\n+\tconst char *e2 = *(const char**)v2;\n+\n+\tfor (;;) {\n+\t\tint c1 = *e1++;\n+\t\tint c2 = *e2++;\n+\t\tc1 = (c1 == '=') ? 0 : tolower(c1);\n+\t\tc2 = (c2 == '=') ? 0 : tolower(c2);\n+\t\tif (c1 > c2)\n+\t\t\treturn 1;\n+\t\tif (c1 < c2)\n+\t\t\treturn -1;\n+\t\tif (c1 == 0)\n+\t\t\treturn 0;\n+\t}\n+}\n \n-\tfor (i = 0; env[i]; i++) {\n-\t\tif (!strncasecmp(env[i], name, nmln) && '=' == env[i][nmln])\n-\t\t\t/* matches */\n-\t\t\treturn i;\n+static int bsearchenv(char **env, const char *name, size_t size)\n+{\n+\tunsigned low = 0, high = size;\n+\twhile (low < high) {\n+\t\tunsigned mid = low + ((high - low) >> 1);\n+\t\tint cmp = compareenv(&env[mid], &name);\n+\t\tif (cmp < 0)\n+\t\t\tlow = mid + 1;\n+\t\telse if (cmp > 0)\n+\t\t\thigh = mid;\n+\t\telse\n+\t\t\treturn mid;\n \t}\n-\treturn -1;\n+\treturn ~low; /* not found, return 1's complement of insert position */\n }\n \n /*\n@@ -1212,39 +1228,46 @@ static int lookupenv(char **env, const char *name, size_t nmln)\n  */\n static int do_putenv(char **env, const char *name, int size, int free_old)\n {\n-\tchar *eq = strchrnul(name, '=');\n-\tint i = lookupenv(env, name, eq-name);\n+\tint i = bsearchenv(env, name, size - 1);\n \n-\tif (i < 0) {\n-\t\tif (*eq) {\n-\t\t\tenv[size - 1] = (char*) name;\n-\t\t\tenv[size] = NULL;\n+\t/* optionally free removed / replaced entry */\n+\tif (i >= 0 && free_old)\n+\t\tfree(env[i]);\n+\n+\tif (strchr(name, '=')) {\n+\t\t/* if new value ('key=value') is specified, insert or replace entry */\n+\t\tif (i < 0) {\n+\t\t\ti = ~i;\n+\t\t\tmemmove(&env[i + 1], &env[i], (size - i) * sizeof(char*));\n \t\t\tsize++;\n \t\t}\n-\t}\n-\telse {\n-\t\tif (free_old)\n-\t\t\tfree(env[i]);\n-\t\tif (*eq)\n-\t\t\tenv[i] = (char*) name;\n-\t\telse {\n-\t\t\tfor (; env[i]; i++)\n-\t\t\t\tenv[i] = env[i+1];\n-\t\t\tsize--;\n-\t\t}\n+\t\tenv[i] = (char*) name;\n+\t} else if (i >= 0) {\n+\t\t/* otherwise ('key') remove existing entry */\n+\t\tsize--;\n+\t\tmemmove(&env[i], &env[i + 1], (size - i) * sizeof(char*));\n \t}\n \treturn size;\n }\n \n-#undef getenv\n+static char *do_getenv(const char *name)\n+{\n+\tchar *value;\n+\tint pos = bsearchenv(environ, name, environ_size - 1);\n+\tif (pos < 0)\n+\t\treturn NULL;\n+\tvalue = strchr(environ[pos], '=');\n+\treturn value ? &value[1] : NULL;\n+}\n+\n char *mingw_getenv(const char *name)\n {\n-\tchar *result = getenv(name);\n+\tchar *result = do_getenv(name);\n \tif (!result && !strcmp(name, \"TMPDIR\")) {\n \t\t/* on Windows it is TMP and TEMP */\n-\t\tresult = getenv(\"TMP\");\n+\t\tresult = do_getenv(\"TMP\");\n \t\tif (!result)\n-\t\t\tresult = getenv(\"TEMP\");\n+\t\t\tresult = do_getenv(\"TEMP\");\n \t}\n \treturn result;\n }\n@@ -2087,6 +2110,9 @@ void mingw_startup()\n \tenviron[i] = NULL;\n \tfree(buffer);\n \n+\t/* sort environment for O(log n) getenv / putenv */\n+\tqsort(environ, i, sizeof(char*), compareenv);\n+\n \t/* initialize critical section for waitpid pinfo_t list */\n \tInitializeCriticalSection(&pinfo_cs);\n \n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246242","messageId":"1405611486-10176-13-git-send-email-kasal@ucw.cz","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 12/13] Win32: patch Windows environment on startup","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T15:38:05Z","receivedAt":"2014-07-17T15:38:05Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\n\nFix Windows specific environment settings on startup rather than checking\nfor special values on every getenv call.\n\nAs a side effect, this makes the patched environment (i.e. with properly\ninitialized TMPDIR and TERM) available to child processes.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 25 ++++++++++++-------------\n 1 file changed, 12 insertions(+), 13 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 9dc6bf6..6d4ec56 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -1250,7 +1250,7 @@ static int do_putenv(char **env, const char *name, int size, int free_old)\n \treturn size;\n }\n \n-static char *do_getenv(const char *name)\n+char *mingw_getenv(const char *name)\n {\n \tchar *value;\n \tint pos = bsearchenv(environ, name, environ_size - 1);\n@@ -1260,18 +1260,6 @@ static char *do_getenv(const char *name)\n \treturn value ? &value[1] : NULL;\n }\n \n-char *mingw_getenv(const char *name)\n-{\n-\tchar *result = do_getenv(name);\n-\tif (!result && !strcmp(name, \"TMPDIR\")) {\n-\t\t/* on Windows it is TMP and TEMP */\n-\t\tresult = do_getenv(\"TMP\");\n-\t\tif (!result)\n-\t\t\tresult = do_getenv(\"TEMP\");\n-\t}\n-\treturn result;\n-}\n-\n int mingw_putenv(const char *namevalue)\n {\n \tALLOC_GROW(environ, (environ_size + 1) * sizeof(char*), environ_alloc);\n@@ -2113,6 +2101,17 @@ void mingw_startup()\n \t/* sort environment for O(log n) getenv / putenv */\n \tqsort(environ, i, sizeof(char*), compareenv);\n \n+\t/* fix Windows specific environment settings */\n+\n+\t/* on Windows it is TMP and TEMP */\n+\tif (!mingw_getenv(\"TMPDIR\")) {\n+\t\tconst char *tmp = mingw_getenv(\"TMP\");\n+\t\tif (!tmp)\n+\t\t\ttmp = mingw_getenv(\"TEMP\");\n+\t\tif (tmp)\n+\t\t\tsetenv(\"TMPDIR\", tmp, 1);\n+\t}\n+\n \t/* initialize critical section for waitpid pinfo_t list */\n \tInitializeCriticalSection(&pinfo_cs);\n \n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246239","messageId":"1405611486-10176-14-git-send-email-kasal@ucw.cz","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 13/13] Enable color output in Windows cmd.exe","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T15:38:06Z","receivedAt":"2014-07-17T15:38:06Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\n\nGit requires the TERM environment variable to be set for all color*\nsettings. Simulate the TERM variable if it is not set (default on Windows).\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 6d4ec56..19975fa 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -2112,6 +2112,10 @@ void mingw_startup()\n \t\t\tsetenv(\"TMPDIR\", tmp, 1);\n \t}\n \n+\t/* simulate TERM to enable auto-color (see color.c) */\n+\tif (!getenv(\"TERM\"))\n+\t\tsetenv(\"TERM\", \"cygwin\", 1);\n+\n \t/* initialize critical section for waitpid pinfo_t list */\n \tInitializeCriticalSection(&pinfo_cs);\n \n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246254","messageId":"xmqqsilzq390.fsf@gitster.dls.corp.google.com","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"Re: [PATCH 00/13] mingw unicode environment","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-07-17T17:55:23Z","receivedAt":"2014-07-17T17:55:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stepan Kasal <kasal@ucw.cz> writes:\n\n> ... only one patch\n> would only remain: gitk and git-gui fixes.)\n\nNice.\n\nWill queue.\n\n> When rebasing Karsten's work, I have eliminated two commits:\n> https://github.com/msysgit/git/commit/f967550\n> https://github.com/msysgit/git/commit/290bf81\n>\n> These commits only moved code down and up; this was not necessary, one\n> forward declaration was all I needed.\n>\n> One of the patches differs from the original version: \"Enable color...\"\n> Following Karsten's suggestion, I have changed the value of env. var.\n> TERM from \"winterm\" to \"cygwin\".  This is because the subprocesses see\n> the variable and may try to find it in (their copy of) termcap.\n>\n> Enjoy,\n>    Stepan\n>\n> Karsten Blees (13):\n>   Revert \"Windows: teach getenv to do a case-sensitive search\"\n>   Win32: Unicode environment (outgoing)\n>   Win32: Unicode environment (incoming)\n>   Win32: fix environment memory leaks\n>   Win32: unify environment case-sensitivity\n>   Win32: unify environment function names\n>   Win32: factor out environment block creation\n>   Win32: don't copy the environment twice when spawning child processes\n>   Win32: reduce environment array reallocations\n>   Win32: use low-level memory allocation during initialization\n>   Win32: keep the environment sorted\n>   Win32: patch Windows environment on startup\n>   Enable color output in Windows cmd.exe\n>\n>  compat/mingw.c   | 290 +++++++++++++++++++++++++++++++------------------------\n>  compat/mingw.h   |  11 +--\n>  config.mak.uname |   2 -\n>  run-command.c    |  10 +-\n>  4 files changed, 170 insertions(+), 143 deletions(-)\n>\n> -- \n> 2.0.0.9635.g0be03cb\n>\n> -- \n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246256","messageId":"53C8115D.8040505@gmail.com","threadId":"37150","inReplyTo":"1405611486-10176-1-git-send-email-kasal@ucw.cz","subject":"Re: [PATCH 00/13] mingw unicode environment","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-07-17T18:09:33Z","receivedAt":"2014-07-17T18:09:33Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Am 17.07.2014 17:37, schrieb Stepan Kasal:\n> Hello,\n> \n> this is the remainder of Karsten's unicode branch, that is a time\n> proven part of msysGit.  (If this code is accepted, only one patch\n> would only remain: gitk and git-gui fixes.)\n> \n\nThank you so much!\n\nI had to add '#include \"../cache.h\"' to compile, due to use of\nALLOC_GROW and alloc_nr in some of the patches. In the msysgit HEAD,\nErik's hideDotFile patch does that [1].\n\n[1] https://github.com/msysgit/git/commit/d85d2b75\n\nAfter that (and applying your mingw test fixes), only t7001 fails\n(the 'cp -P' issue).\n\n> When rebasing Karsten's work, I have eliminated two commits:\n> https://github.com/msysgit/git/commit/f967550\n> https://github.com/msysgit/git/commit/290bf81\n> \n> These commits only moved code down and up; this was not necessary, one\n> forward declaration was all I needed.\n> \n\nI believe we prefer moving code to the right place over forward\ndeclarations (IIRC I got bashed for the latter in one of the first rounds\nof this patch series). If only to justify 'git-blame -M' :-D\n\n> One of the patches differs from the original version: \"Enable color...\"\n> Following Karsten's suggestion, I have changed the value of env. var.\n> TERM from \"winterm\" to \"cygwin\".  This is because the subprocesses see\n> the variable and may try to find it in (their copy of) termcap.\n> \n\nGood! One more step towards getting rid of the git-wrapper.\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246259","messageId":"xmqqfvhzq22x.fsf@gitster.dls.corp.google.com","threadId":"37150","inReplyTo":"53C8115D.8040505@gmail.com","subject":"Re: [PATCH 00/13] mingw unicode environment","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-07-17T18:20:38Z","receivedAt":"2014-07-17T18:20:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karsten Blees <karsten.blees@gmail.com> writes:\n\n> Am 17.07.2014 17:37, schrieb Stepan Kasal:\n>\n> I believe we prefer moving code to the right place over forward\n> declarations (IIRC I got bashed for the latter in one of the first rounds\n> of this patch series). If only to justify 'git-blame -M' :-D\n>\n>> One of the patches differs from the original version: \"Enable color...\"\n>> Following Karsten's suggestion, I have changed the value of env. var.\n>> TERM from \"winterm\" to \"cygwin\".  This is because the subprocesses see\n>> the variable and may try to find it in (their copy of) termcap.\n>\n> Good! One more step towards getting rid of the git-wrapper.\n\nOK, so the series may need further re-polishing of the polishing\ndone by Stepan last-minute before sending them out.  I'll still\nqueue but will hold in 'pu' while Windows folks can agree all is\nwell.\n\nThanks.\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246262","messageId":"20140717190000.GA18960@ucw.cz","threadId":"37150","inReplyTo":"xmqqfvhzq22x.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 00/13] mingw unicode environment","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-17T19:00:00Z","receivedAt":"2014-07-17T19:00:00Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"Hi,\n\n> Karsten Blees <karsten.blees@gmail.com> writes:\n> > I believe we prefer moving code to the right place over forward\n> > declarations (IIRC I got bashed for the latter in one of the first rounds\n> > of this patch series). If only to justify 'git-blame -M' :-D\n\nindeed, my position is the same, generally.\n\nBut it turned out that the current ordering is sane, mostly works as it is,\nand I needed _only one_ fwd decl to make things compile.  This is why I\ndecided to have things arranged this way.\n\nIf anyone thinks the resulting ordering is not OK, they can propose\none re-order patch on top of this series.\n\nJunio wrote:\n> OK, so the series may need further re-polishing of the polishing\n> done by Stepan last-minute before sending them out.  I'll still\n\nNo, it was not last minute work.  It was done several weeks ago, after some\nplanning, etc.  It's my best.  Corrections welcome, though.\n\nStepan\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246263","messageId":"xmqq7g3bpzeg.fsf@gitster.dls.corp.google.com","threadId":"37150","inReplyTo":"20140717190000.GA18960@ucw.cz","subject":"Re: [PATCH 00/13] mingw unicode environment","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-07-17T19:18:31Z","receivedAt":"2014-07-17T19:18:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stepan Kasal <kasal@ucw.cz> writes:\n\n> If anyone thinks the resulting ordering is not OK, they can propose\n> one re-order patch on top of this series.\n\nI agree that that would be a good way to go.\n\n> Junio wrote:\n>> OK, so the series may need further re-polishing of the polishing\n>> done by Stepan last-minute before sending them out.  I'll still\n>\n> No, it was not last minute work.  It was done several weeks ago, after some\n> planning, etc.  It's my best.  Corrections welcome, though.\n\nI did not literally mean \"minute\", and I am sorry if I sounded like\nI was saying that you threw junk that are not well-thought-out into\nthe mix.\n\nThe point I wanted to clarify was that the claim to be \"time proven\npart of msysGit\" in the first paragraph of the cover does not apply\nto some of the patches in the series, in which case I shouldn't\nmerge it right to 'master' without waiting for responses.\n\nIn that context (I take \"time proven\" is like \"more than 18\nmonths\"), weeks vs minutes do not make much of a difference anyway\n;-).\n\n\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246264","messageId":"53C822E1.9020003@gmail.com","threadId":"37150","inReplyTo":"20140717190000.GA18960@ucw.cz","subject":"Re: [PATCH 00/13] mingw unicode environment","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-07-17T19:24:17Z","receivedAt":"2014-07-17T19:24:17Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Am 17.07.2014 21:00, schrieb Stepan Kasal:\n> Hi,\n> \n>> Karsten Blees <karsten.blees@gmail.com> writes:\n>>> I believe we prefer moving code to the right place over forward\n>>> declarations (IIRC I got bashed for the latter in one of the first rounds\n>>> of this patch series). If only to justify 'git-blame -M' :-D\n> \n> indeed, my position is the same, generally.\n> \n> But it turned out that the current ordering is sane, mostly works as it is,\n> and I needed _only one_ fwd decl to make things compile.  This is why I\n> decided to have things arranged this way.\n> \n\nFine with me.\n\nHowever, if it *did* compile for you, I wonder where ALLOC_GROW (as of #02/13)\nand alloc_nr (as of #10/13) came from? Or did we recently remove '#include \"cache.h\"'\nfrom upstream mingw.c?\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246328","messageId":"20140718185134.GA9280@ucw.cz","threadId":"37150","inReplyTo":"53C822E1.9020003@gmail.com","subject":"Re: Re: [PATCH 00/13] mingw unicode environment","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-07-18T18:51:34Z","receivedAt":"2014-07-18T18:51:34Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"Hello Karsten,\n\nyou wrote:\n> However, if it *did* compile for you, I wonder where ALLOC_GROW (as of #02/13)\n> and alloc_nr (as of #10/13) came from? Or did we recently remove '#include \"cache.h\"'\n> from upstream mingw.c?\n\nyou are right, the include needs to be added.\n\nTo test my modifications, I rebased all the rest of msysGit collection,\nbuilt and run the test suite.\n\nAs you pointed out, https://github.com/msysgit/git/commit/d85d2b75\nadds the include.\n\nUnfortunately, I won't get to this for several weeks.  Could you or Hannes\nbe so kind and post the fixup?\n\nThank you for this comment.  And big thanks for the orignal work.\n(I was only moving it and even that took some time. ;-)\n\nStepan\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246395","messageId":"53CAC33E.9000009@gmail.com","threadId":"37150","inReplyTo":"1405611486-10176-3-git-send-email-kasal@ucw.cz","subject":"[PATCH] fixup! Win32: Unicode environment (outgoing)","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-07-19T19:13:02Z","receivedAt":"2014-07-19T19:13:02Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"compat/mingw.c needs to #include \"cache.h\" for ALLOC_GROW.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\n---\n compat/mingw.c | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex bd45950..c725a3e 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -4,6 +4,7 @@\n #include <wchar.h>\n #include \"../strbuf.h\"\n #include \"../run-command.h\"\n+#include \"../cache.h\"\n \n static const int delay[] = { 0, 1, 10, 20, 40 };\n \n-- \n2.0.2.897.g7f80809.dirty\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"246460","messageId":"xmqq4myalljf.fsf@gitster.dls.corp.google.com","threadId":"37150","inReplyTo":"53CAC33E.9000009@gmail.com","subject":"Re: [PATCH] fixup! Win32: Unicode environment (outgoing)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-07-21T16:32:52Z","receivedAt":"2014-07-21T16:32:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karsten Blees <karsten.blees@gmail.com> writes:\n\n> compat/mingw.c needs to #include \"cache.h\" for ALLOC_GROW.\n>\n> Signed-off-by: Karsten Blees <blees@dcon.de>\n> ---\n\nThanks!\n\n>  compat/mingw.c | 1 +\n>  1 file changed, 1 insertion(+)\n>\n> diff --git a/compat/mingw.c b/compat/mingw.c\n> index bd45950..c725a3e 100644\n> --- a/compat/mingw.c\n> +++ b/compat/mingw.c\n> @@ -4,6 +4,7 @@\n>  #include <wchar.h>\n>  #include \"../strbuf.h\"\n>  #include \"../run-command.h\"\n> +#include \"../cache.h\"\n>  \n>  static const int delay[] = { 0, 1, 10, 20, 40 };\n>  \n> -- \n> 2.0.2.897.g7f80809.dirty\n>\n> -- \n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"}]}