Thread (24 messages) 24 messages, 2 authors, 2024-05-17

Re: [PATCH 03/16] refs: implement releasing ref storages

From: Patrick Steinhardt <hidden>
Date: 2024-05-17 07:08:59

On Thu, May 16, 2024 at 11:39:36AM -0500, Karthik Nayak wrote:
Patrick Steinhardt [off-list ref] writes:

[snip]
quoted
diff --git a/refs/debug.c b/refs/debug.c
index 58fb4557ed..27aae42134 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -33,6 +33,12 @@ struct ref_store *maybe_debug_wrap_ref_store(const char *gitdir, struct ref_stor
 	return (struct ref_store *)res;
 }

+static void debug_release(struct ref_store *refs)
+{
+	struct debug_ref_store *drefs = (struct debug_ref_store *)refs;
We should probably add a trace here, using `trace_printf_key()`
I didn't because we don't have `debug_init()` with a trace, either, and
because there is no error code that we could report. But on the other
hand it does not hurt to have it here, so let's just add it.

[snip]
quoted
diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
index a4bb71cd76..6c262c2193 100644
--- a/refs/reftable-backend.c
+++ b/refs/reftable-backend.c
@@ -293,6 +293,27 @@ static struct ref_store *reftable_be_init(struct repository *repo,
 	return &refs->base;
 }

+static void reftable_be_release(struct ref_store *ref_store)
+{
+	struct reftable_ref_store *refs = reftable_be_downcast(ref_store, 0, "release");
+	struct strmap_entry *entry;
+	struct hashmap_iter iter;
+
+	if (refs->main_stack) {
+		reftable_stack_destroy(refs->main_stack);
+		refs->main_stack = NULL;
+	}
+
+	if (refs->worktree_stack) {
+		reftable_stack_destroy(refs->worktree_stack);
+		refs->main_stack = NULL;
This should be `refs->worktree_stack`, right?
Good catch, yes.

Patrick

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help