Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 08f555c

Browse files
mhaggergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f1e9e9a commit 08f555c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

refs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2533,7 +2533,14 @@ static int rename_tmp_log(const char *newrefname)
25332533
int attempts_remaining = 4;
25342534

25352535
retry:
2536-
if (safe_create_leading_directories(git_path("logs/%s", newrefname))) {
2536+
switch (safe_create_leading_directories(git_path("logs/%s", newrefname))) {
2537+
case SCLD_OK:
2538+
break; /* success */
2539+
case SCLD_VANISHED:
2540+
if (--attempts_remaining > 0)
2541+
goto retry;
2542+
/* fall through */
2543+
default:
25372544
error("unable to create directory for %s", newrefname);
25382545
return -1;
25392546
}

0 commit comments

Comments
 (0)