@@ -1431,6 +1431,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
14311431 HANDLE cons ;
14321432 const char * (* quote_arg )(const char * arg ) =
14331433 is_msys2_sh (* argv ) ? quote_arg_msys2 : quote_arg_msvc ;
1434+ const char * strace_env ;
14341435
14351436 do_unset_environment_variables ();
14361437
@@ -1489,6 +1490,31 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
14891490 free (quoted );
14901491 }
14911492
1493+ strace_env = getenv ("GIT_STRACE_COMMANDS" );
1494+ if (strace_env ) {
1495+ char * p = path_lookup ("strace.exe" , 1 );
1496+ if (!p )
1497+ return error ("strace not found!" );
1498+ if (xutftowcs_path (wcmd , p ) < 0 ) {
1499+ free (p );
1500+ return -1 ;
1501+ }
1502+ free (p );
1503+ if (!strcmp ("1" , strace_env ) ||
1504+ !strcasecmp ("yes" , strace_env ) ||
1505+ !strcasecmp ("true" , strace_env ))
1506+ strbuf_insert (& args , 0 , "strace " , 7 );
1507+ else {
1508+ const char * quoted = quote_arg (strace_env );
1509+ struct strbuf buf = STRBUF_INIT ;
1510+ strbuf_addf (& buf , "strace -o %s " , quoted );
1511+ if (quoted != strace_env )
1512+ free ((char * )quoted );
1513+ strbuf_insert (& args , 0 , buf .buf , buf .len );
1514+ strbuf_release (& buf );
1515+ }
1516+ }
1517+
14921518 ALLOC_ARRAY (wargs , st_add (st_mult (2 , args .len ), 1 ));
14931519 xutftowcs (wargs , args .buf , 2 * args .len + 1 );
14941520 strbuf_release (& args );
0 commit comments