From: Michael Haggerty Date: Sat, 18 Jan 2014 22:49:01 GMT Subject: [PATCH v3 17/17] rename_tmp_log(): on SCLD_VANISHED, retry Message-ID: <1390085341-2553-18-git-send-email-mhagger@alum.mit.edu> In-Reply-To: <1390085341-2553-1-git-send-email-mhagger@alum.mit.edu> If safe_create_leading_directories() fails because a file along the path unexpectedly vanished, try again from the beginning. Try at most 4 times. Signed-off-by: Michael Haggerty --- refs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/refs.c b/refs.c index 134d5aa..0148bbd 100644 --- a/refs.c +++ b/refs.c @@ -2533,7 +2533,14 @@ static int rename_tmp_log(const char *newrefname) int attempts_remaining = 4; retry: - if (safe_create_leading_directories(git_path("logs/%s", newrefname))) { + switch (safe_create_leading_directories(git_path("logs/%s", newrefname))) { + case SCLD_OK: + break; /* success */ + case SCLD_VANISHED: + if (--attempts_remaining > 0) + goto retry; + /* fall through */ + default: error("unable to create directory for %s", newrefname); return -1; } -- 1.8.5.2