]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb/source-packed: wire up `freshen_object()` callback
authorPatrick Steinhardt <ps@pks.im>
Wed, 17 Jun 2026 06:39:57 +0000 (08:39 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Jun 2026 12:00:01 +0000 (05:00 -0700)
Move `packfile_store_freshen_object()` and from "packfile.c" into
"odb/source-packed.c" and wire it up as the `freshen_object()` callback
of the "packed" source.

Note that this removes the last external caller of `find_pack_entry()`
from "packfile.c", which means that we can now make this function
static.

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
odb/source-packed.h
packfile.c
packfile.h

index 8ad782dc7be4543c89a2f21627ad1628f592fa5d..fa2e18e71b3cf6579d12fbf775978316c270e7ec 100644 (file)
@@ -152,7 +152,7 @@ static int odb_source_files_freshen_object(struct odb_source *source,
                                           const struct object_id *oid)
 {
        struct odb_source_files *files = odb_source_files_downcast(source);
-       if (packfile_store_freshen_object(files->packed, oid) ||
+       if (odb_source_freshen_object(&files->packed->base, oid) ||
            odb_source_freshen_object(&files->loose->base, oid))
                return 1;
        return 0;
index b801b620236f9ef715404896172361f110f39a4d..e40b52e445c57c425d11cbb59379a3adcf53d63b 100644 (file)
@@ -9,9 +9,9 @@
 #include "odb/streaming.h"
 #include "packfile.h"
 
-int find_pack_entry(struct odb_source_packed *store,
-                   const struct object_id *oid,
-                   struct pack_entry *e)
+static int find_pack_entry(struct odb_source_packed *store,
+                          const struct object_id *oid,
+                          struct pack_entry *e)
 {
        struct packfile_list_entry *l;
 
@@ -482,6 +482,25 @@ static int odb_source_packed_find_abbrev_len(struct odb_source *source,
        return 0;
 }
 
+static int odb_source_packed_freshen_object(struct odb_source *source,
+                                           const struct object_id *oid)
+{
+       struct odb_source_packed *packed = odb_source_packed_downcast(source);
+       struct pack_entry e;
+
+       if (!find_pack_entry(packed, oid, &e))
+               return 0;
+       if (e.p->is_cruft)
+               return 0;
+       if (e.p->freshened)
+               return 1;
+       if (utime(e.p->pack_name, NULL))
+               return 0;
+       e.p->freshened = 1;
+
+       return 1;
+}
+
 void (*report_garbage)(unsigned seen_bits, const char *path);
 
 static void report_helper(const struct string_list *list,
@@ -695,6 +714,7 @@ struct odb_source_packed *odb_source_packed_new(struct odb_source_files *parent)
        packed->base.for_each_object = odb_source_packed_for_each_object;
        packed->base.count_objects = odb_source_packed_count_objects;
        packed->base.find_abbrev_len = odb_source_packed_find_abbrev_len;
+       packed->base.freshen_object = odb_source_packed_freshen_object;
 
        if (!is_absolute_path(parent->base.path))
                chdir_notify_register(NULL, odb_source_packed_reparent, packed);
index f430ee0b9466bd93d38992c2c7da696a8b60b715..9d4796261a72d3dfecae9d3ac3ac6ed579ce85a5 100644 (file)
@@ -90,10 +90,4 @@ static inline struct odb_source_packed *odb_source_packed_downcast(struct odb_so
  */
 void odb_source_packed_prepare(struct odb_source_packed *source);
 
-struct pack_entry;
-
-int find_pack_entry(struct odb_source_packed *store,
-                   const struct object_id *oid,
-                   struct pack_entry *e);
-
 #endif
index 7f84094e536886ac0e94cbcc6af422a371ea496c..a577275d4f334e4e803cb7ee926afe5efbe1fc22 100644 (file)
@@ -1892,22 +1892,6 @@ int packfile_fill_entry(struct packed_git *p,
        return 1;
 }
 
-int packfile_store_freshen_object(struct odb_source_packed *store,
-                                 const struct object_id *oid)
-{
-       struct pack_entry e;
-       if (!find_pack_entry(store, oid, &e))
-               return 0;
-       if (e.p->is_cruft)
-               return 0;
-       if (e.p->freshened)
-               return 1;
-       if (utime(e.p->pack_name, NULL))
-               return 0;
-       e.p->freshened = 1;
-       return 1;
-}
-
 static void maybe_invalidate_kept_pack_cache(struct odb_source_packed *store,
                                             unsigned flags)
 {
index 79324e4010632b942be65acaa77ba059b85e2730..71a71017ee1058443902369a181e1e7732ae0454 100644 (file)
@@ -132,9 +132,6 @@ static inline void repo_for_each_pack_data_next(struct repo_for_each_pack_data *
 struct packed_git *packfile_store_load_pack(struct odb_source_packed *store,
                                            const char *idx_path, int local);
 
-int packfile_store_freshen_object(struct odb_source_packed *store,
-                                 const struct object_id *oid);
-
 enum kept_pack_type {
        KEPT_PACK_ON_DISK = (1 << 0),
        KEPT_PACK_IN_CORE = (1 << 1),