From: Junio C Hamano Date: Thu, 14 Sep 2017 08:40:35 +0000 (+0900) Subject: Merge branch 'jk/incore-lockfile-removal' into next X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/603dae7fb2d1fe208b734e645ffab8a3c56b03f4 Merge branch 'jk/incore-lockfile-removal' into next The long-standing rule that an in-core lockfile instance, once it is used, must not be freed, has been lifted and the lockfile and tempfile APIs have been updated to reduce the chance of programming errors. * jk/incore-lockfile-removal: stop leaking lock structs in some simple cases ref_lock: stop leaking lock_files lockfile: update lifetime requirements in documentation tempfile: auto-allocate tempfiles on heap tempfile: remove deactivated list entries tempfile: use list.h for linked list tempfile: release deactivated strbufs instead of resetting tempfile: robustify cleanup handler tempfile: factor out deactivation tempfile: factor out activation tempfile: replace die("BUG") with BUG() tempfile: handle NULL tempfile pointers gracefully tempfile: prefer is_tempfile_active to bare access lockfile: do not rollback lock on failed close tempfile: do not delete tempfile on failed close always check return value of close_tempfile verify_signed_buffer: prefer close_tempfile() to close() setup_temporary_shallow: move tempfile struct into function setup_temporary_shallow: avoid using inactive tempfile write_index_as_tree: cleanup tempfile on error --- 603dae7fb2d1fe208b734e645ffab8a3c56b03f4 diff --cc refs/files-backend.c index cda790dcbc,f3455609d6..a7cc65d0de --- a/refs/files-backend.c +++ b/refs/files-backend.c @@@ -2425,17 -2365,13 +2418,17 @@@ static int lock_ref_for_update(struct f * the lockfile is still open. Close it to * free up the file descriptor: */ - if (close_ref(lock)) { + if (close_ref_gently(lock)) { strbuf_addf(err, "couldn't close '%s.lock'", update->refname); - return TRANSACTION_GENERIC_ERROR; + ret = TRANSACTION_GENERIC_ERROR; + goto out; } } - return 0; + +out: + strbuf_release(&referent); + return ret; } /*