mingw: use strftime() directly in UCRT builds

The `mingw_strftime()` wrapper exists to work around msvcrt.dll's incomplete `strftime()` implementation by dynamically loading the version from ucrtbase.dll at runtime via `LoadLibrary()` + `GetProcAddress()`. When the binary is already linked against UCRT (i.e. when building in the UCRT64 environment), the linked-in `strftime()` is the ucrtbase.dll version, making the dynamic loading needless churn: It's calling the very same code. Simply guard both the declaration and implementation so that the unnecessary work-around is skipped in UCRT builds. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Apr 3, 2026 at 09:56 UTC c664ee2001a1ea0ecbc6448b24303687e6caf1cb
1 file changed +4
compat/mingw.c
+4
@@ -1394,6 +1394,9 @@ revert_attrs:
1394 size_t mingw_strftime(char *s, size_t max,
1395 const char *format, const struct tm *tm)
1396 {
1397 +#ifdef _UCRT
1398 + size_t ret = strftime(s, max, format, tm);
1399 +#else
1400 /* a pointer to the original strftime in case we can't find the UCRT version */
1401 static size_t (*fallback)(char *, size_t, const char *, const struct tm *) = strftime;
1402 size_t ret;
@@ -1404,6 +1407,7 @@ size_t mingw_strftime(char *s, size_t max,
1407 ret = strftime(s, max, format, tm);
1408 else
1409 ret = fallback(s, max, format, tm);
1410 +#endif
1411
1412 if (!ret && errno == EINVAL)
1413 die("invalid strftime format: '%s'", format);