@matheusbsbs / matheus-bagliano / commits / d9b2633385
Fork 0

test-chmtime: work around Windows limitation

Windows has problems changing the mtime when the file is write protected, even by the owner of said file. Add a Windows-only workaround to change the mode if necessary before trying to change the mtime. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Steffen Prohaska <prohaska@zib.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed May 31, 2009 at 18:15 UTC d9b26333854ce72a05cd077638c41a332f79c779
1 file changed +9
test-chmtime.c
+9
@@ -87,6 +87,15 @@ int main(int argc, const char *argv[])
87 return -1;
88 }
89
90 +#ifdef WIN32
91 + if (!(sb.st_mode & S_IWUSR) &&
92 + chmod(argv[i], sb.st_mode | S_IWUSR)) {
93 + fprintf(stderr, "Could not make user-writable %s: %s",
94 + argv[i], strerror(errno));
95 + return -1;
96 + }
97 +#endif
98 +
99 utb.actime = sb.st_atime;
100 utb.modtime = set_eq ? set_time : sb.st_mtime + set_time;
101