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

Re: [PATCH 2/2] lock_packed_refs(): allow retries when acquiring the packed-refs lock

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
May 2, 2015, 03:47 UTC
Message-ID
<554448B6.6080605@alum.mit.edu>
In-Reply-To
<5543A621.7010208@kdbg.org>
On 05/01/2015 06:13 PM, Johannes Sixt wrote:
Show 25 quoted lines
> Am 01.05.2015 um 16:52 schrieb Michael Haggerty:
>> +test_expect_success 'retry acquiring packed-refs.lock' '
>> +    LOCK=.git/packed-refs.lock &&
>> +    >$LOCK &&
>> +    test_when_finished "rm -f $LOCK" &&
>> +    {
>> +        ( sleep 1 ; rm -f $LOCK ) &
>> +    } &&
> 
> I haven't tested yet, but I think that this will be problematic on
> Windows: a directory cannot be removed if it is the current directory of
> a process. Here, the sub-shell process is alive for a second. If the
> remainder of the test script completes before the process dies, the test
> directory cannot be removed.
> 
> How about this:
> 
>     test_when_finished "wait; rm -f $LOCK" &&
>     { sleep 1 & } &&
>     ...
> 
>> +    git -c core.packedrefstimeout=3000 pack-refs --all --prune
>> +'
>> +
>>   test_done

Thanks for pointing out this problem. Your suggestion seems good. I assume that you didn't intend to omit the "rm -f $LOCK" from the subprocess, because the whole point is for that to happen while "git pack-refs" is running.

I will include your change in v2.
Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
Previous: Johannes SixtNext: Johannes Sixt
Message 6 of 18 in “Retry attempts to acquire the packed-refs lock”
  1. 0/2 Retry attempts to acquire the packed-refs lockMichael Haggerty, May 1, 2015
  2. 1/2 lockfile: allow file locking to be retried with a timeoutMichael Haggerty, May 1, 2015
  3. Junio C HamanoMay 11, 2015
  4. 2/2 lock_packed_refs(): allow retries when acquiring the packed-refs lockMichael Haggerty, May 1, 2015
  5. Johannes SixtMay 1, 2015
  6. Michael HaggertyMay 2, 2015
  7. Johannes SixtMay 2, 2015
  8. Michael HaggertyMay 11, 2015
  9. Stefan BellerMay 1, 2015
  10. Jeff KingMay 1, 2015
  11. Michael HaggertyMay 2, 2015
  12. Stefan BellerMay 4, 2015
  13. Jeff KingMay 5, 2015
  14. Michael HaggertyMay 11, 2015
  15. Jeff KingMay 11, 2015
  16. Stefan BellerMay 11, 2015
  17. Stefan BellerMay 11, 2015
  18. Junio C HamanoMay 3, 2015

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.