Skip to content

Commit 529a899

Browse files
committed
fixup! Add Git for Windows' wrapper executable
Fix whitespace. This trick was performed by git rebase --whitespace=fix HEAD^ Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 055a65c commit 529a899

File tree

1 file changed

+94
-94
lines changed

1 file changed

+94
-94
lines changed

compat/win32/git-wrapper.c

Lines changed: 94 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ PrintError(LPCWSTR wszPrefix, DWORD dwError)
2020
DWORD cch = 0;
2121

2222
cch = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
23-
| FORMAT_MESSAGE_FROM_SYSTEM
24-
| FORMAT_MESSAGE_IGNORE_INSERTS,
25-
NULL, dwError, LANG_NEUTRAL,
26-
(LPTSTR)&lpsz, 0, NULL);
23+
| FORMAT_MESSAGE_FROM_SYSTEM
24+
| FORMAT_MESSAGE_IGNORE_INSERTS,
25+
NULL, dwError, LANG_NEUTRAL,
26+
(LPTSTR)&lpsz, 0, NULL);
2727
if (cch < 1) {
28-
cch = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
29-
| FORMAT_MESSAGE_FROM_STRING
30-
| FORMAT_MESSAGE_ARGUMENT_ARRAY,
31-
L"Code 0x%1!08x!",
32-
0, LANG_NEUTRAL, (LPTSTR)&lpsz, 0,
33-
(va_list*)&dwError);
28+
cch = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
29+
| FORMAT_MESSAGE_FROM_STRING
30+
| FORMAT_MESSAGE_ARGUMENT_ARRAY,
31+
L"Code 0x%1!08x!",
32+
0, LANG_NEUTRAL, (LPTSTR)&lpsz, 0,
33+
(va_list*)&dwError);
3434
}
3535
fwprintf(stderr, L"%s: %s", wszPrefix, lpsz);
3636
LocalFree((HLOCAL)lpsz);
@@ -56,38 +56,38 @@ main(void)
5656

5757
/* if not set, set TERM to msys */
5858
if (GetEnvironmentVariable(L"TERM", NULL, 0) == 0) {
59-
SetEnvironmentVariable(L"TERM", L"msys");
59+
SetEnvironmentVariable(L"TERM", L"msys");
6060
}
6161

6262
/* if not set, set PLINK_PROTOCOL to ssh */
6363
if (GetEnvironmentVariable(L"PLINK_PROTOCOL", NULL, 0) == 0) {
64-
SetEnvironmentVariable(L"PLINK_PROTOCOL", L"ssh");
64+
SetEnvironmentVariable(L"PLINK_PROTOCOL", L"ssh");
6565
}
6666

6767
/* set HOME to %HOMEDRIVE%%HOMEPATH% or %USERPROFILE%
6868
* With roaming profiles: HOMEPATH is the roaming location and
6969
* USERPROFILE is the local location
7070
*/
7171
if (GetEnvironmentVariable(L"HOME", NULL, 0) == 0) {
72-
LPWSTR e = NULL;
73-
len = GetEnvironmentVariable(L"HOMEPATH", NULL, 0);
74-
if (len == 0) {
75-
len = GetEnvironmentVariable(L"USERPROFILE", NULL, 0);
76-
if (len != 0) {
77-
e = (LPWSTR)malloc(len * sizeof(WCHAR));
78-
GetEnvironmentVariable(L"USERPROFILE", e, len);
79-
SetEnvironmentVariable(L"HOME", e);
80-
free(e);
81-
}
82-
} else {
83-
int n;
84-
len += GetEnvironmentVariable(L"HOMEDRIVE", NULL, 0);
85-
e = (LPWSTR)malloc(sizeof(WCHAR) * (len + 2));
86-
n = GetEnvironmentVariable(L"HOMEDRIVE", e, len);
87-
GetEnvironmentVariable(L"HOMEPATH", &e[n], len-n);
88-
SetEnvironmentVariable(L"HOME", e);
89-
free(e);
90-
}
72+
LPWSTR e = NULL;
73+
len = GetEnvironmentVariable(L"HOMEPATH", NULL, 0);
74+
if (len == 0) {
75+
len = GetEnvironmentVariable(L"USERPROFILE", NULL, 0);
76+
if (len != 0) {
77+
e = (LPWSTR)malloc(len * sizeof(WCHAR));
78+
GetEnvironmentVariable(L"USERPROFILE", e, len);
79+
SetEnvironmentVariable(L"HOME", e);
80+
free(e);
81+
}
82+
} else {
83+
int n;
84+
len += GetEnvironmentVariable(L"HOMEDRIVE", NULL, 0);
85+
e = (LPWSTR)malloc(sizeof(WCHAR) * (len + 2));
86+
n = GetEnvironmentVariable(L"HOMEDRIVE", e, len);
87+
GetEnvironmentVariable(L"HOMEPATH", &e[n], len-n);
88+
SetEnvironmentVariable(L"HOME", e);
89+
free(e);
90+
}
9191
}
9292

9393
/* extend the PATH */
@@ -100,7 +100,7 @@ main(void)
100100
wcscat(path2, exepath);
101101
PathAppend(path2, L"mingw\\bin;");
102102
GetEnvironmentVariable(L"PATH", &path2[wcslen(path2)],
103-
(len/sizeof(WCHAR))-wcslen(path2));
103+
(len/sizeof(WCHAR))-wcslen(path2));
104104
SetEnvironmentVariable(L"PATH", path2);
105105
free(path2);
106106

@@ -111,75 +111,75 @@ main(void)
111111
* untouched.
112112
*/
113113
{
114-
int wargc = 0, gui = 0;
115-
LPWSTR cmdline = NULL;
116-
LPWSTR *wargv = NULL, p = NULL;
117-
cmdline = GetCommandLine();
118-
wargv = CommandLineToArgvW(cmdline, &wargc);
119-
cmd = (LPWSTR)malloc(sizeof(WCHAR) * (wcslen(cmdline) + MAX_PATH));
120-
if (wargc > 1 && wcsicmp(L"gui", wargv[1]) == 0) {
121-
wait = 0;
122-
if (wargc > 2 && wcsicmp(L"citool", wargv[2]) == 0) {
123-
wait = 1;
124-
wcscpy(cmd, L"git.exe");
125-
} else {
126-
WCHAR script[MAX_PATH];
127-
gui = 1;
128-
wcscpy(script, exepath);
129-
PathAppend(script, L"libexec\\git-core\\git-gui");
130-
PathQuoteSpaces(script);
131-
wcscpy(cmd, L"wish.exe ");
132-
wcscat(cmd, script);
133-
wcscat(cmd, L" --");
134-
exep = NULL; /* find the module from the commandline */
135-
}
136-
} else {
137-
wcscpy(cmd, L"git.exe");
138-
}
139-
/* find the first space after the initial parameter then append all */
140-
p = wcschr(&cmdline[wcslen(wargv[0])], L' ');
141-
if (p && *p) {
142-
/* for git gui subcommands, remove the 'gui' word */
143-
if (gui) {
144-
while (*p == L' ') ++p;
145-
p = wcschr(p, L' ');
146-
}
147-
if (p && *p)
148-
wcscat(cmd, p);
149-
}
150-
LocalFree(wargv);
114+
int wargc = 0, gui = 0;
115+
LPWSTR cmdline = NULL;
116+
LPWSTR *wargv = NULL, p = NULL;
117+
cmdline = GetCommandLine();
118+
wargv = CommandLineToArgvW(cmdline, &wargc);
119+
cmd = (LPWSTR)malloc(sizeof(WCHAR) * (wcslen(cmdline) + MAX_PATH));
120+
if (wargc > 1 && wcsicmp(L"gui", wargv[1]) == 0) {
121+
wait = 0;
122+
if (wargc > 2 && wcsicmp(L"citool", wargv[2]) == 0) {
123+
wait = 1;
124+
wcscpy(cmd, L"git.exe");
125+
} else {
126+
WCHAR script[MAX_PATH];
127+
gui = 1;
128+
wcscpy(script, exepath);
129+
PathAppend(script, L"libexec\\git-core\\git-gui");
130+
PathQuoteSpaces(script);
131+
wcscpy(cmd, L"wish.exe ");
132+
wcscat(cmd, script);
133+
wcscat(cmd, L" --");
134+
exep = NULL; /* find the module from the commandline */
135+
}
136+
} else {
137+
wcscpy(cmd, L"git.exe");
138+
}
139+
/* find the first space after the initial parameter then append all */
140+
p = wcschr(&cmdline[wcslen(wargv[0])], L' ');
141+
if (p && *p) {
142+
/* for git gui subcommands, remove the 'gui' word */
143+
if (gui) {
144+
while (*p == L' ') ++p;
145+
p = wcschr(p, L' ');
146+
}
147+
if (p && *p)
148+
wcscat(cmd, p);
149+
}
150+
LocalFree(wargv);
151151
}
152152

153153
/* set the console to ANSI/GUI codepage */
154154
codepage = GetConsoleCP();
155155
SetConsoleCP(GetACP());
156156

157157
{
158-
STARTUPINFO si;
159-
PROCESS_INFORMATION pi;
160-
BOOL br = FALSE;
161-
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
162-
ZeroMemory(&si, sizeof(STARTUPINFO));
163-
si.cb = sizeof(STARTUPINFO);
164-
br = CreateProcess(exep,/* module: null means use command line */
165-
cmd, /* modified command line */
166-
NULL, /* process handle inheritance */
167-
NULL, /* thread handle inheritance */
168-
TRUE, /* handles inheritable? */
169-
CREATE_UNICODE_ENVIRONMENT,
170-
NULL, /* environment: use parent */
171-
NULL, /* starting directory: use parent */
172-
&si, &pi);
173-
if (br) {
174-
if (wait)
175-
WaitForSingleObject(pi.hProcess, INFINITE);
176-
if (!GetExitCodeProcess(pi.hProcess, (DWORD *)&r))
177-
PrintError(L"error reading exit code", GetLastError());
178-
CloseHandle(pi.hProcess);
179-
} else {
180-
PrintError(L"error launching git", GetLastError());
181-
r = 1;
182-
}
158+
STARTUPINFO si;
159+
PROCESS_INFORMATION pi;
160+
BOOL br = FALSE;
161+
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
162+
ZeroMemory(&si, sizeof(STARTUPINFO));
163+
si.cb = sizeof(STARTUPINFO);
164+
br = CreateProcess(exep,/* module: null means use command line */
165+
cmd, /* modified command line */
166+
NULL, /* process handle inheritance */
167+
NULL, /* thread handle inheritance */
168+
TRUE, /* handles inheritable? */
169+
CREATE_UNICODE_ENVIRONMENT,
170+
NULL, /* environment: use parent */
171+
NULL, /* starting directory: use parent */
172+
&si, &pi);
173+
if (br) {
174+
if (wait)
175+
WaitForSingleObject(pi.hProcess, INFINITE);
176+
if (!GetExitCodeProcess(pi.hProcess, (DWORD *)&r))
177+
PrintError(L"error reading exit code", GetLastError());
178+
CloseHandle(pi.hProcess);
179+
} else {
180+
PrintError(L"error launching git", GetLastError());
181+
r = 1;
182+
}
183183
}
184184

185185
free(cmd);

0 commit comments

Comments
 (0)