@@ -1431,6 +1431,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1431
1431
HANDLE cons ;
1432
1432
const char * (* quote_arg )(const char * arg ) =
1433
1433
is_msys2_sh (* argv ) ? quote_arg_msys2 : quote_arg_msvc ;
1434
+ const char * strace_env ;
1434
1435
1435
1436
do_unset_environment_variables ();
1436
1437
@@ -1489,6 +1490,31 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1489
1490
free (quoted );
1490
1491
}
1491
1492
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
+
1492
1518
ALLOC_ARRAY (wargs , st_add (st_mult (2 , args .len ), 1 ));
1493
1519
xutftowcs (wargs , args .buf , 2 * args .len + 1 );
1494
1520
strbuf_release (& args );
0 commit comments