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

Re: [PATCH 6/7] refs: allow multiple reflog entries for the same refname

From
Christian Couder <christian.couder@gmail.com>
Date
Dec 11, 2024, 10:44 UTC
Message-ID
<CAP8UFD2zogHD_g5FOVNFvBswPJF749wd4f2s9Pzgef-pv=U0Gg@mail.gmail.com>
In-Reply-To
<20241209-320-git-refs-migrate-reflogs-v1-6-d4bc37ee860f@gmail.com>
On Mon, Dec 9, 2024 at 12:11 PM Karthik Nayak <karthik.188@gmail.com> wrote:
>
> The reference transaction only allows a update for a given reference to
s/a update/an update/
or: s/a update/a single update/
> avoid conflicts. This, however, isn't an issue for reflogs. There are no
> conflicts to be resolved in reflogs and when migrating reflogs between
> backends we'd have multiple reflog entries for the same refname.
Show 5 quoted lines
> @@ -1302,6 +1303,7 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
>         struct ident_split committer_ident = {0};
>         size_t logs_nr = 0, logs_alloc = 0, i;
>         const char *committer_info;
> +       struct strintmap logs_ts;
Here a comment might help explain what logs_ts is used for.
Show 8 quoted lines
>         int ret = 0;
>
>         committer_info = git_committer_info(0);
> @@ -1310,6 +1312,8 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
>
>         QSORT(arg->updates, arg->updates_nr, transaction_update_cmp);
>
> +       strintmap_init(&logs_ts, ts);

I am not sure I understand what logs_ts is used for and why its default value is set to ts.

Also ts is an uint64_t while the second argument to strintmap_init() is an int. I wonder if it could be an issue especially on 32 bits platforms.

Show 20 quoted lines
>         reftable_writer_set_limits(writer, ts, ts);
>
>         for (i = 0; i < arg->updates_nr; i++) {
> @@ -1391,6 +1395,7 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
>
>                         if (create_reflog) {
>                                 struct ident_split c;
> +                               uint64_t update_index;
>
>                                 ALLOC_GROW(logs, logs_nr + 1, logs_alloc);
>                                 log = &logs[logs_nr++];
> @@ -1405,7 +1410,11 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
>                                 }
>
>                                 fill_reftable_log_record(log, &c);
> -                               log->update_index = ts;
> +
> +                               update_index = strintmap_get(&logs_ts, u->refname);
> +                               log->update_index = update_index;
> +                               strintmap_set(&logs_ts, u->refname, update_index+1);
s/update_index+1/update_index + 1/
Also is the 'update_index' var really needed or could we just do:
                               log->update_index =
strintmap_get(&logs_ts, u->refname);
                               strintmap_set(&logs_ts, u->refname,
log->update_index + 1);
?
>                                 log->refname = xstrdup(u->refname);
>                                 memcpy(log->value.update.new_hash,
>                                        u->new_oid.hash, GIT_MAX_RAWSZ);
Previous: Karthik NayakNext: karthik nayak
Message 21 of 30 in “refs: add reflog support to `git refs migrate`”
  1. 0/7 refs: add reflog support to `git refs migrate`Karthik Nayak, Dec 9, 2024
  2. 1/7 refs: include committer info in `ref_update` structKarthik Nayak, Dec 9, 2024
  3. Christian CouderDec 10, 2024
  4. karthik nayakDec 11, 2024
  5. 2/7 refs: add `index` field to `struct ref_udpate`Karthik Nayak, Dec 9, 2024
  6. 3/7 refs/files: add count field to ref_lockKarthik Nayak, Dec 9, 2024
  7. Christian CouderDec 10, 2024
  8. karthik nayakDec 11, 2024
  9. Christian CouderDec 11, 2024
  10. karthik nayakDec 11, 2024
  11. 4/7 refs: extract out refname verification in transactionsKarthik Nayak, Dec 9, 2024
  12. Christian CouderDec 11, 2024
  13. karthik nayakDec 11, 2024
  14. Patrick SteinhardtDec 11, 2024
  15. 5/7 refs: introduce the `ref_transaction_update_reflog` functionKarthik Nayak, Dec 9, 2024
  16. Christian CouderDec 11, 2024
  17. karthik nayakDec 11, 2024
  18. Patrick SteinhardtDec 11, 2024
  19. karthik nayakDec 11, 2024
  20. 6/7 refs: allow multiple reflog entries for the same refnameKarthik Nayak, Dec 9, 2024
  21. Christian CouderDec 11, 2024
  22. karthik nayakDec 12, 2024
  23. Patrick SteinhardtDec 11, 2024
  24. karthik nayakDec 12, 2024
  25. 7/7 refs: add support for migrating reflogsKarthik Nayak, Dec 9, 2024
  26. Patrick SteinhardtDec 11, 2024
  27. karthik nayakDec 12, 2024
  28. Junio C HamanoDec 10, 2024
  29. karthik nayakDec 10, 2024
  30. karthik nayakDec 10, 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.