rename() fails on Windows if the destination exists.

This commit is contained in:
Johannes Sixt
2007-01-08 17:45:25 +01:00
parent 2bd27c7c97
commit 4ba0bd54b3

View File

@@ -274,6 +274,12 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
if (fclose(cb.newlog))
status |= error("%s: %s", strerror(errno),
newlog_path);
#ifdef __MINGW32__
/* rename fails if the destination exists */
if (unlink(lock->log_file))
status |= error("cannot remove %s", lock->log_file);
else
#endif
if (rename(newlog_path, lock->log_file)) {
status |= error("cannot rename %s to %s",
newlog_path, lock->log_file);