Skip to content

Commit

Permalink
test-chmtime: work around Windows limitation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Jun 1, 2009
1 parent 492f709 commit d9b2633
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test-chmtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit d9b2633

Please sign in to comment.