Skip to content

Commit

Permalink
rename_tmp_log(): on SCLD_VANISHED, retry
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed Jan 21, 2014
1 parent f1e9e9a commit 08f555c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 08f555c

Please sign in to comment.