diff --git a/builtin-reflog.c b/builtin-reflog.c index 6d14184736..4877bb060b 100644 --- a/builtin-reflog.c +++ b/builtin-reflog.c @@ -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);