Revert "Windows: teach getenv to do a case-sensitive search"

This reverts commit df599e9612788b728ce43a03159b85f1fe624d6a. As of 5e9637c6 "i18n: add infrastructure for translating Git with gettext", eval_gettext uses MinGW envsubst.exe instead of git-sh-i18n--envsubst.exe for variable substitution. This breaks git-submodule.sh messages and tests, as envsubst.exe doesn't support case-sensitive environment lookup (the same is true for almost everything on Windows, including MSys and Cygwin tools). 30a615ac "Windows/i18n: rename $path to prevent clashes with $PATH" renames the conflicting variable in git-submodule.sh, so that it works on Windows (i.e. with case-insensitive environment, regardless of the toolset). Revert to the documented behaviour of case-insensitive environment on Windows. Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Stepan Kasal <kasal@ucw.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Karsten Blees committed Jul 17, 2014 at 17:37 UTC 9ae1afa5e659dc61602e8f50fe469c21a9704319
1 file changed +3 -20
compat/mingw.c
+3 -20
@@ -1245,31 +1245,14 @@ char **make_augmented_environ(const char *const *vars)
1245 }
1246
1247 #undef getenv
1248 -
1249 -/*
1250 - * The system's getenv looks up the name in a case-insensitive manner.
1251 - * This version tries a case-sensitive lookup and falls back to
1252 - * case-insensitive if nothing was found. This is necessary because,
1253 - * as a prominent example, CMD sets 'Path', but not 'PATH'.
1254 - * Warning: not thread-safe.
1255 - */
1256 -static char *getenv_cs(const char *name)
1257 -{
1258 - size_t len = strlen(name);
1259 - int i = lookup_env(environ, name, len);
1260 - if (i >= 0)
1261 - return environ[i] + len + 1; /* skip past name and '=' */
1262 - return getenv(name);
1263 -}
1264 -
1248 char *mingw_getenv(const char *name)
1249 {
1267 - char *result = getenv_cs(name);
1250 + char *result = getenv(name);
1251 if (!result && !strcmp(name, "TMPDIR")) {
1252 /* on Windows it is TMP and TEMP */
1270 - result = getenv_cs("TMP");
1253 + result = getenv("TMP");
1254 if (!result)
1272 - result = getenv_cs("TEMP");
1255 + result = getenv("TEMP");
1256 }
1257 return result;
1258 }