@@ -964,7 +964,16 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
964
964
size_t mingw_strftime (char * s , size_t max ,
965
965
const char * format , const struct tm * tm )
966
966
{
967
- size_t ret = strftime (s , max , format , tm );
967
+ /* a pointer to the original strftime in case we can't find the UCRT version */
968
+ static size_t (* fallback )(char * , size_t , const char * , const struct tm * ) = strftime ;
969
+ size_t ret ;
970
+ DECLARE_PROC_ADDR (ucrtbase .dll , size_t , strftime , char * , size_t ,
971
+ const char * , const struct tm * );
972
+
973
+ if (INIT_PROC_ADDR (strftime ))
974
+ ret = strftime (s , max , format , tm );
975
+ else
976
+ ret = fallback (s , max , format , tm );
968
977
969
978
if (!ret && errno == EINVAL )
970
979
die ("invalid strftime format: '%s'" , format );
@@ -1479,6 +1488,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1479
1488
const char * (* quote_arg )(const char * arg ) =
1480
1489
is_msys2_sh (cmd ? cmd : * argv ) ?
1481
1490
quote_arg_msys2 : quote_arg_msvc ;
1491
+ const char * strace_env ;
1482
1492
1483
1493
/* Make sure to override previous errors, if any */
1484
1494
errno = 0 ;
@@ -1562,6 +1572,31 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1562
1572
free (quoted );
1563
1573
}
1564
1574
1575
+ strace_env = getenv ("GIT_STRACE_COMMANDS" );
1576
+ if (strace_env ) {
1577
+ char * p = path_lookup ("strace.exe" , 1 );
1578
+ if (!p )
1579
+ return error ("strace not found!" );
1580
+ if (xutftowcs_path (wcmd , p ) < 0 ) {
1581
+ free (p );
1582
+ return -1 ;
1583
+ }
1584
+ free (p );
1585
+ if (!strcmp ("1" , strace_env ) ||
1586
+ !strcasecmp ("yes" , strace_env ) ||
1587
+ !strcasecmp ("true" , strace_env ))
1588
+ strbuf_insert (& args , 0 , "strace " , 7 );
1589
+ else {
1590
+ const char * quoted = quote_arg (strace_env );
1591
+ struct strbuf buf = STRBUF_INIT ;
1592
+ strbuf_addf (& buf , "strace -o %s " , quoted );
1593
+ if (quoted != strace_env )
1594
+ free ((char * )quoted );
1595
+ strbuf_insert (& args , 0 , buf .buf , buf .len );
1596
+ strbuf_release (& buf );
1597
+ }
1598
+ }
1599
+
1565
1600
ALLOC_ARRAY (wargs , st_add (st_mult (2 , args .len ), 1 ));
1566
1601
xutftowcs (wargs , args .buf , 2 * args .len + 1 );
1567
1602
strbuf_release (& args );
@@ -2581,12 +2616,14 @@ int is_valid_win32_path(const char *path, int allow_literal_nul)
2581
2616
continue ;
2582
2617
}
2583
2618
break ;
2584
- case 'c' : case 'C' : /* COM<N>, CON, CONIN$, CONOUT$ */
2619
+ case 'c' : case 'C' :
2620
+ /* COM1 ... COM9, CON, CONIN$, CONOUT$ */
2585
2621
if ((c = path [++ i ]) != 'o' && c != 'O' )
2586
2622
goto not_a_reserved_name ;
2587
2623
c = path [++ i ];
2588
- if (c == 'm' || c == 'M' ) { /* COM<N> */
2589
- if (!isdigit (path [++ i ]))
2624
+ if (c == 'm' || c == 'M' ) { /* COM1 ... COM9 */
2625
+ c = path [++ i ];
2626
+ if (c < '1' || c > '9' )
2590
2627
goto not_a_reserved_name ;
2591
2628
} else if (c == 'n' || c == 'N' ) { /* CON */
2592
2629
c = path [i + 1 ];
0 commit comments