@@ -178,7 +178,7 @@ static int ask_yes_no_if_possible(const char *format, ...)
178
178
vsnprintf (question , sizeof (question ), format , args );
179
179
va_end (args );
180
180
181
- if ((retry_hook [0 ] = getenv ("GIT_ASK_YESNO" ))) {
181
+ if ((retry_hook [0 ] = mingw_getenv ("GIT_ASK_YESNO" ))) {
182
182
retry_hook [1 ] = question ;
183
183
return !run_command_v_opt (retry_hook , 0 );
184
184
}
@@ -599,19 +599,6 @@ char *mingw_getcwd(char *pointer, int len)
599
599
return ret ;
600
600
}
601
601
602
- #undef getenv
603
- char * mingw_getenv (const char * name )
604
- {
605
- char * result = getenv (name );
606
- if (!result && !strcmp (name , "TMPDIR" )) {
607
- /* on Windows it is TMP and TEMP */
608
- result = getenv ("TMP" );
609
- if (!result )
610
- result = getenv ("TEMP" );
611
- }
612
- return result ;
613
- }
614
-
615
602
/*
616
603
* See http://msdn2.microsoft.com/en-us/library/17w5ykft(vs.71).aspx
617
604
* (Parsing C++ Command-Line Arguments)
@@ -711,7 +698,7 @@ static const char *parse_interpreter(const char *cmd)
711
698
*/
712
699
static char * * get_path_split (void )
713
700
{
714
- char * p , * * path , * envpath = getenv ("PATH" );
701
+ char * p , * * path , * envpath = mingw_getenv ("PATH" );
715
702
int i , n = 0 ;
716
703
717
704
if (!envpath || !* envpath )
@@ -1128,6 +1115,36 @@ char **make_augmented_environ(const char *const *vars)
1128
1115
return env ;
1129
1116
}
1130
1117
1118
+ #undef getenv
1119
+
1120
+ /*
1121
+ * The system's getenv looks up the name in a case-insensitive manner.
1122
+ * This version tries a case-sensitive lookup and falls back to
1123
+ * case-insensitive if nothing was found. This is necessary because,
1124
+ * as a prominent example, CMD sets 'Path', but not 'PATH'.
1125
+ * Warning: not thread-safe.
1126
+ */
1127
+ static char * getenv_cs (const char * name )
1128
+ {
1129
+ size_t len = strlen (name );
1130
+ int i = lookup_env (environ , name , len );
1131
+ if (i >= 0 )
1132
+ return environ [i ] + len + 1 ; /* skip past name and '=' */
1133
+ return getenv (name );
1134
+ }
1135
+
1136
+ char * mingw_getenv (const char * name )
1137
+ {
1138
+ char * result = getenv_cs (name );
1139
+ if (!result && !strcmp (name , "TMPDIR" )) {
1140
+ /* on Windows it is TMP and TEMP */
1141
+ result = getenv_cs ("TMP" );
1142
+ if (!result )
1143
+ result = getenv_cs ("TEMP" );
1144
+ }
1145
+ return result ;
1146
+ }
1147
+
1131
1148
/*
1132
1149
* Note, this isn't a complete replacement for getaddrinfo. It assumes
1133
1150
* that service contains a numerical port, or that it is null. It
0 commit comments