diff options
Diffstat (limited to 'compat')
| -rw-r--r-- | compat/disk.h | 2 | ||||
| -rw-r--r-- | compat/fsmonitor/fsm-health-darwin.c | 12 | ||||
| -rw-r--r-- | compat/fsmonitor/fsm-health-win32.c | 5 | ||||
| -rw-r--r-- | compat/fsmonitor/fsm-ipc-darwin.c | 8 | ||||
| -rw-r--r-- | compat/fsmonitor/fsm-ipc-win32.c | 4 | ||||
| -rw-r--r-- | compat/fsmonitor/fsm-listen-darwin.c | 11 | ||||
| -rw-r--r-- | compat/fsmonitor/fsm-listen-win32.c | 30 | ||||
| -rw-r--r-- | compat/fsmonitor/fsm-path-utils-darwin.c | 5 | ||||
| -rw-r--r-- | compat/fsmonitor/fsm-path-utils-win32.c | 13 | ||||
| -rw-r--r-- | compat/fsmonitor/fsm-settings-darwin.c | 3 | ||||
| -rw-r--r-- | compat/fsmonitor/fsm-settings-win32.c | 6 | ||||
| -rw-r--r-- | compat/linux/procinfo.c | 2 | ||||
| -rw-r--r-- | compat/mingw.c | 18 | ||||
| -rw-r--r-- | compat/mingw.h | 7 | ||||
| -rw-r--r-- | compat/pread.c | 1 | ||||
| -rw-r--r-- | compat/precompose_utf8.c | 6 | ||||
| -rw-r--r-- | compat/sha1-chunked.c | 3 | ||||
| -rw-r--r-- | compat/simple-ipc/ipc-shared.c | 2 | ||||
| -rw-r--r-- | compat/simple-ipc/ipc-unix-socket.c | 4 | ||||
| -rw-r--r-- | compat/simple-ipc/ipc-win32.c | 6 | ||||
| -rw-r--r-- | compat/terminal.c | 13 | ||||
| -rw-r--r-- | compat/win32/headless.c | 115 | ||||
| -rw-r--r-- | compat/win32/trace2_win32_process_info.c | 8 |
23 files changed, 226 insertions, 58 deletions
diff --git a/compat/disk.h b/compat/disk.h index 50a32e3d8a..6c979c27d8 100644 --- a/compat/disk.h +++ b/compat/disk.h @@ -2,6 +2,8 @@ #define COMPAT_DISK_H #include "git-compat-util.h" +#include "abspath.h" +#include "gettext.h" static int get_disk_info(struct strbuf *out) { diff --git a/compat/fsmonitor/fsm-health-darwin.c b/compat/fsmonitor/fsm-health-darwin.c index b9f709e854..c2afcbe6c8 100644 --- a/compat/fsmonitor/fsm-health-darwin.c +++ b/compat/fsmonitor/fsm-health-darwin.c @@ -1,24 +1,24 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsm-health.h" #include "fsmonitor--daemon.h" -int fsm_health__ctor(struct fsmonitor_daemon_state *state) +int fsm_health__ctor(struct fsmonitor_daemon_state *state UNUSED) { return 0; } -void fsm_health__dtor(struct fsmonitor_daemon_state *state) +void fsm_health__dtor(struct fsmonitor_daemon_state *state UNUSED) { return; } -void fsm_health__loop(struct fsmonitor_daemon_state *state) +void fsm_health__loop(struct fsmonitor_daemon_state *state UNUSED) { return; } -void fsm_health__stop_async(struct fsmonitor_daemon_state *state) +void fsm_health__stop_async(struct fsmonitor_daemon_state *state UNUSED) { } diff --git a/compat/fsmonitor/fsm-health-win32.c b/compat/fsmonitor/fsm-health-win32.c index 2ea08c1d4e..2d4e245beb 100644 --- a/compat/fsmonitor/fsm-health-win32.c +++ b/compat/fsmonitor/fsm-health-win32.c @@ -1,8 +1,9 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsm-health.h" #include "fsmonitor--daemon.h" +#include "gettext.h" /* * Every minute wake up and test our health. diff --git a/compat/fsmonitor/fsm-ipc-darwin.c b/compat/fsmonitor/fsm-ipc-darwin.c index d67b0ee50d..6f3a95410c 100644 --- a/compat/fsmonitor/fsm-ipc-darwin.c +++ b/compat/fsmonitor/fsm-ipc-darwin.c @@ -1,7 +1,11 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" +#include "gettext.h" +#include "hex.h" +#include "path.h" +#include "repository.h" #include "strbuf.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsmonitor-ipc.h" #include "fsmonitor-path-utils.h" diff --git a/compat/fsmonitor/fsm-ipc-win32.c b/compat/fsmonitor/fsm-ipc-win32.c index e08c505c14..41984ea48e 100644 --- a/compat/fsmonitor/fsm-ipc-win32.c +++ b/compat/fsmonitor/fsm-ipc-win32.c @@ -1,9 +1,11 @@ +#include "git-compat-util.h" #include "config.h" #include "fsmonitor-ipc.h" +#include "path.h" const char *fsmonitor_ipc__get_path(struct repository *r) { static char *ret; if (!ret) - ret = git_pathdup("fsmonitor--daemon.ipc"); + ret = repo_git_path(r, "fsmonitor--daemon.ipc"); return ret; } diff --git a/compat/fsmonitor/fsm-listen-darwin.c b/compat/fsmonitor/fsm-listen-darwin.c index 97a55a6f0a..11b56d3ef1 100644 --- a/compat/fsmonitor/fsm-listen-darwin.c +++ b/compat/fsmonitor/fsm-listen-darwin.c @@ -23,11 +23,14 @@ #endif #endif -#include "cache.h" -#include "fsmonitor.h" +#include "git-compat-util.h" +#include "fsmonitor-ll.h" #include "fsm-listen.h" #include "fsmonitor--daemon.h" #include "fsmonitor-path-utils.h" +#include "gettext.h" +#include "string-list.h" +#include "trace.h" struct fsm_listen_data { @@ -188,12 +191,12 @@ static void my_add_path(struct fsmonitor_batch *batch, const char *path) } -static void fsevent_callback(ConstFSEventStreamRef streamRef, +static void fsevent_callback(ConstFSEventStreamRef streamRef UNUSED, void *ctx, size_t num_of_events, void *event_paths, const FSEventStreamEventFlags event_flags[], - const FSEventStreamEventId event_ids[]) + const FSEventStreamEventId event_ids[] UNUSED) { struct fsmonitor_daemon_state *state = ctx; struct fsm_listen_data *data = state->listen_data; diff --git a/compat/fsmonitor/fsm-listen-win32.c b/compat/fsmonitor/fsm-listen-win32.c index 03df8d951b..90a2412284 100644 --- a/compat/fsmonitor/fsm-listen-win32.c +++ b/compat/fsmonitor/fsm-listen-win32.c @@ -1,8 +1,10 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsm-listen.h" #include "fsmonitor--daemon.h" +#include "gettext.h" +#include "trace2.h" /* * The documentation of ReadDirectoryChangesW() states that the maximum @@ -287,8 +289,7 @@ void fsm_listen__stop_async(struct fsmonitor_daemon_state *state) SetEvent(state->listen_data->hListener[LISTENER_SHUTDOWN]); } -static struct one_watch *create_watch(struct fsmonitor_daemon_state *state, - const char *path) +static struct one_watch *create_watch(const char *path) { struct one_watch *watch = NULL; DWORD desired_access = FILE_LIST_DIRECTORY; @@ -359,8 +360,7 @@ static void destroy_watch(struct one_watch *watch) free(watch); } -static int start_rdcw_watch(struct fsm_listen_data *data, - struct one_watch *watch) +static int start_rdcw_watch(struct one_watch *watch) { DWORD dwNotifyFilter = FILE_NOTIFY_CHANGE_FILE_NAME | @@ -733,11 +733,11 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state) state->listen_error_code = 0; - if (start_rdcw_watch(data, data->watch_worktree) == -1) + if (start_rdcw_watch(data->watch_worktree) == -1) goto force_error_stop; if (data->watch_gitdir && - start_rdcw_watch(data, data->watch_gitdir) == -1) + start_rdcw_watch(data->watch_gitdir) == -1) goto force_error_stop; for (;;) { @@ -753,7 +753,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state) } if (result == -2) { /* retryable error */ - if (start_rdcw_watch(data, data->watch_worktree) == -1) + if (start_rdcw_watch(data->watch_worktree) == -1) goto force_error_stop; continue; } @@ -761,7 +761,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state) /* have data */ if (process_worktree_events(state) == LISTENER_SHUTDOWN) goto force_shutdown; - if (start_rdcw_watch(data, data->watch_worktree) == -1) + if (start_rdcw_watch(data->watch_worktree) == -1) goto force_error_stop; continue; } @@ -774,7 +774,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state) } if (result == -2) { /* retryable error */ - if (start_rdcw_watch(data, data->watch_gitdir) == -1) + if (start_rdcw_watch(data->watch_gitdir) == -1) goto force_error_stop; continue; } @@ -782,7 +782,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state) /* have data */ if (process_gitdir_events(state) == LISTENER_SHUTDOWN) goto force_shutdown; - if (start_rdcw_watch(data, data->watch_gitdir) == -1) + if (start_rdcw_watch(data->watch_gitdir) == -1) goto force_error_stop; continue; } @@ -819,16 +819,14 @@ int fsm_listen__ctor(struct fsmonitor_daemon_state *state) data->hEventShutdown = CreateEvent(NULL, TRUE, FALSE, NULL); - data->watch_worktree = create_watch(state, - state->path_worktree_watch.buf); + data->watch_worktree = create_watch(state->path_worktree_watch.buf); if (!data->watch_worktree) goto failed; check_for_shortnames(data->watch_worktree); if (state->nr_paths_watching > 1) { - data->watch_gitdir = create_watch(state, - state->path_gitdir_watch.buf); + data->watch_gitdir = create_watch(state->path_gitdir_watch.buf); if (!data->watch_gitdir) goto failed; } diff --git a/compat/fsmonitor/fsm-path-utils-darwin.c b/compat/fsmonitor/fsm-path-utils-darwin.c index ce5a8febe0..049f97eaaf 100644 --- a/compat/fsmonitor/fsm-path-utils-darwin.c +++ b/compat/fsmonitor/fsm-path-utils-darwin.c @@ -1,5 +1,8 @@ -#include "fsmonitor.h" +#include "git-compat-util.h" +#include "fsmonitor-ll.h" #include "fsmonitor-path-utils.h" +#include "gettext.h" +#include "trace.h" #include <dirent.h> #include <errno.h> #include <fcntl.h> diff --git a/compat/fsmonitor/fsm-path-utils-win32.c b/compat/fsmonitor/fsm-path-utils-win32.c index 0d95bbb416..f4f9cc1f33 100644 --- a/compat/fsmonitor/fsm-path-utils-win32.c +++ b/compat/fsmonitor/fsm-path-utils-win32.c @@ -1,6 +1,8 @@ -#include "cache.h" -#include "fsmonitor.h" +#include "git-compat-util.h" +#include "fsmonitor-ll.h" #include "fsmonitor-path-utils.h" +#include "gettext.h" +#include "trace.h" /* * Check remote working directory protocol. @@ -130,7 +132,8 @@ int fsmonitor__is_fs_remote(const char *path) /* * No-op for now. */ -int fsmonitor__get_alias(const char *path, struct alias_info *info) +int fsmonitor__get_alias(const char *path UNUSED, + struct alias_info *info UNUSED) { return 0; } @@ -138,8 +141,8 @@ int fsmonitor__get_alias(const char *path, struct alias_info *info) /* * No-op for now. */ -char *fsmonitor__resolve_alias(const char *path, - const struct alias_info *info) +char *fsmonitor__resolve_alias(const char *path UNUSED, + const struct alias_info *info UNUSED) { return NULL; } diff --git a/compat/fsmonitor/fsm-settings-darwin.c b/compat/fsmonitor/fsm-settings-darwin.c index 6abbc7af3a..a382590635 100644 --- a/compat/fsmonitor/fsm-settings-darwin.c +++ b/compat/fsmonitor/fsm-settings-darwin.c @@ -1,5 +1,6 @@ +#include "git-compat-util.h" #include "config.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsmonitor-ipc.h" #include "fsmonitor-settings.h" #include "fsmonitor-path-utils.h" diff --git a/compat/fsmonitor/fsm-settings-win32.c b/compat/fsmonitor/fsm-settings-win32.c index a8af31b71d..0f2aa321f6 100644 --- a/compat/fsmonitor/fsm-settings-win32.c +++ b/compat/fsmonitor/fsm-settings-win32.c @@ -1,7 +1,7 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "repository.h" -#include "fsmonitor.h" +#include "fsmonitor-ll.h" #include "fsmonitor-settings.h" #include "fsmonitor-path-utils.h" @@ -25,7 +25,7 @@ static enum fsmonitor_reason check_vfs4git(struct repository *r) return FSMONITOR_REASON_OK; } -enum fsmonitor_reason fsm_os__incompatible(struct repository *r, int ipc) +enum fsmonitor_reason fsm_os__incompatible(struct repository *r, int ipc UNUSED) { enum fsmonitor_reason reason; diff --git a/compat/linux/procinfo.c b/compat/linux/procinfo.c index bc2f9382a1..4bb2d66227 100644 --- a/compat/linux/procinfo.c +++ b/compat/linux/procinfo.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "strbuf.h" #include "strvec.h" diff --git a/compat/mingw.c b/compat/mingw.c index e433740381..42053c1f65 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -6,10 +6,16 @@ #include <wchar.h> #include "../strbuf.h" #include "../run-command.h" -#include "../cache.h" +#include "../abspath.h" +#include "../alloc.h" #include "win32/lazyload.h" #include "../config.h" +#include "../environment.h" +#include "../trace2.h" +#include "../symlinks.h" +#include "../wrapper.h" #include "dir.h" +#include "gettext.h" #define SECURITY_WIN32 #include <sspi.h> @@ -237,7 +243,8 @@ static int core_restrict_inherited_handles = -1; static enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY; static char *unset_environment_variables; -int mingw_core_config(const char *var, const char *value, void *cb) +int mingw_core_config(const char *var, const char *value, + const struct config_context *ctx, void *cb) { if (!strcmp(var, "core.hidedotfiles")) { if (value && !strcasecmp(value, "dotgitonly")) @@ -248,6 +255,8 @@ int mingw_core_config(const char *var, const char *value, void *cb) } if (!strcmp(var, "core.unsetenvvars")) { + if (!value) + return config_error_nonbool(var); free(unset_environment_variables); unset_environment_variables = xstrdup(value); return 0; @@ -1340,6 +1349,11 @@ static char *path_lookup(const char *cmd, int exe_only) return prog; } +char *mingw_locate_in_PATH(const char *cmd) +{ + return path_lookup(cmd, 0); +} + static const wchar_t *wcschrnul(const wchar_t *s, wchar_t c) { while (*s && *s != c) diff --git a/compat/mingw.h b/compat/mingw.h index 209cf7ceba..6aec50e412 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -11,7 +11,9 @@ typedef _sigset_t sigset_t; #undef _POSIX_THREAD_SAFE_FUNCTIONS #endif -int mingw_core_config(const char *var, const char *value, void *cb); +struct config_context; +int mingw_core_config(const char *var, const char *value, + const struct config_context *ctx, void *cb); #define platform_core_config mingw_core_config /* @@ -175,6 +177,9 @@ pid_t waitpid(pid_t pid, int *status, int options); #define kill mingw_kill int mingw_kill(pid_t pid, int sig); +#define locate_in_PATH mingw_locate_in_PATH +char *mingw_locate_in_PATH(const char *cmd); + #ifndef NO_OPENSSL #include <openssl/ssl.h> static inline int mingw_SSL_set_fd(SSL *ssl, int fd) diff --git a/compat/pread.c b/compat/pread.c index 978cac4ec9..484e6d4c71 100644 --- a/compat/pread.c +++ b/compat/pread.c @@ -1,4 +1,5 @@ #include "../git-compat-util.h" +#include "../wrapper.h" ssize_t git_pread(int fd, void *buf, size_t count, off_t offset) { diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c index cce1d57a46..0bd5c24250 100644 --- a/compat/precompose_utf8.c +++ b/compat/precompose_utf8.c @@ -5,8 +5,12 @@ #define PRECOMPOSE_UNICODE_C -#include "cache.h" +#include "git-compat-util.h" #include "config.h" +#include "environment.h" +#include "gettext.h" +#include "path.h" +#include "strbuf.h" #include "utf8.h" #include "precompose_utf8.h" diff --git a/compat/sha1-chunked.c b/compat/sha1-chunked.c index 6adfcfd540..a4a6f930d7 100644 --- a/compat/sha1-chunked.c +++ b/compat/sha1-chunked.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "hash-ll.h" int git_SHA1_Update_Chunked(platform_SHA_CTX *c, const void *data, size_t len) { diff --git a/compat/simple-ipc/ipc-shared.c b/compat/simple-ipc/ipc-shared.c index 1b9d359ab6..e5e1dda8cc 100644 --- a/compat/simple-ipc/ipc-shared.c +++ b/compat/simple-ipc/ipc-shared.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "simple-ipc.h" #include "strbuf.h" #include "pkt-line.h" diff --git a/compat/simple-ipc/ipc-unix-socket.c b/compat/simple-ipc/ipc-unix-socket.c index 28a79289d4..b2f4f22ce4 100644 --- a/compat/simple-ipc/ipc-unix-socket.c +++ b/compat/simple-ipc/ipc-unix-socket.c @@ -1,8 +1,10 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "gettext.h" #include "simple-ipc.h" #include "strbuf.h" #include "pkt-line.h" #include "thread-utils.h" +#include "trace2.h" #include "unix-socket.h" #include "unix-stream-server.h" diff --git a/compat/simple-ipc/ipc-win32.c b/compat/simple-ipc/ipc-win32.c index 20ea7b65e0..8bfe51248e 100644 --- a/compat/simple-ipc/ipc-win32.c +++ b/compat/simple-ipc/ipc-win32.c @@ -1,8 +1,12 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "abspath.h" +#include "gettext.h" #include "simple-ipc.h" #include "strbuf.h" #include "pkt-line.h" #include "thread-utils.h" +#include "trace.h" +#include "trace2.h" #include "accctrl.h" #include "aclapi.h" diff --git a/compat/terminal.c b/compat/terminal.c index ea490a7ced..0afda730f2 100644 --- a/compat/terminal.c +++ b/compat/terminal.c @@ -1,5 +1,6 @@ -#include "cache.h" +#include "git-compat-util.h" #include "compat/terminal.h" +#include "gettext.h" #include "sigchain.h" #include "strbuf.h" #include "run-command.h" @@ -478,10 +479,13 @@ struct escape_sequence_entry { }; static int sequence_entry_cmp(const void *hashmap_cmp_fn_data UNUSED, - const struct escape_sequence_entry *e1, - const struct escape_sequence_entry *e2, + const struct hashmap_entry *he1, + const struct hashmap_entry *he2, const void *keydata) { + const struct escape_sequence_entry + *e1 = container_of(he1, const struct escape_sequence_entry, entry), + *e2 = container_of(he2, const struct escape_sequence_entry, entry); return strcmp(e1->sequence, keydata ? keydata : e2->sequence); } @@ -495,8 +499,7 @@ static int is_known_escape_sequence(const char *sequence) struct strbuf buf = STRBUF_INIT; char *p, *eol; - hashmap_init(&sequences, (hashmap_cmp_fn)sequence_entry_cmp, - NULL, 0); + hashmap_init(&sequences, sequence_entry_cmp, NULL, 0); strvec_pushl(&cp.args, "infocmp", "-L", "-1", NULL); if (pipe_command(&cp, NULL, 0, &buf, 0, NULL, 0)) diff --git a/compat/win32/headless.c b/compat/win32/headless.c new file mode 100644 index 0000000000..8b00dfe3bd --- /dev/null +++ b/compat/win32/headless.c @@ -0,0 +1,115 @@ +/* + * headless Git - run Git without opening a console window on Windows + */ + +#define STRICT +#define WIN32_LEAN_AND_MEAN +#define UNICODE +#define _UNICODE +#include <windows.h> +#include <stdio.h> +#include <stdlib.h> +#include <wchar.h> + +/* + * If `dir` contains the path to a Git exec directory, extend `PATH` to + * include the corresponding `bin/` directory (which is where all those + * `.dll` files needed by `git.exe` are, on Windows). + */ +static int extend_path(wchar_t *dir, size_t dir_len) +{ + const wchar_t *suffix = L"\\libexec\\git-core"; + size_t suffix_len = wcslen(suffix); + wchar_t *env; + DWORD len; + + if (dir_len < suffix_len) + return 0; + + dir_len -= suffix_len; + if (memcmp(dir + dir_len, suffix, suffix_len * sizeof(wchar_t))) + return 0; + + len = GetEnvironmentVariableW(L"PATH", NULL, 0); + if (!len) + return 0; + + env = _alloca((dir_len + 5 + len) * sizeof(wchar_t)); + wcsncpy(env, dir, dir_len); + wcscpy(env + dir_len, L"\\bin;"); + if (!GetEnvironmentVariableW(L"PATH", env + dir_len + 5, len)) + return 0; + + SetEnvironmentVariableW(L"PATH", env); + return 1; +} + +int WINAPI wWinMain(_In_ HINSTANCE instance, + _In_opt_ HINSTANCE previous_instance, + _In_ LPWSTR command_line, _In_ int show) +{ + wchar_t git_command_line[32768]; + size_t size = sizeof(git_command_line) / sizeof(wchar_t); + const wchar_t *needs_quotes = L""; + int slash = 0, i; + + STARTUPINFO startup_info = { + .cb = sizeof(STARTUPINFO), + .dwFlags = STARTF_USESHOWWINDOW, + .wShowWindow = SW_HIDE, + }; + PROCESS_INFORMATION process_info = { 0 }; + DWORD creation_flags = CREATE_UNICODE_ENVIRONMENT | + CREATE_NEW_CONSOLE | CREATE_NO_WINDOW; + DWORD exit_code; + + /* First, determine the full path of argv[0] */ + for (i = 0; _wpgmptr[i]; i++) + if (_wpgmptr[i] == L' ') + needs_quotes = L"\""; + else if (_wpgmptr[i] == L'\\') + slash = i; + + if (slash >= size - 11) + return 127; /* Too long path */ + + /* If it is in Git's exec path, add the bin/ directory to the PATH */ + extend_path(_wpgmptr, slash); + + /* Then, add the full path of `git.exe` as argv[0] */ + i = swprintf_s(git_command_line, size, L"%ls%.*ls\\git.exe%ls", + needs_quotes, slash, _wpgmptr, needs_quotes); + if (i < 0) + return 127; /* Too long path */ + + if (*command_line) { + /* Now, append the command-line arguments */ + i = swprintf_s(git_command_line + i, size - i, + L" %ls", command_line); + if (i < 0) + return 127; + } + + startup_info.hStdInput = GetStdHandle(STD_INPUT_HANDLE); + startup_info.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); + startup_info.hStdError = GetStdHandle(STD_ERROR_HANDLE); + + if (!CreateProcess(NULL, /* infer argv[0] from the command line */ + git_command_line, /* modified command line */ + NULL, /* inherit process handles? */ + NULL, /* inherit thread handles? */ + FALSE, /* handles inheritable? */ + creation_flags, + NULL, /* use this process' environment */ + NULL, /* use this process' working directory */ + &startup_info, &process_info)) + return 129; /* could not start */ + WaitForSingleObject(process_info.hProcess, INFINITE); + if (!GetExitCodeProcess(process_info.hProcess, &exit_code)) + exit_code = 130; /* Could not determine exit code? */ + + CloseHandle(process_info.hProcess); + CloseHandle(process_info.hThread); + + return (int)exit_code; +} diff --git a/compat/win32/trace2_win32_process_info.c b/compat/win32/trace2_win32_process_info.c index a53fd92434..3ef0936f6f 100644 --- a/compat/win32/trace2_win32_process_info.c +++ b/compat/win32/trace2_win32_process_info.c @@ -1,8 +1,10 @@ -#include "../../cache.h" +#include "../../git-compat-util.h" #include "../../json-writer.h" +#include "../../repository.h" +#include "../../trace2.h" #include "lazyload.h" -#include <Psapi.h> -#include <tlHelp32.h> +#include <psapi.h> +#include <tlhelp32.h> /* * An arbitrarily chosen value to limit the size of the ancestor |
