summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2014-01-18 23:49:01 +0100
committerJunio C Hamano <gitster@pobox.com>2014-01-21 13:47:28 -0800
commit08f555cb82f92797ca0aa0d6ba32e6872f1331e5 (patch)
treed7415181a5ae26f9d8e17a57638bdf9cafcbfa44
parentf1e9e9a4dbe2cfb39dcb14ee4f34628ef46d7b15 (diff)
downloadgit-08f555cb82f92797ca0aa0d6ba32e6872f1331e5.tar.gz
rename_tmp_log(): on SCLD_VANISHED, retrymh/safe-create-leading-directories
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>
-rw-r--r--refs.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/refs.c b/refs.c
index fd644f0f41..703b5a2f45 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;
}