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

Re: [PATCH 2/3] fetch.c: change s_update_ref to use a ref transaction

From
Ronnie Sahlberg <sahlberg@google.com>
Date
Apr 24, 2014, 15:22 UTC
Message-ID
<CAL=YDWm5NqkBSCkxabCO3_tDqPyuugD8K9FHZ5dsw9dAEXf5Eg@mail.gmail.com>
In-Reply-To
<CAPig+cQUAVK7O7yRJGjvRmuPg06C1ZEi876gMsihFpGLgVa=Mg@mail.gmail.com>
Fixed. Thanks.
On Wed, Apr 23, 2014 at 1:12 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 49 quoted lines
> On Tue, Apr 22, 2014 at 2:45 PM, Ronnie Sahlberg <sahlberg@google.com> wrote:
>> Change s_update_ref to use a ref transaction for the ref update.
>> Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
>>
>> Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
>
> Doubled sign-off.
>
>> ---
>>  builtin/fetch.c | 15 +++++++--------
>>  1 file changed, 7 insertions(+), 8 deletions(-)
>>
>> diff --git a/builtin/fetch.c b/builtin/fetch.c
>> index a93c893..5c15584 100644
>> --- a/builtin/fetch.c
>> +++ b/builtin/fetch.c
>> @@ -375,7 +375,7 @@ static int s_update_ref(const char *action,
>>  {
>>         char msg[1024];
>>         char *rla = getenv("GIT_REFLOG_ACTION");
>> -       static struct ref_lock *lock;
>> +       struct ref_transaction *transaction;
>>
>>         if (dry_run)
>>                 return 0;
>> @@ -384,15 +384,14 @@ static int s_update_ref(const char *action,
>>         snprintf(msg, sizeof(msg), "%s: %s", rla, action);
>>
>>         errno = 0;
>> -       lock = lock_any_ref_for_update(ref->name,
>> -                                      check_old ? ref->old_sha1 : NULL,
>> -                                      0, NULL);
>> -       if (!lock)
>> -               return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
>> -                                         STORE_REF_ERROR_OTHER;
>> -       if (write_ref_sha1(lock, ref->new_sha1, msg) < 0)
>> +       transaction = ref_transaction_begin();
>> +       if (!transaction ||
>> +           ref_transaction_update(transaction, ref->name, ref->new_sha1,
>> +                                  ref->old_sha1, 0, check_old) ||
>> +           ref_transaction_commit(transaction, msg, UPDATE_REFS_QUIET_ON_ERR))
>>                 return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
>>                                           STORE_REF_ERROR_OTHER;
>> +
>>         return 0;
>>  }
>>
>> --
>> 1.9.1.518.g16976cb.dirty
Previous: Eric SunshineNext: Ronnie Sahlberg
Message 7 of 14 in “Use ref transactions for fetch”
  1. 0/3 Use ref transactions for fetchRonnie Sahlberg, Apr 22, 2014
  2. 1/3 fetch.c: clear errno before calling functions that might set itRonnie Sahlberg, Apr 22, 2014
  3. Eric SunshineApr 23, 2014
  4. Ronnie SahlbergApr 24, 2014
  5. 2/3 fetch.c: change s_update_ref to use a ref transactionRonnie Sahlberg, Apr 22, 2014
  6. Eric SunshineApr 23, 2014
  7. Ronnie SahlbergApr 24, 2014
  8. 3/3 fetch.c: use a single ref transaction for all ref updatesRonnie Sahlberg, Apr 22, 2014
  9. Eric SunshineApr 23, 2014
  10. Ronnie SahlbergApr 24, 2014
  11. Michael HaggertyMay 5, 2014
  12. Ronnie SahlbergMay 5, 2014
  13. Junio C HamanoMay 6, 2014
  14. Michael HaggertyMay 6, 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.