Skip to content
Browse files

squash! Help debugging with MSys2 by optionally executing bash with s…


Also support passing a path to a log file via GIT_STRACE_COMMANDS to
force Git to call strace.exe with the `-o <path>` argument, i.e. to log
into a file rather than print the log directly.

That comes in handy when the output would otherwise misinterpreted by a
calling process as part of Git's output.

Note: the values "1", "yes" or "true" are *not* specifying paths, but
tell Git to let strace.exe log directly to the console.

Signed-off-by: Johannes Schindelin <>
  • Loading branch information...
dscho committed Apr 25, 2017
1 parent 52a7159 commit 2dd360375454c14132ccb288d0a4a51f3354d7c9
Showing with 16 additions and 2 deletions.
  1. +16 −2 compat/mingw.c
@@ -1509,6 +1509,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
BOOL ret;
HANDLE cons;
const char *strace_env;


@@ -1568,7 +1569,8 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen

if (getenv("GIT_STRACE_COMMANDS")) {
strace_env = getenv("GIT_STRACE_COMMANDS");
if (strace_env) {
char **path = get_path_split();
char *p = path_lookup("strace.exe", path, 1);
if (!p) {
@@ -1580,8 +1582,20 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
return -1;
strbuf_insert(&args, 0, "strace ", 7);
if (!strcmp("1", strace_env) ||
!strcasecmp("yes", strace_env) ||
!strcasecmp("true", strace_env))
strbuf_insert(&args, 0, "strace ", 7);
else {
const char *quoted = quote_arg(strace_env);
struct strbuf buf = STRBUF_INIT;
strbuf_addf(&buf, "strace -o %s ", quoted);
if (quoted != strace_env)
free((char *)quoted);
strbuf_insert(&args, 0, buf.buf, buf.len);

ALLOC_ARRAY(wargs, st_add(st_mult(2, args.len), 1));

0 comments on commit 2dd3603

Please sign in to comment.
You can’t perform that action at this time.