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

Re: [PATCH 2/5] refs.c: write updates to packed refs when a transaction has more than one ref

From
Ronnie Sahlberg <sahlberg@google.com>
Date
Jul 30, 2014, 19:19 UTC
Message-ID
<CAL=YDWn60wSnY3cKBDgZYdCnNDzyF9VyJ72CbBcHSi7kM2uY2A@mail.gmail.com>
In-Reply-To
<xmqq4mxz3m8q.fsf@gitster.dls.corp.google.com>
On Tue, Jul 29, 2014 at 2:09 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 36 quoted lines
> Ronnie Sahlberg <sahlberg@google.com> writes:
>
>> +     /*
>> +      * Always copy loose refs that are to be deleted to the packed refs.
>> +      * If we are updating multiple refs then copy all non symref refs
>> +      * to the packed refs too.
>> +      */
>>       for (i = 0; i < n; i++) {
>>               struct ref_update *update = updates[i];
>>               unsigned char sha1[20];
>> +             int flag;
>>
>>               if (update->update_type != UPDATE_SHA1)
>>                       continue;
>> -             if (!is_null_sha1(update->new_sha1))
>> +             if (num_updates < 2 && !is_null_sha1(update->new_sha1))
>>                       continue;
>>               if (get_packed_ref(update->refname))
>>                       continue;
>>               if (!resolve_ref_unsafe(update->refname, sha1,
>> -                                     RESOLVE_REF_READING, NULL))
>> +                                     RESOLVE_REF_READING, &flag))
>> +                     continue;
>> +             if (flag & REF_ISSYMREF)
>>                       continue;
>
> This skipping of symref didn't use to be here.
>
> Is this an enhancement needed to implement the new "feature"
> (i.e. use packed refs to represent multi-update as an atomic
> operation)?  It looks to me more like an unrelated "oops, forgot
> that we cannot use packed refs to store symrefs" fix-up, unless no
> caller passed symref in updates[] in the original code, and now we
> have callers that do.
>
> Puzzled...

It was mainly as an enhancement. Prior to this patch we were only using the packed-refs trick for the delete+rename operation part of a rename_ref() call. And for that case we already explicitly test for and disallow symbolic refs already in rename_ref().

I added this just for extra safety for "now that we possibly delete multiple refs in one transaction, should I special case/disallow the packed refs trick for symrefs?" Looking at it again I don't think we need this special casing and it only makes the code more complex and confusing. I will review the use of this a little and run some tests and if all looks sane I will remove this ISSYMREF special casing.

Thank! ronnie sahlberg

Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 10 in “use packed refs for ref-transactions”
  1. 0/5 use packed refs for ref-transactionsRonnie Sahlberg, Jul 25, 2014
  2. 1/5 refs.c: move reflog updates into its own functionRonnie Sahlberg, Jul 25, 2014
  3. 2/5 refs.c: write updates to packed refs when a transaction has more than one refRonnie Sahlberg, Jul 25, 2014
  4. Junio C HamanoJul 29, 2014
  5. Ronnie SahlbergJul 30, 2014
  6. Junio C HamanoJul 29, 2014
  7. Ronnie SahlbergJul 30, 2014
  8. 3/5 remote.c: use a transaction for deleting refsRonnie Sahlberg, Jul 25, 2014
  9. 4/5 refs.c: make repack_without_refs staticRonnie Sahlberg, Jul 25, 2014
  10. 5/5 refs.c: make the *_packed_refs functions staticRonnie Sahlberg, Jul 25, 2014

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.