Skip to content

Commit 9ae1afa

Browse files
kbleesgitster
authored andcommitted
Revert "Windows: teach getenv to do a case-sensitive search"
This reverts commit df599e9. As of 5e9637c "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). 30a615a "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>
1 parent e6ce2be commit 9ae1afa

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

compat/mingw.c

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,31 +1245,14 @@ char **make_augmented_environ(const char *const *vars)
12451245
}
12461246

12471247
#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-
12651248
char *mingw_getenv(const char *name)
12661249
{
1267-
char *result = getenv_cs(name);
1250+
char *result = getenv(name);
12681251
if (!result && !strcmp(name, "TMPDIR")) {
12691252
/* on Windows it is TMP and TEMP */
1270-
result = getenv_cs("TMP");
1253+
result = getenv("TMP");
12711254
if (!result)
1272-
result = getenv_cs("TEMP");
1255+
result = getenv("TEMP");
12731256
}
12741257
return result;
12751258
}

0 commit comments

Comments
 (0)