From: Patrick Steinhardt Date: Wed, 17 Jun 2026 06:39:57 +0000 (+0200) Subject: odb/source-packed: wire up `freshen_object()` callback X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98189bdd0a789115e3bb5ec5d5312ce71d6f59b0;p=thirdparty%2Fgit.git odb/source-packed: wire up `freshen_object()` callback 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 Signed-off-by: Junio C Hamano --- diff --git a/odb/source-files.c b/odb/source-files.c index 8ad782dc7b..fa2e18e71b 100644 --- a/odb/source-files.c +++ b/odb/source-files.c @@ -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; diff --git a/odb/source-packed.c b/odb/source-packed.c index b801b62023..e40b52e445 100644 --- a/odb/source-packed.c +++ b/odb/source-packed.c @@ -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); diff --git a/odb/source-packed.h b/odb/source-packed.h index f430ee0b94..9d4796261a 100644 --- a/odb/source-packed.h +++ b/odb/source-packed.h @@ -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 diff --git a/packfile.c b/packfile.c index 7f84094e53..a577275d4f 100644 --- a/packfile.c +++ b/packfile.c @@ -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) { diff --git a/packfile.h b/packfile.h index 79324e4010..71a71017ee 100644 --- a/packfile.h +++ b/packfile.h @@ -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),