files_initial_transaction_commit(): only unlock if locked

Running git clone --single-branch --mirror -b TAGNAME previously triggered the following error message: fatal: multiple updates for ref 'refs/tags/TAGNAME' not allowed. This error condition is handled in files_initial_transaction_commit(). 42c7f7ff9 ("commit_packed_refs(): remove call to `packed_refs_unlock()`", 2017-06-23) introduced incorrect unlocking in the error path of this function, which changes the error message to fatal: BUG: packed_refs_unlock() called when not locked Move the call to packed_refs_unlock() above the "cleanup:" label since the unlocking should only be done in the last error path. Signed-off-by: Mathias Rav <m@git.strova.dk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Mathias Rav committed Jan 18, 2018 at 14:38 UTC 81fcb698e03543d35c93ec6726a830aa6b9c5167
1 file changed +1 -2
refs/files-backend.c
+1 -2
@@ -2874,13 +2874,12 @@ static int files_initial_transaction_commit(struct ref_store *ref_store,
2874
2875 if (initial_ref_transaction_commit(packed_transaction, err)) {
2876 ret = TRANSACTION_GENERIC_ERROR;
2877 - goto cleanup;
2877 }
2878
2879 + packed_refs_unlock(refs->packed_ref_store);
2880 cleanup:
2881 if (packed_transaction)
2882 ref_transaction_free(packed_transaction);
2883 - packed_refs_unlock(refs->packed_ref_store);
2883 transaction->state = REF_TRANSACTION_CLOSED;
2884 string_list_clear(&affected_refnames, 0);
2885 return ret;