5
5
#include "../strbuf.h"
6
6
#include "../run-command.h"
7
7
#include "../cache.h"
8
+ #include "../config.h"
8
9
9
10
#define HCAST (type , handle ) ((type)(intptr_t)handle)
10
11
@@ -202,6 +203,35 @@ static int ask_yes_no_if_possible(const char *format, ...)
202
203
}
203
204
}
204
205
206
+ /* Windows only */
207
+ enum hide_dotfiles_type {
208
+ HIDE_DOTFILES_FALSE = 0 ,
209
+ HIDE_DOTFILES_TRUE ,
210
+ HIDE_DOTFILES_DOTGITONLY
211
+ };
212
+
213
+ static enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY ;
214
+ static char * unset_environment_variables ;
215
+
216
+ int mingw_core_config (const char * var , const char * value , void * cb )
217
+ {
218
+ if (!strcmp (var , "core.hidedotfiles" )) {
219
+ if (value && !strcasecmp (value , "dotgitonly" ))
220
+ hide_dotfiles = HIDE_DOTFILES_DOTGITONLY ;
221
+ else
222
+ hide_dotfiles = git_config_bool (var , value );
223
+ return 0 ;
224
+ }
225
+
226
+ if (!strcmp (var , "core.unsetenvvars" )) {
227
+ free (unset_environment_variables );
228
+ unset_environment_variables = xstrdup (value );
229
+ return 0 ;
230
+ }
231
+
232
+ return 0 ;
233
+ }
234
+
205
235
int mingw_unlink (const char * pathname )
206
236
{
207
237
int ret , tries = 0 ;
@@ -1080,6 +1110,27 @@ static wchar_t *make_environment_block(char **deltaenv)
1080
1110
return wenvblk ;
1081
1111
}
1082
1112
1113
+ static void do_unset_environment_variables (void )
1114
+ {
1115
+ static int done ;
1116
+ char * p = unset_environment_variables ;
1117
+
1118
+ if (done || !p )
1119
+ return ;
1120
+ done = 1 ;
1121
+
1122
+ for (;;) {
1123
+ char * comma = strchr (p , ',' );
1124
+
1125
+ if (comma )
1126
+ * comma = '\0' ;
1127
+ unsetenv (p );
1128
+ if (!comma )
1129
+ break ;
1130
+ p = comma + 1 ;
1131
+ }
1132
+ }
1133
+
1083
1134
struct pinfo_t {
1084
1135
struct pinfo_t * next ;
1085
1136
pid_t pid ;
@@ -1098,9 +1149,12 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1098
1149
wchar_t wcmd [MAX_PATH ], wdir [MAX_PATH ], * wargs , * wenvblk = NULL ;
1099
1150
unsigned flags = CREATE_UNICODE_ENVIRONMENT ;
1100
1151
BOOL ret ;
1152
+ HANDLE cons ;
1153
+
1154
+ do_unset_environment_variables ();
1101
1155
1102
1156
/* Determine whether or not we are associated to a console */
1103
- HANDLE cons = CreateFile ("CONOUT$" , GENERIC_WRITE ,
1157
+ cons = CreateFile ("CONOUT$" , GENERIC_WRITE ,
1104
1158
FILE_SHARE_WRITE , NULL , OPEN_EXISTING ,
1105
1159
FILE_ATTRIBUTE_NORMAL , NULL );
1106
1160
if (cons == INVALID_HANDLE_VALUE ) {
@@ -2291,6 +2345,8 @@ void mingw_startup(void)
2291
2345
/* fix Windows specific environment settings */
2292
2346
setup_windows_environment ();
2293
2347
2348
+ unset_environment_variables = xstrdup ("PERL5LIB" );
2349
+
2294
2350
/* initialize critical section for waitpid pinfo_t list */
2295
2351
InitializeCriticalSection (& pinfo_cs );
2296
2352
0 commit comments