Skip to content

Commit

Permalink
t/helper/test-chmtime: skip directories on Windows
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jeffhostetler authored and dscho committed Aug 16, 2021
1 parent d0ed68b commit fd9522a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions t/helper/test-chmtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fd9522a

Please sign in to comment.