forked from karupanerura/c-git-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-git.cpp
40 lines (32 loc) · 780 Bytes
/
git-git.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <string>
#include <iostream>
#include <process.h>
std::wstring create_git_arguments(
int argc,
wchar_t *argv[],
int start_index = 1)
{
std::wstring result = L"";
for (int i = start_index; i < argc; ++i) {
result.append(L"\"");
result.append(argv[i]);
result.append(L"\" ");
}
return result;
}
void print_error(int errnum) {
const rsize_t ERR_MSG_MAX = 94;
if (errnum) {
wchar_t buff[ERR_MSG_MAX + 1];
_wcserror_s(buff, errnum);
std::wcerr.imbue(std::locale(""));
std::wcerr << buff << std::endl;
}
}
int wmain(int argc, wchar_t *argv[]) {
auto git_args = create_git_arguments(argc, argv);
auto git_cl = L"git " + git_args;
int code = _wsystem(git_cl.c_str());
print_error(errno);
return code;
}