1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-08 18:16:09 +02:00

rename_tmp_log(): on SCLD_VANISHED, retry

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 <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Michael Haggerty 2014-01-18 23:49:01 +01:00 committed by Junio C Hamano
parent f1e9e9a4db
commit 08f555cb82

9
refs.c
View File

@ -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;
}