From 54ee3c29d72563d740a8282403bb952e7eef116e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 6 May 2015 12:09:03 +0000 Subject: [PATCH] git-wrapper: support the non-mintty fall-back for Git Bash When we fall back to starting the Git Bash in the regular Windows console, we need to show said console's window... So let's introduce yet another configuration knob for use via string resources. Signed-off-by: Johannes Schindelin --- compat/win32/git-wrapper.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/compat/win32/git-wrapper.c b/compat/win32/git-wrapper.c index d57095a605..093d20838e 100644 --- a/compat/win32/git-wrapper.c +++ b/compat/win32/git-wrapper.c @@ -187,9 +187,9 @@ static int strip_prefix(LPWSTR str, int *len, LPCWSTR prefix) static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep, LPWSTR *prefix_args, int *prefix_args_len, int *is_git_command, LPWSTR *working_directory, int *full_path, - int *skip_arguments, int *allocate_console) + int *skip_arguments, int *allocate_console, int *show_console) { - int id, minimal_search_path, needs_a_console, wargc; + int id, minimal_search_path, needs_a_console, no_hide, wargc; LPWSTR *wargv; #define BUFSIZE 65536 @@ -199,6 +199,7 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep, for (id = 0; ; id++) { minimal_search_path = 0; needs_a_console = 0; + no_hide = 0; len = LoadString(NULL, id, buf, BUFSIZE); if (!len) { @@ -221,6 +222,8 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep, minimal_search_path = 1; else if (strip_prefix(buf, &len, L"ALLOC_CONSOLE=1 ")) needs_a_console = 1; + else if (strip_prefix(buf, &len, L"SHOW_CONSOLE=1 ")) + no_hide = 1; else break; } @@ -303,6 +306,8 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep, *full_path = 0; if (needs_a_console) *allocate_console = 1; + if (no_hide) + *show_console = 1; LocalFree(wargv); return 1; @@ -312,7 +317,7 @@ int main(void) { int r = 1, wait = 1, prefix_args_len = -1, needs_env_setup = 1, is_git_command = 1, full_path = 1, skip_arguments = 0, - allocate_console = 0; + allocate_console = 0, show_console = 0; WCHAR exepath[MAX_PATH], exe[MAX_PATH]; LPWSTR cmd = NULL, exep = exe, prefix_args = NULL, basename; LPWSTR working_directory = NULL; @@ -332,7 +337,8 @@ int main(void) if (configure_via_resource(basename, exepath, exep, &prefix_args, &prefix_args_len, &is_git_command, &working_directory, - &full_path, &skip_arguments, &allocate_console)) { + &full_path, &skip_arguments, &allocate_console, + &show_console)) { /* do nothing */ } else if (!wcsicmp(basename, L"git-gui.exe")) { @@ -445,7 +451,7 @@ int main(void) ZeroMemory(&si, sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); - if (allocate_console) + if (allocate_console | show_console) creation_flags |= CREATE_NEW_CONSOLE; else if ((console_handle = CreateFile(L"CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, @@ -462,6 +468,10 @@ int main(void) creation_flags |= CREATE_NO_WINDOW; } + if (show_console) { + si.dwFlags |= STARTF_USESHOWWINDOW; + si.wShowWindow = SW_SHOW; + } br = CreateProcess(/* module: null means use command line */ exep, cmd, /* modified command line */