Skip to content

Commit ec87da9

Browse files
dschoGit for Windows Build Agent
authored andcommitted
mingw: use strftime() directly in UCRT builds (#6130)
Currently, Git for Windows is built off of the MINGW64 tool chain. But this will have to change because [the MSYS2 project deprecated this tool chain in favor of UCRT64](https://www.msys2.org/news/#2026-03-15-deprecating-the-mingw64-environment). Of course, that's only possible because they dropped support for Windows 8.1, which Git for Windows will probably have to do relatively soon. The best time to do that is probably [the Git 3.0 inflection point](#6018) when we already promised to drop support for older Windows versions. To prepare for such a huge change, I investigated what needs to be changed in Git for Windows' source code. And the good news is there's actually not very much. This here patch seems to be the only change that's necessary, and not even _strictly_ necessary: the `mingw_strftime()` wrapper would still do the right thing. It would just uselessly load the same function that's already loaded, dynamically, again. - The `strerror()` override [is guarded by an `#ifndef _UCRT`](https://github.com/git-for-windows/git/blob/v2.53.0.windows.2/compat/mingw-posix.h#L294-L296), - `PRIuMAX` resolves to standard `"llu"` [via `<inttypes.h>`](https://github.com/git-for-windows/git/blob/v2.53.0.windows.2/compat/mingw-posix.h#L449-L454) (note that `__MINGW64_VERSION_MAJOR` is defined both in MINGW64 and UCRT64, by virtue of using the `mingw-w64-headers`), - [`__USE_MINGW_ANSI_STDIO=0`](https://github.com/git-for-windows/git/blob/v2.53.0.windows.2/config.mak.uname#L751C19-L751C33) is irrelevant because [`_UCRT` short-circuits it](https://github.com/git-for-windows/git-sdk-64/blob/08933e673c79b5db48419917a2b02746b390afc4/mingw64/include/inttypes.h#L33), and - `SNPRINTF_RETURNS_BOGUS` hasn't been set for Git for Windows' builds since ec47a33, i.e. for a _really_ long time.
2 parents 67948d5 + 1253fdb commit ec87da9

File tree

6 files changed

+26
-4
lines changed

6 files changed

+26
-4
lines changed

Documentation/git-svn.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'git svn' <command> [<options>] [<arguments>]
12+
(UNSUPPORTED!)
1213

1314
DESCRIPTION
1415
-----------

compat/mingw.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,9 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
15091509
size_t mingw_strftime(char *s, size_t max,
15101510
const char *format, const struct tm *tm)
15111511
{
1512+
#ifdef _UCRT
1513+
size_t ret = strftime(s, max, format, tm);
1514+
#else
15121515
/* a pointer to the original strftime in case we can't find the UCRT version */
15131516
static size_t (*fallback)(char *, size_t, const char *, const struct tm *) = strftime;
15141517
size_t ret;
@@ -1519,6 +1522,7 @@ size_t mingw_strftime(char *s, size_t max,
15191522
ret = strftime(s, max, format, tm);
15201523
else
15211524
ret = fallback(s, max, format, tm);
1525+
#endif
15221526

15231527
if (!ret && errno == EINVAL)
15241528
die("invalid strftime format: '%s'", format);

git-svn.perl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,19 @@ sub term_init {
305305
: new Term::ReadLine 'git-svn';
306306
}
307307

308+
sub deprecated_warning {
309+
my @lines = @_;
310+
if (-t STDERR) {
311+
@lines = map { "\e[33m$_\e[0m" } @lines;
312+
}
313+
warn join("\n", @lines), "\n";
314+
}
315+
316+
deprecated_warning(
317+
"WARNING: \`git svn\` is no longer supported by the Git for Windows project.",
318+
"See https://github.com/git-for-windows/git/issues/5405 for details."
319+
);
320+
308321
my $cmd;
309322
for (my $i = 0; $i < @ARGV; $i++) {
310323
if (defined $cmd{$ARGV[$i]}) {

t/t9108-git-svn-glob.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ test_expect_success 'test disallow multi-globs' '
110110
svn_cmd commit -m "try to try"
111111
) &&
112112
test_must_fail git svn fetch three 2> stderr.three &&
113-
test_cmp expect.three stderr.three
113+
sed "/^WARNING.*no.* supported/{N;d}" <stderr.three >stderr.three.clean &&
114+
test_cmp expect.three stderr.three.clean
114115
'
115116

116117
test_done

t/t9109-git-svn-multi-glob.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ test_expect_success 'test disallow multiple globs' '
161161
svn_cmd commit -m "try to try"
162162
) &&
163163
test_must_fail git svn fetch three 2> stderr.three &&
164-
test_cmp expect.three stderr.three
164+
sed "/^WARNING.*no.* supported/{N;d}" <stderr.three >stderr.three.clean &&
165+
test_cmp expect.three stderr.three.clean
165166
'
166167

167168
test_done

t/t9168-git-svn-partially-globbed-names.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ test_expect_success 'test disallow prefixed multi-globs' '
155155
svn_cmd commit -m "try to try"
156156
) &&
157157
test_must_fail git svn fetch four 2>stderr.four &&
158-
test_cmp expect.four stderr.four &&
158+
sed "/^WARNING.*no.* supported/{N;d}" <stderr.four >stderr.four.clean &&
159+
test_cmp expect.four stderr.four.clean &&
159160
git config --unset svn-remote.four.branches &&
160161
git config --unset svn-remote.four.tags
161162
'
@@ -223,7 +224,8 @@ test_expect_success 'test disallow multiple asterisks in one word' '
223224
svn_cmd commit -m "try to try"
224225
) &&
225226
test_must_fail git svn fetch six 2>stderr.six &&
226-
test_cmp expect.six stderr.six
227+
sed "/^WARNING.*no.* supported/{N;d}" <stderr.six >stderr.six.clean &&
228+
test_cmp expect.six stderr.six.clean
227229
'
228230

229231
test_done

0 commit comments

Comments
 (0)