From e493ca541b3ff2015347b1217bf048608bfb0cd6 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 25 Sep 2017 19:13:45 +0200 Subject: [PATCH] mingw: avoid inifinite loop in rename() We have this loop where we try to remove the read-only attribute when rename() fails and try again. If it fails again, let's not try to remove the read-only attribute and try *again*. This fixes https://github.com/git-for-windows/git/issues/1299 Signed-off-by: Johannes Schindelin --- compat/mingw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compat/mingw.c b/compat/mingw.c index 20339907aa..96e95da05d 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -2423,7 +2423,8 @@ repeat: return -1; } - if ((attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) { + if (attrs == INVALID_FILE_ATTRIBUTES && + (attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) { if (attrs & FILE_ATTRIBUTE_DIRECTORY) { DWORD attrsold = GetFileAttributesW(wpold); if (attrsold == INVALID_FILE_ATTRIBUTES ||