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

Re: [PATCHv3 5/6] refs.c: remove unlock_ref and commit_ref from write_ref_sha1

From
Stefan Beller <sbeller@google.com>
Date
Jan 24, 2015, 00:22 UTC
Message-ID
<CAGZ79kYPCFBNNkYV0C_XeCEaqfz=Mh3Zy=L-vAWsmZBFgebqNQ@mail.gmail.com>
In-Reply-To
<xmqq61bxoxs8.fsf@gitster.dls.corp.google.com>
On Fri, Jan 23, 2015 at 3:57 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 21 quoted lines
> Stefan Beller <sbeller@google.com> writes:
>
>> -static int commit_ref(struct ref_lock *lock)
>> +static int commit_ref(struct ref_lock *lock, const unsigned char *sha1)
>>  {
>> +     if (!lock->force_write && !hashcmp(lock->old_sha1, sha1))
>> +             return 0;
>>       if (commit_lock_file(lock->lk))
>>               return -1;
>>       return 0;
>> @@ -2879,10 +2882,13 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
>>       }
>>       lock->force_write = 1;
>>       hashcpy(lock->old_sha1, orig_sha1);
>> -     if (write_ref_sha1(lock, orig_sha1, logmsg)) {
>> +     if (write_ref_sha1(lock, orig_sha1, logmsg)
>> +         || commit_ref(lock, orig_sha1)) {
>> +             unlock_ref(lock);
>
> This is not a new problem, but the two lines in pre-context of this
> patch look strange.

Which (not new) problem are you talking about here? Do you have a reference?

Show 8 quoted lines
> Regardless of what this particular caller does, I am not sure if the
> early-return codepath in commit_ref() is correct.  From the callers'
> point of view, it sometimes unlocks the ref (i.e. when a different
> SHA-1 is written or force_write is set) and sometimes keeps the ref
> locked (i.e. when early-return is taken).  Shouldn't these two cases
> behave identically?  Or am I wrong to assume that the early return
> using "hashcmp(lock->old_sha1, sha1)" is a mere optimization?
>

I assumed it was not just an optimization as the test suite fails if I touch that line. I'll look into cleaning it up in a more obvious fashion.

Previous: Junio C HamanoNext: Junio C Hamano
Message 33 of 45 in “[PATCHv2 0/5] Fix bug in large transactions”
  1. Stefan BellerJan 22, 2015
  2. 1/5 update-ref: test handling large transactions properlyStefan Beller, Jan 22, 2015
  3. Michael HaggertyJan 22, 2015
  4. Jeff KingJan 22, 2015
  5. 2/5 t7004: rename ULIMIT test prerequisite to ULIMIT_STACK_SIZEStefan Beller, Jan 22, 2015
  6. 3/5 refs.c: remove lock_fd from struct ref_lockStefan Beller, Jan 22, 2015
  7. 4/5 refs.c: have a write_sha1_to_lock_file wrapperStefan Beller, Jan 22, 2015
  8. 5/5 refs.c: enable large transactionsStefan Beller, Jan 22, 2015
  9. Michael HaggertyJan 22, 2015
  10. Jeff KingJan 22, 2015
  11. Michael HaggertyJan 22, 2015
  12. Stefan BellerJan 22, 2015
  13. 0/5 So you dislike the sequence of system calls?Stefan Beller, Jan 22, 2015
  14. 1/5 fixup for "refs.c: enable large transactions"Stefan Beller, Jan 22, 2015
  15. 2/5 refs.c: remove unlock_ref from write_ref_sha1Stefan Beller, Jan 22, 2015
  16. 3/5 refs.c: move static functions to close and commit refsStefan Beller, Jan 22, 2015
  17. 4/5 refs.c: remove committing the ref from write_ref_sha1Stefan Beller, Jan 22, 2015
  18. 5/5 refs.c: write values to lock files early for committingStefan Beller, Jan 22, 2015
  19. Ramsay JonesJan 22, 2015
  20. Stefan BellerJan 22, 2015
  21. Ramsay JonesJan 22, 2015
  22. Ramsay JonesJan 22, 2015
  23. Stefan BellerJan 22, 2015
  24. Ramsay JonesJan 22, 2015
  25. Michael HaggertyJan 22, 2015
  26. 0/6 Fix bug in large transactionsStefan Beller, Jan 23, 2015
  27. 1/6 update-ref: test handling large transactions properlyStefan Beller, Jan 23, 2015
  28. 2/6 t7004: rename ULIMIT test prerequisite to ULIMIT_STACK_SIZEStefan Beller, Jan 23, 2015
  29. 3/6 refs.c: remove lock_fd from struct ref_lockStefan Beller, Jan 23, 2015
  30. 4/6 refs.c: move static functions to close and commit refsStefan Beller, Jan 23, 2015
  31. 5/6 refs.c: remove unlock_ref and commit_ref from write_ref_sha1Stefan Beller, Jan 23, 2015
  32. Junio C HamanoJan 23, 2015
  33. Stefan BellerJan 24, 2015
  34. Junio C HamanoJan 24, 2015
  35. Stefan BellerJan 24, 2015
  36. Junio C HamanoJan 24, 2015
  37. 6/6 refs.c: enable large transactionsStefan Beller, Jan 23, 2015
  38. Junio C HamanoJan 24, 2015
  39. Stefan BellerJan 24, 2015
  40. Junio C HamanoJan 24, 2015
  41. Stefan BellerJan 26, 2015
  42. refs.c: clean up write_ref_sha1 returnsStefan Beller, Jan 26, 2015
  43. Junio C HamanoJan 27, 2015
  44. Stefan BellerJan 28, 2015
  45. Junio C HamanoJan 27, 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.