git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] files_initial_transaction_commit(): only unlock if locked

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 19, 2018, 22:14 UTC
Message-ID
<xmqqwp0do5sg.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20180118141914.GA32718@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 27 quoted lines
> On Thu, Jan 18, 2018 at 02:38:41PM +0100, Mathias Rav wrote:
>
>> 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.
>
> Thanks, this solution looks correct to me. It's pretty low-impact since
> the locking is the second-to-last thing in the function, so we don't
> have to re-add the unlock to a bunch of error code paths. But one
> alternative would be to just do:
>
>   if (packed_refs_is_locked(refs))
> 	packed_refs_unlock(refs->packed_ref_store);
>
> in the cleanup section.

Yeah, that may be a more future-proof alternative, and just as you said the patch as posted would be sufficient, too.

Thanks.
Previous: Jeff KingNext: Michael Haggerty
Message 3 of 5 in “files_initial_transaction_commit(): only unlock if locked”
  1. files_initial_transaction_commit(): only unlock if lockedMathias Rav, Jan 18, 2018
  2. Jeff KingJan 18, 2018
  3. Junio C HamanoJan 19, 2018
  4. Michael HaggertyJan 22, 2018
  5. Mathias RavJan 22, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.