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>
This commit is contained in:
Johannes Schindelin 2009-05-31 18:15:18 +02:00 коммит произвёл Junio C Hamano
Родитель 492f70913e
Коммит d9b2633385
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -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;