Skip to content

Commit f1e9e9a

Browse files
mhaggergitster
authored andcommitted
rename_tmp_log(): limit the number of remote_empty_directories() attempts
This doesn't seem to be a likely error, but we've got the counter anyway, so we might as well use it for an added bit of safety. Please note that the first call to rename() is optimistic, and it is normal for it to fail if there is a directory in the way. So bump the total number of allowed attempts to 4, to be sure that we can still have at least 3 retries in the case of a race. Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ae4a283 commit f1e9e9a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

refs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
25302530

25312531
static int rename_tmp_log(const char *newrefname)
25322532
{
2533-
int attempts_remaining = 3;
2533+
int attempts_remaining = 4;
25342534

25352535
retry:
25362536
if (safe_create_leading_directories(git_path("logs/%s", newrefname))) {
@@ -2539,7 +2539,7 @@ static int rename_tmp_log(const char *newrefname)
25392539
}
25402540

25412541
if (rename(git_path(TMP_RENAMED_LOG), git_path("logs/%s", newrefname))) {
2542-
if (errno==EISDIR || errno==ENOTDIR) {
2542+
if ((errno==EISDIR || errno==ENOTDIR) && --attempts_remaining > 0) {
25432543
/*
25442544
* rename(a, b) when b is an existing
25452545
* directory ought to result in ISDIR, but

0 commit comments

Comments
 (0)