From: Johannes Schindelin Date: Sun, 31 May 2009 16:15:18 +0000 (+0200) Subject: test-chmtime: work around Windows limitation X-Git-Tag: v1.6.4-rc0~63^2~9 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d9b26333854ce72a05cd077638c41a332f79c779;p=git.git 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 Signed-off-by: Steffen Prohaska Signed-off-by: Junio C Hamano --- diff --git a/test-chmtime.c b/test-chmtime.c index d5358cbaa..fe476cb61 100644 --- a/test-chmtime.c +++ b/test-chmtime.c @@ -87,6 +87,15 @@ int main(int argc, const char *argv[]) return -1; } +#ifdef WIN32 + if (!(sb.st_mode & S_IWUSR) && + chmod(argv[i], sb.st_mode | S_IWUSR)) { + fprintf(stderr, "Could not make user-writable %s: %s", + argv[i], strerror(errno)); + return -1; + } +#endif + utb.actime = sb.st_atime; utb.modtime = set_eq ? set_time : sb.st_mtime + set_time;