Change lock_ref_sha1_basic to return an error instead of dying when
we fail to lock a file during a transaction.
This function is only called from transaction_commit() and it knows how
to handle these failures.

Signed-off-by: Ronnie Sahlberg <sahlb...@google.com>
---
 refs.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/refs.c b/refs.c
index 41cb51d..35f6db1 100644
--- a/refs.c
+++ b/refs.c
@@ -2206,6 +2206,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char 
*refname,
 
        lock->lock_fd = hold_lock_file_for_update(lock->lk, ref_file, lflags);
        if (lock->lock_fd < 0) {
+               last_errno = errno;
                if (errno == ENOENT && --attempts_remaining > 0)
                        /*
                         * Maybe somebody just deleted one of the
@@ -2213,8 +2214,10 @@ static struct ref_lock *lock_ref_sha1_basic(const char 
*refname,
                         * again:
                         */
                        goto retry;
-               else
-                       unable_to_lock_index_die(ref_file, errno);
+               else {
+                       unable_to_lock_error(ref_file, errno);
+                       goto error_return;
+               }
        }
        if (bad_ref)
                return lock;
-- 
2.0.1.523.g0041e8a

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to