t9001: style modernisation phase #5
[gitweb.git] / lockfile.c
index e0460275e1904e12728840102d0a51e98008eef9..4f16ee78ce3dbc263a762a8800dfe9ddfcfaecd5 100644 (file)
@@ -162,16 +162,6 @@ void unable_to_lock_message(const char *path, int err, struct strbuf *buf)
                            absolute_path(path), strerror(err));
 }
 
-int unable_to_lock_error(const char *path, int err)
-{
-       struct strbuf buf = STRBUF_INIT;
-
-       unable_to_lock_message(path, err, &buf);
-       error("%s", buf.buf);
-       strbuf_release(&buf);
-       return -1;
-}
-
 NORETURN void unable_to_lock_die(const char *path, int err)
 {
        struct strbuf buf = STRBUF_INIT;
@@ -217,9 +207,12 @@ int hold_lock_file_for_append(struct lock_file *lk, const char *path, int flags)
 
                if (flags & LOCK_DIE_ON_ERROR)
                        exit(128);
+               close(orig_fd);
                rollback_lock_file(lk);
                errno = save_errno;
                return -1;
+       } else {
+               close(orig_fd);
        }
        return fd;
 }