Skip to content

Commit 4f5f856

Browse files
committed
fixup! Let the Git wrapper serve as a drop-in replacement for builtins
Prepare to prefix the command-line with non-builtins. We are now using the Git wrapper to call non-Git programs, too. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 3ee6eff commit 4f5f856

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

compat/win32/git-wrapper.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static void setup_environment(LPWSTR exepath)
9797
* untouched.
9898
*/
9999
static LPWSTR fixup_commandline(LPWSTR exepath, LPWSTR *exep, int *wait,
100-
LPWSTR builtin, int builtin_len)
100+
LPWSTR prefix_args, int prefix_args_len)
101101
{
102102
int wargc = 0, gui = 0;
103103
LPWSTR cmd = NULL, cmdline = NULL;
@@ -106,7 +106,7 @@ static LPWSTR fixup_commandline(LPWSTR exepath, LPWSTR *exep, int *wait,
106106
cmdline = GetCommandLine();
107107
wargv = CommandLineToArgvW(cmdline, &wargc);
108108
cmd = (LPWSTR)malloc(sizeof(WCHAR) *
109-
(wcslen(cmdline) + builtin_len + 1 + MAX_PATH));
109+
(wcslen(cmdline) + prefix_args_len + 1 + MAX_PATH));
110110
if (wargc > 1 && wcsicmp(L"gui", wargv[1]) == 0) {
111111
*wait = 0;
112112
if (wargc > 2 && wcsicmp(L"citool", wargv[2]) == 0) {
@@ -127,9 +127,9 @@ static LPWSTR fixup_commandline(LPWSTR exepath, LPWSTR *exep, int *wait,
127127
*exep = NULL;
128128
}
129129
}
130-
else if (builtin)
130+
else if (prefix_args)
131131
_swprintf(cmd, L"%s\\%s %.*s",
132-
exepath, L"git.exe", builtin_len, builtin);
132+
exepath, L"git.exe", prefix_args_len, prefix_args);
133133
else
134134
wcscpy(cmd, L"git.exe");
135135

@@ -151,9 +151,9 @@ static LPWSTR fixup_commandline(LPWSTR exepath, LPWSTR *exep, int *wait,
151151

152152
int main(void)
153153
{
154-
int r = 1, wait = 1, builtin_len = -1;
154+
int r = 1, wait = 1, prefix_args_len = -1;
155155
WCHAR exepath[MAX_PATH], exe[MAX_PATH];
156-
LPWSTR cmd = NULL, exep = exe, builtin = NULL, basename;
156+
LPWSTR cmd = NULL, exep = exe, prefix_args = NULL, basename;
157157
UINT codepage = 0;
158158

159159
/* get the installation location */
@@ -165,10 +165,10 @@ int main(void)
165165
basename = exepath + wcslen(exepath) + 1;
166166
if (!wcsncmp(basename, L"git-", 4)) {
167167
/* Call a builtin */
168-
builtin = basename + 4;
169-
builtin_len = wcslen(builtin);
170-
if (!wcscmp(builtin + builtin_len - 4, L".exe"))
171-
builtin_len -= 4;
168+
prefix_args = basename + 4;
169+
prefix_args_len = wcslen(prefix_args);
170+
if (!wcscmp(prefix_args + prefix_args_len - 4, L".exe"))
171+
prefix_args_len -= 4;
172172

173173
/* set the default exe module */
174174
wcscpy(exe, exepath);
@@ -186,9 +186,10 @@ int main(void)
186186
PathAppend(exe, L"bin\\git.exe");
187187
}
188188

189-
if (!builtin)
189+
if (!prefix_args)
190190
setup_environment(exepath);
191-
cmd = fixup_commandline(exepath, &exep, &wait, builtin, builtin_len);
191+
cmd = fixup_commandline(exepath, &exep, &wait,
192+
prefix_args, prefix_args_len);
192193

193194
/* set the console to ANSI/GUI codepage */
194195
codepage = GetConsoleCP();

0 commit comments

Comments
 (0)