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

Re: [PATCH v2 8/9] refs: add peeled object ID to the `ref_update` struct

From
Karthik Nayak <karthik.188@gmail.com>
Date
Apr 27, 2026, 09:33 UTC
Message-ID
<CAOLa=ZSwupDzWKk0bq=N+O8U0NV9y3h3hFsAeN8WJF-Nwj5vVw@mail.gmail.com>
In-Reply-To
<87v7dgcnp6.fsf@toon--20250203-5JQV3.mail-host-address-is-not-set>
Toon Claes <toon@iotcl.com> writes:
Show 8 quoted lines
> Karthik Nayak <karthik.188@gmail.com> writes:
>
>> Certain reference backend {packed, reftable}, have the ability to also
>
> Shouldn't it be:
>
>   Certain reference backends {packed, reftable} have the ability to also
>
Oh yeah, thanks!
Show 98 quoted lines
>> store the peeled object ID for a reference pointing to a tag object.
>> This has the added benefit that during retrieval of such references, we
>> also obtain the peeled object ID without having to use the ODB.
>>
>> To provide this functionality, each backend independently calls the ODB
>> to obtain the peeled OID. To move this functionality to the generic
>> layer, there must be support infrastructure to pass in a peeled OID for
>> reference updates.
>>
>> Add a `peeled` field to the `ref_update` structure and modify
>> `ref_transaction_add_update()` to receive and copy this object ID to the
>> `ref_update` structure. Finally, modify `ref_transaction_update()` to
>> peel tag objects and pass the peeled OID to
>> `ref_transaction_add_update()`.
>>
>> Update all callers of these functions with the new function parameters.
>> Callers which only add reflog updates, need to only pass in NULL, since
>> for reflogs, we don't store peeled OIDs. Reference deletions also only
>> need to pass in NULL. For others, pass along the peeled OID if
>> available.
>>
>> In a following commit, we'll modify the backends to use this peeled OID
>> instead of parsing it themselves.
>>
>> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
>> ---
>>  refs.c                  | 15 +++++++++++++--
>>  refs/files-backend.c    | 20 ++++++++++++--------
>>  refs/refs-internal.h    | 14 ++++++++++++++
>>  refs/reftable-backend.c |  6 +++---
>>  4 files changed, 42 insertions(+), 13 deletions(-)
>>
>> diff --git a/refs/refs-internal.h b/refs/refs-internal.h
>> index d103387ebf..307dcb277b 100644
>> --- a/refs/refs-internal.h
>> +++ b/refs/refs-internal.h
>> @@ -39,6 +39,13 @@ struct ref_transaction;
>>   */
>>  #define REF_LOG_ONLY (1 << 7)
>>
>> +/*
>> + * The reference contains a peeled object ID. This is used when the
>> + * new_oid is pointing to a tag object and the reference backend
>> + * wants to also store the peeled value for optimized retrieval.
>> + */
>> +#define REF_HAVE_PEELED (1 << 15)
>
> How did you end up picking this value?
>
> I did some grepping to figure out if it would conflict with anything:
>
>     git grep -h '#define REF_' -- '*.h' '*.c' |
>       awk '/0x/{n=strtonum($3);b=0;while(n>1){n/=2;b++};$3="(1 << "b")"} 1' |
>       sort -t'<' -k3 -n |
>       column -t
>
> (Yeah I got some help from AI to write the `awk` command)
>
> Resulting in:
>
>     #define  REF_EXCLUSIONS_INIT                   {                \
>     #define  REF_FILTER_H
>     #define  REF_FILTER_INIT                       {                \
>     #define  REF_FORMAT_INIT                       {                \
>     #define  REF_FORMATTING_STATE_INIT             {                0   }
>     #define  REF_NO_DEREF                          (1               <<  0)
>     #define  REF_NORMAL                            (1u              <<  0)
>     #define  REF_STATES_INIT                       {                \
>     #define  REF_STORE_ALL_CAPS                    (REF_STORE_READ  |   \
>     #define  REF_STORE_CREATE_ON_DISK_IS_WORKTREE  (1               <<  0)
>     #define  REF_STORE_READ                        (1               <<  0)
>     #define  REF_TRANSACTION_UPDATE_ALLOWED_FLAGS  \
>     #define  REF_BRANCHES                          (1u              <<  1)
>     #define  REF_FORCE_CREATE_REFLOG               (1               <<  1)
>     #define  REF_STORE_WRITE                       (1               <<  1)   /*  can  perform  update  operations  */
>     #define  REF_HAVE_NEW                          (1               <<  2)
>     #define  REF_STORE_ODB                         (1               <<  2)   /*  has  access   to      object      database  */
>     #define  REF_TAGS                              (1u              <<  2)
>     #define  REF_HAVE_OLD                          (1               <<  3)
>     #define  REF_STORE_MAIN                        (1               <<  3)
>     #define  REF_DIR                               (1               <<  4)
>     #define  REF_IS_PRUNING                        (1               <<  4)
>     #define  REF_DELETING                          (1               <<  5)
>     #define  REF_INCOMPLETE                        (1               <<  5)
>     #define  REF_KNOWS_PEELED                      (1               <<  6)
>     #define  REF_NEEDS_COMMIT                      (1               <<  6)
>     #define  REF_LOG_ONLY                          (1               <<  7)
>     #define  REF_UPDATE_VIA_HEAD                   (1               <<  8)
>     #define  REF_UPDATE_VIA_HEAD                   (1               <<  8)
>     #define  REF_DELETED_RMDIR                     (1               <<  9)
>     #define  REF_SKIP_OID_VERIFICATION             (1               <<  10)
>     #define  REF_SKIP_REFNAME_VERIFICATION         (1               <<  11)
>     #define  REF_SKIP_CREATE_REFLOG                (1               <<  12)
>     #define  REF_LOG_USE_PROVIDED_OIDS             (1               <<  13)
>     #define  REF_LOG_VIA_SPLIT                     (1               <<  14)
>     #define  REF_HAVE_PEELED                       (1               <<  15)
>
> So I guess it makes sense to use `(1 << 15)`.

I wish I has this command, I manually went through the individual files. I think it is messy though, hopefully something to cleanup next.

#leftoverbits
> --
> Cheers,
> Toon
Thanks for the review, appreciate it..
Previous: Toon ClaesNext: Karthik Nayak
Message 42 of 68 in “refs: move some of the generic logic out of the backends”
  1. 0/8 refs: move some of the generic logic out of the backendsKarthik Nayak, Apr 20, 2026
  2. 1/8 refs: remove unused typedef 'ref_transaction_commit_fn'Karthik Nayak, Apr 20, 2026
  3. Patrick SteinhardtApr 22, 2026
  4. Karthik NayakApr 22, 2026
  5. 2/8 refs: extract out reflog config to generic layerKarthik Nayak, Apr 20, 2026
  6. Patrick SteinhardtApr 22, 2026
  7. Karthik NayakApr 22, 2026
  8. 3/8 refs: return `ref_transaction_error` from `ref_transaction_update()`Karthik Nayak, Apr 20, 2026
  9. Patrick SteinhardtApr 22, 2026
  10. Karthik NayakApr 22, 2026
  11. 4/8 update-ref: move `print_rejected_refs()` upKarthik Nayak, Apr 20, 2026
  12. Patrick SteinhardtApr 22, 2026
  13. Karthik NayakApr 22, 2026
  14. 5/8 update-ref: handle rejections while adding updatesKarthik Nayak, Apr 20, 2026
  15. Patrick SteinhardtApr 22, 2026
  16. Karthik NayakApr 22, 2026
  17. 6/8 refs: move object parsing to the generic layerKarthik Nayak, Apr 20, 2026
  18. Patrick SteinhardtApr 22, 2026
  19. Karthik NayakApr 22, 2026
  20. 8/8 refs: use peeled tag values in reference backendsKarthik Nayak, Apr 20, 2026
  21. 7/8 refs: add peeled object ID to the `ref_update` structKarthik Nayak, Apr 20, 2026
  22. 0/9 refs: move some of the generic logic out of the backendsKarthik Nayak, Apr 23, 2026
  23. 1/9 refs: remove unused typedef 'ref_transaction_commit_fn'Karthik Nayak, Apr 23, 2026
  24. 2/9 refs: introduce `ref_store_init_options`Karthik Nayak, Apr 23, 2026
  25. Patrick SteinhardtApr 23, 2026
  26. Karthik NayakApr 24, 2026
  27. 3/9 refs: extract out reflog config to generic layerKarthik Nayak, Apr 23, 2026
  28. Patrick SteinhardtApr 23, 2026
  29. 4/9 refs: return `ref_transaction_error` from `ref_transaction_update()`Karthik Nayak, Apr 23, 2026
  30. Toon ClaesApr 24, 2026
  31. 5/9 update-ref: move `print_rejected_refs()` upKarthik Nayak, Apr 23, 2026
  32. 6/9 update-ref: handle rejections while adding updatesKarthik Nayak, Apr 23, 2026
  33. Patrick SteinhardtApr 23, 2026
  34. Karthik NayakApr 24, 2026
  35. Toon ClaesApr 24, 2026
  36. Karthik NayakApr 27, 2026
  37. 7/9 refs: move object parsing to the generic layerKarthik Nayak, Apr 23, 2026
  38. Toon ClaesApr 24, 2026
  39. Karthik NayakApr 27, 2026
  40. 8/9 refs: add peeled object ID to the `ref_update` structKarthik Nayak, Apr 23, 2026
  41. Toon ClaesApr 24, 2026
  42. Karthik NayakApr 27, 2026
  43. 9/9 refs: use peeled tag values in reference backendsKarthik Nayak, Apr 23, 2026
  44. 0/9 refs: move some of the generic logic out of the backendsKarthik Nayak, Apr 27, 2026
  45. 1/9 refs: remove unused typedef 'ref_transaction_commit_fn'Karthik Nayak, Apr 27, 2026
  46. 2/9 refs: introduce `ref_store_init_options`Karthik Nayak, Apr 27, 2026
  47. 3/9 refs: extract out reflog config to generic layerKarthik Nayak, Apr 27, 2026
  48. 4/9 refs: return `ref_transaction_error` from `ref_transaction_update()`Karthik Nayak, Apr 27, 2026
  49. 5/9 update-ref: move `print_rejected_refs()` upKarthik Nayak, Apr 27, 2026
  50. 6/9 update-ref: handle rejections while adding updatesKarthik Nayak, Apr 27, 2026
  51. Toon ClaesApr 29, 2026
  52. Karthik NayakApr 30, 2026
  53. 7/9 refs: move object parsing to the generic layerKarthik Nayak, Apr 27, 2026
  54. 8/9 refs: add peeled object ID to the `ref_update` structKarthik Nayak, Apr 27, 2026
  55. 9/9 refs: use peeled tag values in reference backendsKarthik Nayak, Apr 27, 2026
  56. 0/9 refs: move some of the generic logic out of the backendsKarthik Nayak, May 4, 2026
  57. 1/9 refs: remove unused typedef 'ref_transaction_commit_fn'Karthik Nayak, May 4, 2026
  58. 2/9 refs: introduce `ref_store_init_options`Karthik Nayak, May 4, 2026
  59. 3/9 refs: extract out reflog config to generic layerKarthik Nayak, May 4, 2026
  60. 4/9 refs: return `ref_transaction_error` from `ref_transaction_update()`Karthik Nayak, May 4, 2026
  61. 5/9 update-ref: move `print_rejected_refs()` upKarthik Nayak, May 4, 2026
  62. 6/9 update-ref: handle rejections while adding updatesKarthik Nayak, May 4, 2026
  63. Patrick SteinhardtMay 5, 2026
  64. Karthik NayakMay 5, 2026
  65. Toon ClaesMay 6, 2026
  66. 7/9 refs: move object parsing to the generic layerKarthik Nayak, May 4, 2026
  67. 8/9 refs: add peeled object ID to the `ref_update` structKarthik Nayak, May 4, 2026
  68. 9/9 refs: use peeled tag values in reference backendsKarthik Nayak, May 4, 2026

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.