From 4911eb7f0f8f8e6f4533f910d93c32bf893bfa2a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 20 Feb 2015 09:52:07 +0000 Subject: [PATCH] Help debugging with MSys2 by optionally executing bash with strace MSys2's strace facility is very useful for debugging... With this patch, the bash will be executed through strace if the environment variable GIT_STRACE_COMMANDS is set, which comes in real handy when investigating issues in the test suite. Signed-off-by: Johannes Schindelin --- compat/mingw.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/compat/mingw.c b/compat/mingw.c index b5bc7c91ab..2524166ea9 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1202,6 +1202,22 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen free(quoted); } + if (getenv("GIT_STRACE_COMMANDS")) { + char **path = get_path_split(); + char *p = path_lookup("strace.exe", path, 1); + if (!p) { + free_path_split(path); + return error("strace not found!"); + } + free_path_split(path); + if (xutftowcs_path(wcmd, p) < 0) { + free(p); + return -1; + } + strbuf_insert(&args, 0, "strace ", 7); + free(p); + } + ALLOC_ARRAY(wargs, st_add(st_mult(2, args.len), 1)); xutftowcs(wargs, args.buf, 2 * args.len + 1); strbuf_release(&args);