aboutsummaryrefslogtreecommitdiff
path: root/test-chmtime.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2009-05-31 18:15:18 +0200
committerJunio C Hamano <gitster@pobox.com>2009-06-01 00:10:08 -0700
commitd9b26333854ce72a05cd077638c41a332f79c779 (patch)
tree06d3e18d55d2e5801d43d7ebc8764773911494c1 /test-chmtime.c
parent492f70913e11de19bc4cb197b1fe195c645b89c9 (diff)
downloadgit-d9b26333854ce72a05cd077638c41a332f79c779.tar.gz
git-d9b26333854ce72a05cd077638c41a332f79c779.tar.xz
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>
Diffstat (limited to 'test-chmtime.c')
-rw-r--r--test-chmtime.c9
1 files changed, 9 insertions, 0 deletions
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;