Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 1ec9937

Browse files
kbleeskasal
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 <[email protected]>
1 parent aa7bfb8 commit 1ec9937

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
@@ -1155,31 +1155,14 @@ char **make_augmented_environ(const char *const *vars)
11551155
}
11561156

11571157
#undef getenv
1158-
1159-
/*
1160-
* The system's getenv looks up the name in a case-insensitive manner.
1161-
* This version tries a case-sensitive lookup and falls back to
1162-
* case-insensitive if nothing was found. This is necessary because,
1163-
* as a prominent example, CMD sets 'Path', but not 'PATH'.
1164-
* Warning: not thread-safe.
1165-
*/
1166-
static char *getenv_cs(const char *name)
1167-
{
1168-
size_t len = strlen(name);
1169-
int i = lookup_env(environ, name, len);
1170-
if (i >= 0)
1171-
return environ[i] + len + 1; /* skip past name and '=' */
1172-
return getenv(name);
1173-
}
1174-
11751158
char *mingw_getenv(const char *name)
11761159
{
1177-
char *result = getenv_cs(name);
1160+
char *result = getenv(name);
11781161
if (!result && !strcmp(name, "TMPDIR")) {
11791162
/* on Windows it is TMP and TEMP */
1180-
result = getenv_cs("TMP");
1163+
result = getenv("TMP");
11811164
if (!result)
1182-
result = getenv_cs("TEMP");
1165+
result = getenv("TEMP");
11831166
}
11841167
return result;
11851168
}

0 commit comments

Comments
 (0)