From: Patrick Steinhardt Date: Mon, 1 Jun 2026 08:20:35 +0000 (+0200) Subject: odb/source-loose: wire up `freshen_object()` callback X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=d8b9e8bb23ece128179ad54ed5ecbcd4bd809b1e;p=thirdparty%2Fgit.git odb/source-loose: wire up `freshen_object()` callback Move `odb_source_loose_freshen_object()` from "object-file.c" into "odb/source-loose.c" and wire it up as the `freshen_object()` callback of the loose source. As part of the move, `check_and_freshen_source()` is inlined into the callback function, as it has no other callers anymore. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- diff --git a/object-file.c b/object-file.c index c83136cf70..0689a4e67b 100644 --- a/object-file.c +++ b/object-file.c @@ -87,15 +87,6 @@ int check_and_freshen_file(const char *fn, int freshen) return 1; } -static int check_and_freshen_source(struct odb_source *source, - const struct object_id *oid, - int freshen) -{ - static struct strbuf path = STRBUF_INIT; - odb_loose_path(source, &path, oid); - return check_and_freshen_file(path.buf, freshen); -} - int format_object_header(char *str, size_t size, enum object_type type, size_t objsize) { @@ -815,12 +806,6 @@ static int write_loose_object(struct odb_source *source, FOF_SKIP_COLLISION_CHECK); } -int odb_source_loose_freshen_object(struct odb_source *source, - const struct object_id *oid) -{ - return !!check_and_freshen_source(source, oid, 1); -} - int odb_source_loose_write_stream(struct odb_source *source, struct odb_write_stream *in_stream, size_t len, struct object_id *oid) diff --git a/object-file.h b/object-file.h index 506ca6be40..1d90df9d98 100644 --- a/object-file.h +++ b/object-file.h @@ -23,9 +23,6 @@ int index_path(struct index_state *istate, struct object_id *oid, const char *pa struct object_info; struct odb_source; -int odb_source_loose_freshen_object(struct odb_source *source, - const struct object_id *oid); - int odb_source_loose_write_object(struct odb_source *source, const void *buf, unsigned long len, enum object_type type, struct object_id *oid, diff --git a/odb/source-files.c b/odb/source-files.c index d5454e170d..ef548e6fe6 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, { struct odb_source_files *files = odb_source_files_downcast(source); if (packfile_store_freshen_object(files->packed, oid) || - odb_source_loose_freshen_object(source, oid)) + odb_source_freshen_object(&files->loose->base, oid)) return 1; return 0; } diff --git a/odb/source-loose.c b/odb/source-loose.c index 27be066327..e519365d23 100644 --- a/odb/source-loose.c +++ b/odb/source-loose.c @@ -580,6 +580,14 @@ out: return ret; } +static int odb_source_loose_freshen_object(struct odb_source *source, + const struct object_id *oid) +{ + static struct strbuf path = STRBUF_INIT; + odb_loose_path(source, &path, oid); + return !!check_and_freshen_file(path.buf, 1); +} + static void odb_source_loose_clear_cache(struct odb_source_loose *loose) { oidtree_clear(loose->cache); @@ -638,6 +646,7 @@ struct odb_source_loose *odb_source_loose_new(struct odb_source_files *files) loose->base.for_each_object = odb_source_loose_for_each_object; loose->base.find_abbrev_len = odb_source_loose_find_abbrev_len; loose->base.count_objects = odb_source_loose_count_objects; + loose->base.freshen_object = odb_source_loose_freshen_object; if (!is_absolute_path(loose->base.path)) chdir_notify_register(NULL, odb_source_loose_reparent, loose);