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

[PATCH v3 0/8] reftable: a couple of improvements for libgit2

From
Patrick Steinhardt <ps@pks.im>
Date
Aug 12, 2025, 09:54 UTC
Message-ID
<20250812-pks-reftable-fixes-for-libgit2-v3-0-cf3b2267867e@pks.im>
In-Reply-To
<20250801-pks-reftable-fixes-for-libgit2-v1-0-f446e1c33cb9@pks.im>
Hi,

this small patch series contains a couple of improvements I required for libgit2. With those changes libgit2 is now able to run its full test suite with reftable-enabled repositories. I still need to invest a bit of work to make it memory-leak free and compile on Windows, but overall I think that support for reftables is almost ready.

Changes in v2:
  - Another commit that fixes handling of outdated stacks when doing
    compaction. This issue is hit in libgit2, which has a test that
    performs writes with a couple dozen concurrent threads.
  - Add a link to past discussions around `{0}` vs `{{0}}` as provided
    by Eric.
  - Link to v1: https://lore.kernel.org/r/20250801-pks-reftable-fixes-for-libgit2-v1-0-f446e1c33cb9@pks.im
Changes in v3:
  - Adapt `reftable_stack_init_addition()` to `memset()` the addition
    instead of using `{{0}}`.
  - Add another commit on top that makes the `flock` interface more
    robust by not relying on `errno`.
  - Add another commit to fix races with concurrent writers caused by
    the backend not passing `REFTABLE_STACK_NEW_ADDITION_RELOAD`.
  - Link to v2: https://lore.kernel.org/r/20250804-pks-reftable-fixes-for-libgit2-v2-0-fef06209a984@pks.im
Thanks!
Patrick
---
Patrick Steinhardt (8):
      reftable/writer: fix type used for number of records
      reftable/writer: drop Git-specific `QSORT()` macro
      reftable/stack: reorder code to avoid forward declarations
      reftable/stack: fix compiler warning due to missing braces
      reftable/stack: allow passing flags to `reftable_stack_add()`
      reftable/stack: handle outdated stacks when compacting
      reftable: don't second-guess errors from flock interface
      refs/reftable: always reload stacks when creating lock
 refs/reftable-backend.c         |  23 ++-
 reftable/reftable-stack.h       |   9 +-
 reftable/reftable-writer.h      |   4 +-
 reftable/stack.c                | 439 +++++++++++++++++++---------------------
 reftable/system.c               |   2 +-
 reftable/system.h               |   4 +-
 reftable/writer.c               |  23 ++-
 t/unit-tests/t-reftable-stack.c |  50 ++---
 8 files changed, 275 insertions(+), 279 deletions(-)
Range-diff versus v2:
1:  ce08ba1217 = 1:  1613715dc9 reftable/writer: fix type used for number of records
2:  80a87ff19a = 2:  4a082b71fb reftable/writer: drop Git-specific `QSORT()` macro
3:  e230c97347 < -:  ---------- reftable/stack: fix compiler warning due to missing braces
4:  dd413b76a2 ! 3:  3977a1f497 reftable/stack: reorder code to avoid forward declarations
    @@ reftable/stack.c: int reftable_stack_reload(struct reftable_stack *st)
      	struct reftable_stack *stack;
     @@ reftable/stack.c: struct reftable_addition {
      
    - #define REFTABLE_ADDITION_INIT {{0}}
    + #define REFTABLE_ADDITION_INIT {0}
      
     +static void reftable_addition_close(struct reftable_addition *add)
     +{
-:  ---------- > 4:  e8424dd2ee reftable/stack: fix compiler warning due to missing braces
5:  494bbd6c97 ! 5:  4f0f5cd8e1 reftable/stack: allow passing flags to `reftable_stack_add()`
    @@ reftable/stack.c: static int reftable_stack_init_addition(struct reftable_additi
     -			 void *arg)
     +			 void *arg, unsigned flags)
      {
    - 	struct reftable_addition add = REFTABLE_ADDITION_INIT;
    --	int err = reftable_stack_init_addition(&add, st, 0);
    -+	int err = reftable_stack_init_addition(&add, st, flags);
    + 	struct reftable_addition add;
    + 	int err;
    + 
    +-	err = reftable_stack_init_addition(&add, st, 0);
    ++	err = reftable_stack_init_addition(&add, st, flags);
      	if (err < 0)
      		goto done;
      
6:  46411bf2c2 = 6:  e6e06c8d34 reftable/stack: handle outdated stacks when compacting
-:  ---------- > 7:  86d57dad6e reftable: don't second-guess errors from flock interface
-:  ---------- > 8:  b7bb745ffb refs/reftable: always reload stacks when creating lock

--- base-commit: e813a0200a7121b97fec535f0d0b460b0a33356c change-id: 20250801-pks-reftable-fixes-for-libgit2-562b959a5603

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 26 of 52 in “reftable: a couple of improvements for libgit2”
  1. 0/5 reftable: a couple of improvements for libgit2Patrick Steinhardt, Aug 1, 2025
  2. 1/5 reftable/writer: fix type used for number of recordsPatrick Steinhardt, Aug 1, 2025
  3. 2/5 reftable/writer: drop Git-specific `QSORT()` macroPatrick Steinhardt, Aug 1, 2025
  4. 3/5 reftable/stack: fix compiler warning due to missing bracesPatrick Steinhardt, Aug 1, 2025
  5. Eric SunshineAug 1, 2025
  6. Patrick SteinhardtAug 4, 2025
  7. Junio C HamanoAug 4, 2025
  8. Patrick SteinhardtAug 5, 2025
  9. Carlo ArenasAug 12, 2025
  10. Patrick SteinhardtAug 12, 2025
  11. Junio C HamanoAug 12, 2025
  12. 4/5 reftable/stack: reorder code to avoid forward declarationsPatrick Steinhardt, Aug 1, 2025
  13. 5/5 reftable/stack: allow passing flags to `reftable_stack_add()`Patrick Steinhardt, Aug 1, 2025
  14. 0/6 reftable: a couple of improvements for libgit2Patrick Steinhardt, Aug 4, 2025
  15. 1/6 reftable/writer: fix type used for number of recordsPatrick Steinhardt, Aug 4, 2025
  16. 2/6 reftable/writer: drop Git-specific `QSORT()` macroPatrick Steinhardt, Aug 4, 2025
  17. 3/6 reftable/stack: fix compiler warning due to missing bracesPatrick Steinhardt, Aug 4, 2025
  18. 4/6 reftable/stack: reorder code to avoid forward declarationsPatrick Steinhardt, Aug 4, 2025
  19. Justin ToblerAug 11, 2025
  20. 5/6 reftable/stack: allow passing flags to `reftable_stack_add()`Patrick Steinhardt, Aug 4, 2025
  21. Justin ToblerAug 11, 2025
  22. Patrick SteinhardtAug 12, 2025
  23. 6/6 reftable/stack: handle outdated stacks when compactingPatrick Steinhardt, Aug 4, 2025
  24. Justin ToblerAug 11, 2025
  25. Patrick SteinhardtAug 12, 2025
  26. 0/8 reftable: a couple of improvements for libgit2Patrick Steinhardt, Aug 12, 2025
  27. 1/8 reftable/writer: fix type used for number of recordsPatrick Steinhardt, Aug 12, 2025
  28. 2/8 reftable/writer: drop Git-specific `QSORT()` macroPatrick Steinhardt, Aug 12, 2025
  29. 3/8 reftable/stack: reorder code to avoid forward declarationsPatrick Steinhardt, Aug 12, 2025
  30. 4/8 reftable/stack: fix compiler warning due to missing bracesPatrick Steinhardt, Aug 12, 2025
  31. Justin ToblerAug 12, 2025
  32. 5/8 reftable/stack: allow passing flags to `reftable_stack_add()`Patrick Steinhardt, Aug 12, 2025
  33. Justin ToblerAug 12, 2025
  34. Patrick SteinhardtAug 13, 2025
  35. 6/8 reftable/stack: handle outdated stacks when compactingPatrick Steinhardt, Aug 12, 2025
  36. 7/8 reftable: don't second-guess errors from flock interfacePatrick Steinhardt, Aug 12, 2025
  37. Justin ToblerAug 12, 2025
  38. 8/8 refs/reftable: always reload stacks when creating lockPatrick Steinhardt, Aug 12, 2025
  39. Justin ToblerAug 12, 2025
  40. Carlo ArenasAug 12, 2025
  41. Patrick SteinhardtAug 13, 2025
  42. Junio C HamanoAug 13, 2025
  43. 0/8 reftable: a couple of improvements for libgit2Patrick Steinhardt, Aug 13, 2025
  44. 1/8 reftable/writer: fix type used for number of recordsPatrick Steinhardt, Aug 13, 2025
  45. 2/8 reftable/writer: drop Git-specific `QSORT()` macroPatrick Steinhardt, Aug 13, 2025
  46. 3/8 reftable/stack: reorder code to avoid forward declarationsPatrick Steinhardt, Aug 13, 2025
  47. 4/8 reftable/stack: fix compiler warning due to missing bracesPatrick Steinhardt, Aug 13, 2025
  48. 5/8 reftable/stack: allow passing flags to `reftable_stack_add()`Patrick Steinhardt, Aug 13, 2025
  49. 6/8 reftable/stack: handle outdated stacks when compactingPatrick Steinhardt, Aug 13, 2025
  50. 7/8 reftable: don't second-guess errors from flock interfacePatrick Steinhardt, Aug 13, 2025
  51. 8/8 refs/reftable: always reload stacks when creating lockPatrick Steinhardt, Aug 13, 2025
  52. Justin ToblerAug 13, 2025

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.