Skip to content

Commit 369f0f5

Browse files
jeffhostetlergitster
authored andcommitted
t/helper/test-chmtime: skip directories on Windows
Teach `test-tool.exe chmtime` to ignore errors when setting the mtime on a directory on Windows. NEEDSWORK: The Windows version of `utime()` (aka `mingw_utime()`) does not properly handle directories because it uses `_wopen()`. It should be converted to using `CreateFileW()` and backup semantics at a minimum. Since I'm already in the middle of a large patch series, I did not want to destabilize other callers of `utime()` right now. The problem has only been observed in the t/perf/p7519 test when the test repo contains an empty directory on disk. Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 08894d3 commit 369f0f5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

t/helper/test-chmtime.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@ int cmd__chmtime(int argc, const char **argv)
134134
}
135135

136136
if (utb.modtime != sb.st_mtime && utime(argv[i], &utb) < 0) {
137+
#ifdef GIT_WINDOWS_NATIVE
138+
if (S_ISDIR(sb.st_mode)) {
139+
/*
140+
* NEEDSWORK: The Windows version of `utime()`
141+
* (aka `mingw_utime()`) does not correctly
142+
* handle directory arguments, since it uses
143+
* `_wopen()`. Ignore it for now since this
144+
* is just a test.
145+
*/
146+
fprintf(stderr,
147+
("Failed to modify time on directory %s. "
148+
"Skipping\n"), argv[i]);
149+
continue;
150+
}
151+
#endif
137152
fprintf(stderr, "Failed to modify time on %s: %s\n",
138153
argv[i], strerror(errno));
139154
return 1;

0 commit comments

Comments
 (0)