From df5092509fba92f843d55f63edf1fd0d3b2058a4 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 2 Apr 2015 16:39:12 +0100 Subject: [PATCH] squash! git-wrapper: serve as git-gui.exe, too To avoid confusion with builtins, we need to move the code block handling gitk (and now git-gui, too) to intercept before git-gui is mistaken for a builtin. Unfortunately, git-gui is in libexec/git-core/ while gitk is in bin/, therefore we need slightly more adjustments than just moving and augmenting the gitk case. --- compat/win32/git-wrapper.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/compat/win32/git-wrapper.c b/compat/win32/git-wrapper.c index 50756f58b5..561483a212 100644 --- a/compat/win32/git-wrapper.c +++ b/compat/win32/git-wrapper.c @@ -307,6 +307,32 @@ int main(void) &full_path, &skip_arguments)) { /* do nothing */ } + else if (!wcscmp(basename, L"git-gui.exe")) { + static WCHAR buffer[BUFSIZE]; + if (!PathRemoveFileSpec(exepath)) { + fwprintf(stderr, + L"Invalid executable path: %s\n", exepath); + ExitProcess(1); + } + + /* set the default exe module */ + wcscpy(exe, exepath); + PathAppend(exe, msystem_bin); + PathAppend(exe, L"wish.exe"); + if (_waccess(exe, 0) != -1) + swprintf(buffer, BUFSIZE, + L"\"%s\\%.*s\\libexec\\git-core\"", + exepath, wcslen(msystem_bin) - 4, msystem_bin); + else { + wcscpy(exe, exepath); + PathAppend(exe, L"mingw\\bin\\wish.exe"); + swprintf(buffer, BUFSIZE, + L"\"%s\\mingw\\libexec\\git-core\"", exepath); + } + PathAppend(buffer, L"git-gui"); + prefix_args = buffer; + prefix_args_len = wcslen(buffer); + } else if (!wcsncmp(basename, L"git-", 4)) { needs_env_setup = 0; @@ -336,8 +362,7 @@ int main(void) PathAppend(exe, L"bin\\git.exe"); } } - else if (!wcscmp(basename, L"gitk.exe") || - !wcscmp(basename, L"git-gui.exe")) { + else if (!wcscmp(basename, L"gitk.exe")) { static WCHAR buffer[BUFSIZE]; if (!PathRemoveFileSpec(exepath)) { fwprintf(stderr, @@ -357,8 +382,7 @@ int main(void) PathAppend(exe, L"mingw\\bin\\wish.exe"); PathAppend(buffer, L"mingw\\bin"); } - basename[wcslen(basename) - 4] = '\0'; - PathAppend(buffer, basename); + PathAppend(buffer, L"gitk"); prefix_args = buffer; prefix_args_len = wcslen(buffer); }