]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb/source-loose: wire up `freshen_object()` callback
authorPatrick Steinhardt <ps@pks.im>
Thu, 21 May 2026 08:22:32 +0000 (10:22 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 May 2026 13:35:19 +0000 (22:35 +0900)
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 <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object-file.c
object-file.h
odb/source-files.c
odb/source-loose.c

index c83136cf70024c5a3e3d186e02d9626486a025dd..0689a4e67b156a1cddd2425af9cc9de41095f5b0 100644 (file)
@@ -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)
index 506ca6be40b7499e0a1d6d1d5bf7d06eb8fd3e1f..1d90df9d98b78e3a5b7dbb9b97db2a23d2244707 100644 (file)
@@ -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,
index d5454e170dee664830786bb33da56da56a562352..ef548e6fe69cd0c7d9f2b155821589c118f60eb8 100644 (file)
@@ -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;
 }
index 27be066327a3138d8619b6ad1168dc1cfb655b67..e519365d23f6809828dadf313e7672957a787798 100644 (file)
@@ -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);