mirror of
https://github.com/git/git.git
synced 2026-03-13 18:33:25 +01:00
Windows cannot unlink() a file that is read-only.
This commit is contained in:
@@ -25,8 +25,14 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len, int opts)
|
||||
memcpy(pathname + len, de->d_name, 38);
|
||||
if (opts & DRY_RUN)
|
||||
printf("rm -f %s\n", pathname);
|
||||
else if (unlink(pathname) < 0)
|
||||
error("unable to unlink %s", pathname);
|
||||
else {
|
||||
#ifdef __MINGW32__
|
||||
/* read-only files cannot be removed */
|
||||
chmod(pathname, 0666);
|
||||
#endif
|
||||
if (unlink(pathname) < 0)
|
||||
error("unable to unlink %s", pathname);
|
||||
}
|
||||
}
|
||||
pathname[len] = 0;
|
||||
rmdir(pathname);
|
||||
|
||||
@@ -700,6 +700,10 @@ static const char *write_index_file(const char *index_name, unsigned char *sha1)
|
||||
fd = mkstemp(tmpfile);
|
||||
index_name = xstrdup(tmpfile);
|
||||
} else {
|
||||
#ifdef __MINGW32__
|
||||
/* read-only files cannot be removed */
|
||||
chmod(index_name, 0666);
|
||||
#endif
|
||||
unlink(index_name);
|
||||
fd = open(index_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user