Re: [PATCH 05/16] odb/source-packed: wire up `close()` callback
From: Karthik Nayak <hidden>
Date: 2026-06-08 15:31:24
Patrick Steinhardt [off-list ref] writes:
quoted hunk ↗ jump to hunk
Wire up a new `close()` callback for the packed source and call it from the "files" source via the generic `odb_source_close()` interface. Signed-off-by: Patrick Steinhardt <redacted> --- odb/source-files.c | 2 +- odb/source-packed.c | 16 ++++++++++++++++ packfile.c | 12 ------------ packfile.h | 6 ------ 4 files changed, 17 insertions(+), 19 deletions(-)diff --git a/odb/source-files.c b/odb/source-files.c index 3608808e7c..9b0fa9ccdc 100644 --- a/odb/source-files.c +++ b/odb/source-files.c@@ -38,7 +38,7 @@ static void odb_source_files_close(struct odb_source *source) { struct odb_source_files *files = odb_source_files_downcast(source); odb_source_close(&files->loose->base); - packfile_store_close(files->packed); + odb_source_close(&files->packed->base); } static void odb_source_files_reprepare(struct odb_source *source)diff --git a/odb/source-packed.c b/odb/source-packed.c index f81a990cbd..74805be1dd 100644 --- a/odb/source-packed.c +++ b/odb/source-packed.c@@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "abspath.h" #include "chdir-notify.h" +#include "midx.h" #include "odb/source-packed.h" #include "packfile.h"@@ -16,6 +17,20 @@ static void odb_source_packed_reparent(const char *name UNUSED, packed->base.path = path; } +static void odb_source_packed_close(struct odb_source *source) +{ + struct odb_source_packed *packed = odb_source_packed_downcast(source); + + for (struct packfile_list_entry *e = packed->packs.head; e; e = e->next) { + if (e->pack->do_not_close) + BUG("want to close pack marked 'do-not-close'"); + close_pack(e->pack); + } + if (packed->midx) + close_midx(packed->midx); + packed->midx = NULL; +} +
Most of my ODB understandings is coming from reviewing your patches. But I really like how we can map the current workings to the ODB interface.
quoted hunk ↗ jump to hunk
static void odb_source_packed_free(struct odb_source *source) { struct odb_source_packed *packed = odb_source_packed_downcast(source);@@ -42,6 +57,7 @@ struct odb_source_packed *odb_source_packed_new(struct odb_source_files *parent) strmap_init(&packed->packs_by_path); packed->base.free = odb_source_packed_free; + packed->base.close = odb_source_packed_close;
This is what I mean :) [snip]
Attachments
- signature.asc [application/pgp-signature] 690 bytes