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

Re: [PATCH 1/8] refs/reftable: encapsulate reftable stack

From
karthik nayak <karthik.188@gmail.com>
Date
Nov 5, 2024, 11:03 UTC
Message-ID
<CAOLa=ZR89CRuJ7nwBfbGhi-wFuwEc96qNoid8sNKHD5ssmrOXg@mail.gmail.com>
In-Reply-To
<b599bcdac191fd3cfb7797accebd79211e757c47.1730732881.git.ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 45 quoted lines
> The reftable ref store needs to keep track of multiple stacks, one for
> the main worktree and an arbitrary number of stacks for worktrees. This
> is done by storing pointers to `struct reftable_stack`, which we then
> access directly.
>
> Wrap the stack in a new `struct reftable_backend`. This will allow us to
> attach more data to each respective stack in subsequent commits.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  refs/reftable-backend.c | 129 +++++++++++++++++++++++-----------------
>  1 file changed, 73 insertions(+), 56 deletions(-)
>
> diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
> index 38eb14d591..43cba53cb1 100644
> --- a/refs/reftable-backend.c
> +++ b/refs/reftable-backend.c
> @@ -32,6 +32,23 @@
>   */
>  #define REF_UPDATE_VIA_HEAD (1 << 8)
>
> +struct reftable_backend {
> +	struct reftable_stack *stack;
> +};
> +
> +static int reftable_backend_init(struct reftable_backend *be,
> +				 const char *path,
> +				 const struct reftable_write_options *opts)
> +{
> +	return reftable_new_stack(&be->stack, path, opts);
> +}
> +
> +static void reftable_backend_release(struct reftable_backend *be)
> +{
> +	reftable_stack_destroy(be->stack);
> +	be->stack = NULL;
> +}
> +
>  struct reftable_ref_store {
>  	struct ref_store base;
>
> @@ -39,17 +56,17 @@ struct reftable_ref_store {
>  	 * The main stack refers to the common dir and thus contains common
>  	 * refs as well as refs of the main repository.
>  	 */

Shouldn't these comments be updated to say s/stack/backend, while the backend contains the stack, it is confusing to read stack and see backend.

Show 6 quoted lines
> -	struct reftable_stack *main_stack;
> +	struct reftable_backend main_backend;
>  	/*
>  	 * The worktree stack refers to the gitdir in case the refdb is opened
>  	 * via a worktree. It thus contains the per-worktree refs.
>  	 */
Here too.
Show 6 quoted lines
> -	struct reftable_stack *worktree_stack;
> +	struct reftable_backend worktree_backend;
>  	/*
>  	 * Map of worktree stacks by their respective worktree names. The map
>  	 * is populated lazily when we try to resolve `worktrees/$worktree` refs.
>  	 */
Here too.
Show 5 quoted lines
> -	struct strmap worktree_stacks;
> +	struct strmap worktree_backends;
>  	struct reftable_write_options write_options;
>
>  	unsigned int store_flags;
[snip]
Show 6 quoted lines
> @@ -772,14 +789,14 @@ static struct ref_iterator *reftable_be_iterator_begin(struct ref_store *ref_sto
>  	 * right now. If we aren't, then we return the common reftable
>  	 * iterator, only.
>  	 */
> -	 if (!refs->worktree_stack)
> +	 if (!refs->worktree_backend.stack)
Nit: Not your fault, but this is misaligned no?
>  		return &main_iter->base;
>
[snip]
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 3 of 57 in “refs/reftable: reuse iterators when reading refs”
  1. 0/8 refs/reftable: reuse iterators when reading refsPatrick Steinhardt, Nov 4, 2024
  2. 1/8 refs/reftable: encapsulate reftable stackPatrick Steinhardt, Nov 4, 2024
  3. karthik nayakNov 5, 2024
  4. 2/8 refs/reftable: handle reloading stacks in the reftable backendPatrick Steinhardt, Nov 4, 2024
  5. karthik nayakNov 5, 2024
  6. Patrick SteinhardtNov 6, 2024
  7. 3/8 refs/reftable: read references via `struct reftable_backend`Patrick Steinhardt, Nov 4, 2024
  8. karthik nayakNov 5, 2024
  9. 4/8 refs/reftable: refactor reading symbolic refs to use reftable backendPatrick Steinhardt, Nov 4, 2024
  10. 5/8 refs/reftable: refactor reflog expiry to use reftable backendPatrick Steinhardt, Nov 4, 2024
  11. 6/8 reftable/stack: add mechanism to notify callers on reloadPatrick Steinhardt, Nov 4, 2024
  12. 7/8 reftable/merged: drain priority queue on reseekPatrick Steinhardt, Nov 4, 2024
  13. Junio C HamanoNov 5, 2024
  14. Junio C HamanoNov 5, 2024
  15. Patrick SteinhardtNov 5, 2024
  16. 8/8 refs/reftable: reuse iterators when reading refsPatrick Steinhardt, Nov 4, 2024
  17. Junio C HamanoNov 5, 2024
  18. 0/8 refs/reftable: reuse iterators when reading refsPatrick Steinhardt, Nov 5, 2024
  19. 1/8 refs/reftable: encapsulate reftable stackPatrick Steinhardt, Nov 5, 2024
  20. Junio C HamanoNov 12, 2024
  21. 2/8 refs/reftable: handle reloading stacks in the reftable backendPatrick Steinhardt, Nov 5, 2024
  22. Junio C HamanoNov 12, 2024
  23. Patrick SteinhardtNov 12, 2024
  24. 3/8 refs/reftable: read references via `struct reftable_backend`Patrick Steinhardt, Nov 5, 2024
  25. Junio C HamanoNov 12, 2024
  26. Patrick SteinhardtNov 12, 2024
  27. 4/8 refs/reftable: refactor reading symbolic refs to use reftable backendPatrick Steinhardt, Nov 5, 2024
  28. 5/8 refs/reftable: refactor reflog expiry to use reftable backendPatrick Steinhardt, Nov 5, 2024
  29. 6/8 reftable/stack: add mechanism to notify callers on reloadPatrick Steinhardt, Nov 5, 2024
  30. 7/8 reftable/merged: drain priority queue on reseekPatrick Steinhardt, Nov 5, 2024
  31. 8/8 refs/reftable: reuse iterators when reading refsPatrick Steinhardt, Nov 5, 2024
  32. 0/9 refs/reftable: reuse iterators when reading refsPatrick Steinhardt, Nov 25, 2024
  33. 1/9 refs/reftable: encapsulate reftable stackPatrick Steinhardt, Nov 25, 2024
  34. 2/9 refs/reftable: handle reloading stacks in the reftable backendPatrick Steinhardt, Nov 25, 2024
  35. Junio C HamanoNov 26, 2024
  36. 3/9 reftable/stack: add accessor for the hash IDPatrick Steinhardt, Nov 25, 2024
  37. 4/9 refs/reftable: read references via `struct reftable_backend`Patrick Steinhardt, Nov 25, 2024
  38. Junio C HamanoNov 26, 2024
  39. Patrick SteinhardtNov 26, 2024
  40. 5/9 refs/reftable: refactor reading symbolic refs to use reftable backendPatrick Steinhardt, Nov 25, 2024
  41. 6/9 refs/reftable: refactor reflog expiry to use reftable backendPatrick Steinhardt, Nov 25, 2024
  42. 7/9 reftable/stack: add mechanism to notify callers on reloadPatrick Steinhardt, Nov 25, 2024
  43. 8/9 reftable/merged: drain priority queue on reseekPatrick Steinhardt, Nov 25, 2024
  44. 9/9 refs/reftable: reuse iterators when reading refsPatrick Steinhardt, Nov 25, 2024
  45. Christian CouderNov 25, 2024
  46. Patrick SteinhardtNov 25, 2024
  47. 00/10 refs/reftable: reuse iterators when reading refsPatrick Steinhardt, Nov 26, 2024
  48. 01/10 refs/reftable: encapsulate reftable stackPatrick Steinhardt, Nov 26, 2024
  49. 03/10 reftable/stack: add accessor for the hash IDPatrick Steinhardt, Nov 26, 2024
  50. 02/10 refs/reftable: handle reloading stacks in the reftable backendPatrick Steinhardt, Nov 26, 2024
  51. 05/10 refs/reftable: read references via `struct reftable_backend`Patrick Steinhardt, Nov 26, 2024
  52. 04/10 refs/reftable: figure out hash via `reftable_stack`Patrick Steinhardt, Nov 26, 2024
  53. 06/10 refs/reftable: refactor reading symbolic refs to use reftable backendPatrick Steinhardt, Nov 26, 2024
  54. 07/10 refs/reftable: refactor reflog expiry to use reftable backendPatrick Steinhardt, Nov 26, 2024
  55. 08/10 reftable/stack: add mechanism to notify callers on reloadPatrick Steinhardt, Nov 26, 2024
  56. 09/10 reftable/merged: drain priority queue on reseekPatrick Steinhardt, Nov 26, 2024
  57. 10/10 refs/reftable: reuse iterators when reading refsPatrick Steinhardt, Nov 26, 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.