@@ -187,9 +187,9 @@ static int strip_prefix(LPWSTR str, int *len, LPCWSTR prefix)
187187static int configure_via_resource (LPWSTR basename , LPWSTR exepath , LPWSTR exep ,
188188 LPWSTR * prefix_args , int * prefix_args_len ,
189189 int * is_git_command , LPWSTR * working_directory , int * full_path ,
190- int * skip_arguments , int * allocate_console )
190+ int * skip_arguments , int * allocate_console , int * show_console )
191191{
192- int id , minimal_search_path , needs_a_console , wargc ;
192+ int id , minimal_search_path , needs_a_console , no_hide , wargc ;
193193 LPWSTR * wargv ;
194194
195195#define BUFSIZE 65536
@@ -199,6 +199,7 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
199199 for (id = 0 ; ; id ++ ) {
200200 minimal_search_path = 0 ;
201201 needs_a_console = 0 ;
202+ no_hide = 0 ;
202203 len = LoadString (NULL , id , buf , BUFSIZE );
203204
204205 if (!len ) {
@@ -221,6 +222,8 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
221222 minimal_search_path = 1 ;
222223 else if (strip_prefix (buf , & len , L"ALLOC_CONSOLE=1 " ))
223224 needs_a_console = 1 ;
225+ else if (strip_prefix (buf , & len , L"SHOW_CONSOLE=1 " ))
226+ no_hide = 1 ;
224227 else
225228 break ;
226229 }
@@ -303,6 +306,8 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
303306 * full_path = 0 ;
304307 if (needs_a_console )
305308 * allocate_console = 1 ;
309+ if (no_hide )
310+ * show_console = 1 ;
306311 LocalFree (wargv );
307312
308313 return 1 ;
@@ -312,7 +317,7 @@ int main(void)
312317{
313318 int r = 1 , wait = 1 , prefix_args_len = -1 , needs_env_setup = 1 ,
314319 is_git_command = 1 , full_path = 1 , skip_arguments = 0 ,
315- allocate_console = 0 ;
320+ allocate_console = 0 , show_console = 0 ;
316321 WCHAR exepath [MAX_PATH ], exe [MAX_PATH ];
317322 LPWSTR cmd = NULL , exep = exe , prefix_args = NULL , basename ;
318323 LPWSTR working_directory = NULL ;
@@ -332,7 +337,8 @@ int main(void)
332337 if (configure_via_resource (basename , exepath , exep ,
333338 & prefix_args , & prefix_args_len ,
334339 & is_git_command , & working_directory ,
335- & full_path , & skip_arguments , & allocate_console )) {
340+ & full_path , & skip_arguments , & allocate_console ,
341+ & show_console )) {
336342 /* do nothing */
337343 }
338344 else if (!wcsicmp (basename , L"git-gui.exe" )) {
@@ -445,7 +451,7 @@ int main(void)
445451 ZeroMemory (& si , sizeof (STARTUPINFO ));
446452 si .cb = sizeof (STARTUPINFO );
447453
448- if (allocate_console )
454+ if (allocate_console | show_console )
449455 creation_flags |= CREATE_NEW_CONSOLE ;
450456 else if ((console_handle = CreateFile (L"CONOUT$" , GENERIC_WRITE ,
451457 FILE_SHARE_WRITE , NULL , OPEN_EXISTING ,
@@ -462,6 +468,10 @@ int main(void)
462468
463469 creation_flags |= CREATE_NO_WINDOW ;
464470 }
471+ if (show_console ) {
472+ si .dwFlags |= STARTF_USESHOWWINDOW ;
473+ si .wShowWindow = SW_SHOW ;
474+ }
465475 br = CreateProcess (/* module: null means use command line */
466476 exep ,
467477 cmd , /* modified command line */
0 commit comments