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

Re: [PATCH v4 0/8] refs: add reflog support to `git refs migrate`

From
karthik nayak <karthik.188@gmail.com>
Date
Dec 20, 2024, 11:23 UTC
Message-ID
<CAOLa=ZRcp+OxiQxYGJeQ8AEWNk-6SkrRsZdi8bnNtNaWe_zrhg@mail.gmail.com>
In-Reply-To
<874j2zh3jv.fsf@iotcl.com>
Toon Claes <toon@iotcl.com> writes:
Show 38 quoted lines
> Karthik Nayak <karthik.188@gmail.com> writes:
>
>> The `git refs migrate` command was introduced in
>> 25a0023f28 (builtin/refs: new command to migrate ref storage formats,
>> 2024-06-06) to support migrating from one reference backend to another.
>>
>> One limitation of the feature was that it didn't support migrating
>> repositories which contained reflogs. This isn't a requirement on the
>> server side as repositories are stored as bare repositories (which do
>> not contain any reflogs). Clients however generally use reflogs and
>> until now couldn't use the `git refs migrate` command to migrate their
>> repositories to the new reftable format.
>>
>> One of the issues for adding reflog support is that the ref transactions
>> don't support reflogs additions:
>>   1. While there is REF_LOG_ONLY flag, there is no function to utilize
>>   the flag and add reflogs.
>>   2. reference backends generally sort the updates by the refname. This
>>   wouldn't work for reflogs which need to ensure that they maintain the
>>   order of creation.
>>   3. In the files backend, reflog entries are added by obtaining locks
>>   on the refs themselves. This means each update in the transaction, will
>>   obtain a ref_lock. This paradigm fails to accompany the fact that there
>>   could be multiple reflog updates for a refname in a single transaction.
>>   4. The backends check for duplicate entries, which doesn't make sense
>>   in the context of adding multiple reflogs for a given refname.
>>
>> We overcome these issue we make the following changes:
>>   - Update the ref_update structure to also include the committer
>>   information. Using this, we can add a new function which only adds
>>   reflog updates to the transaction.
>
> Out of interest, I see various changes happen around committer info. But
> why is the committer info more relevant for reflog updates, in contrast
> to normal ref updates?
>
> --
> Toon

The committer info is metadata around a ref update. It is only stored in the reflogs. So they're only relevant for reflogs! For e.g. in the files backend, we can see:

  $ cat .git/logs/HEAD | tail -1
  7a929cb27ca6df69d4db64b008e27e002c691028
bc8e00178b671da2b845ccbba175f6c093ed6949 Karthik Nayak
<karthik.188@google.com> 1734624674 +0100	commit: c10

Here the 'Karthik Nayak <karthik.188@gmail.com> 1734624673 +0100' section is the committer_info. Whereas if you see the reference itself

  $ cat .git/HEAD
  ref: refs/heads/master

It only contains reference information. So, the `committer_info` is not needed for regular ref updates. Earlier we dynamically obtain the information when a reflog was being created. But for migration of existing reflogs we need to pass this information from the source to the ref transaction mechanism. So we pass the `committer_info` through the layers.

Thank you for the review.
Previous: Toon Claes
Message 63 of 63 in “refs: add reflog support to `git refs migrate`”
  1. 0/8 refs: add reflog support to `git refs migrate`Karthik Nayak, Dec 13, 2024
  2. 1/8 refs: include committer info in `ref_update` structKarthik Nayak, Dec 13, 2024
  3. 2/8 refs: add `index` field to `struct ref_udpate`Karthik Nayak, Dec 13, 2024
  4. 3/8 refs/files: add count field to ref_lockKarthik Nayak, Dec 13, 2024
  5. 4/8 refs: extract out refname verification in transactionsKarthik Nayak, Dec 13, 2024
  6. 5/8 refs: add `committer_info` to `ref_transaction_add_update()`Karthik Nayak, Dec 13, 2024
  7. Patrick SteinhardtDec 13, 2024
  8. karthik nayakDec 13, 2024
  9. Toon ClaesDec 19, 2024
  10. karthik nayakDec 20, 2024
  11. 6/8 refs: introduce the `ref_transaction_update_reflog` functionKarthik Nayak, Dec 13, 2024
  12. Christian CouderDec 13, 2024
  13. karthik nayakDec 13, 2024
  14. Patrick SteinhardtDec 13, 2024
  15. 7/8 refs: allow multiple reflog entries for the same refnameKarthik Nayak, Dec 13, 2024
  16. Patrick SteinhardtDec 13, 2024
  17. karthik nayakDec 13, 2024
  18. 8/8 refs: add support for migrating reflogsKarthik Nayak, Dec 13, 2024
  19. Patrick SteinhardtDec 13, 2024
  20. karthik nayakDec 15, 2024
  21. 0/8 refs: add reflog support to `git refs migrate`Karthik Nayak, Dec 15, 2024
  22. 1/8 refs: include committer info in `ref_update` structKarthik Nayak, Dec 15, 2024
  23. 2/8 refs: add `index` field to `struct ref_udpate`Karthik Nayak, Dec 15, 2024
  24. 3/8 refs/files: add count field to ref_lockKarthik Nayak, Dec 15, 2024
  25. 4/8 refs: extract out refname verification in transactionsKarthik Nayak, Dec 15, 2024
  26. 5/8 refs: add `committer_info` to `ref_transaction_add_update()`Karthik Nayak, Dec 15, 2024
  27. 6/8 refs: introduce the `ref_transaction_update_reflog` functionKarthik Nayak, Dec 15, 2024
  28. 7/8 refs: allow multiple reflog entries for the same refnameKarthik Nayak, Dec 15, 2024
  29. 8/8 refs: add support for migrating reflogsKarthik Nayak, Dec 15, 2024
  30. Patrick SteinhardtDec 16, 2024
  31. Junio C HamanoDec 16, 2024
  32. karthik nayakDec 16, 2024
  33. Junio C HamanoDec 15, 2024
  34. karthik nayakDec 16, 2024
  35. Junio C HamanoDec 16, 2024
  36. 0/8 refs: add reflog support to `git refs migrate`Karthik Nayak, Dec 16, 2024
  37. 1/8 refs: include committer info in `ref_update` structKarthik Nayak, Dec 16, 2024
  38. 2/8 refs: add `index` field to `struct ref_udpate`Karthik Nayak, Dec 16, 2024
  39. Toon ClaesDec 19, 2024
  40. karthik nayakDec 20, 2024
  41. 3/8 refs/files: add count field to ref_lockKarthik Nayak, Dec 16, 2024
  42. 4/8 refs: extract out refname verification in transactionsKarthik Nayak, Dec 16, 2024
  43. Toon ClaesDec 19, 2024
  44. karthik nayakDec 20, 2024
  45. 5/8 refs: add `committer_info` to `ref_transaction_add_update()`Karthik Nayak, Dec 16, 2024
  46. Toon ClaesDec 19, 2024
  47. karthik nayakDec 20, 2024
  48. 6/8 refs: introduce the `ref_transaction_update_reflog` functionKarthik Nayak, Dec 16, 2024
  49. Toon ClaesDec 19, 2024
  50. Junio C HamanoDec 19, 2024
  51. karthik nayakDec 20, 2024
  52. refs: mark invalid refname message for translationKarthik Nayak, Dec 20, 2024
  53. Junio C HamanoDec 20, 2024
  54. Toon ClaesDec 24, 2024
  55. 7/8 refs: allow multiple reflog entries for the same refnameKarthik Nayak, Dec 16, 2024
  56. Toon ClaesDec 19, 2024
  57. karthik nayakDec 20, 2024
  58. 8/8 refs: add support for migrating reflogsKarthik Nayak, Dec 16, 2024
  59. Patrick SteinhardtDec 17, 2024
  60. karthik nayakDec 17, 2024
  61. Junio C HamanoDec 17, 2024
  62. Toon ClaesDec 19, 2024
  63. karthik nayakDec 20, 2024

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.