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