]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb/source-packed: wire up `close()` callback
authorPatrick Steinhardt <ps@pks.im>
Wed, 17 Jun 2026 06:39:49 +0000 (08:39 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Jun 2026 12:00:00 +0000 (05:00 -0700)
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 <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
odb/source-files.c
odb/source-packed.c
packfile.c
packfile.h

index 3608808e7c6f3a72ec6606cfb8065df88c06c521..9b0fa9ccdce22666bec0e988fa4d3914c0918e57 100644 (file)
@@ -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)
index f81a990cbde757689ed1767346ec919212e8547b..74805be1ddce5ec3f8bf1ba69c0dbb96c257d768 100644 (file)
@@ -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;
+}
+
 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;
 
        if (!is_absolute_path(parent->base.path))
                chdir_notify_register(NULL, odb_source_packed_reparent, packed);
index 6d492216de356a6867818fb6248e137e7fed67d8..e5386145a7835b6ddbec09bbe527e411e171f29e 100644 (file)
@@ -2749,18 +2749,6 @@ int parse_pack_header_option(const char *in, unsigned char *out, unsigned int *l
        return 0;
 }
 
-void packfile_store_close(struct odb_source_packed *store)
-{
-       for (struct packfile_list_entry *e = store->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 (store->midx)
-               close_midx(store->midx);
-       store->midx = NULL;
-}
-
 struct odb_packed_read_stream {
        struct odb_read_stream base;
        struct packed_git *pack;
index e8bc9349f8d0dc63ff150a7797272a4a7c345156..9dc3a131127d6aaeec1c7eadcbd41d4ca0bcc131 100644 (file)
@@ -55,12 +55,6 @@ struct packed_git {
        char pack_name[FLEX_ARRAY]; /* more */
 };
 
-/*
- * Close all packfiles associated with this store. The packfiles won't be
- * free'd, so they can be re-opened at a later point in time.
- */
-void packfile_store_close(struct odb_source_packed *store);
-
 /*
  * Prepare the packfile store by loading packfiles and multi-pack indices for
  * all alternates. This becomes a no-op if the store is already prepared.