summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Jeff Hostetler <jeffhost@microsoft.com>2022-03-25 18:03:06 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2022-03-25 16:04:17 -0700
commit369f0f54ff92fe321e8c7c2d2372e0eb31f77303 (patch)
tree9f8af1d11326b59dd5b849f58b663e6b5f14baae
parentt/perf: avoid copying builtin fsmonitor files into test repo (diff)
downloadtgif-369f0f54ff92fe321e8c7c2d2372e0eb31f77303.tar.xz
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 <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--t/helper/test-chmtime.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/t/helper/test-chmtime.c b/t/helper/test-chmtime.c
index 524b55ca49..dc28890a18 100644
--- a/t/helper/test-chmtime.c
+++ b/t/helper/test-chmtime.c
@@ -134,6 +134,21 @@ int cmd__chmtime(int argc, const char **argv)
}
if (utb.modtime != sb.st_mtime && utime(argv[i], &utb) < 0) {
+#ifdef GIT_WINDOWS_NATIVE
+ if (S_ISDIR(sb.st_mode)) {
+ /*
+ * NEEDSWORK: The Windows version of `utime()`
+ * (aka `mingw_utime()`) does not correctly
+ * handle directory arguments, since it uses
+ * `_wopen()`. Ignore it for now since this
+ * is just a test.
+ */
+ fprintf(stderr,
+ ("Failed to modify time on directory %s. "
+ "Skipping\n"), argv[i]);
+ continue;
+ }
+#endif
fprintf(stderr, "Failed to modify time on %s: %s\n",
argv[i], strerror(errno));
return 1;