]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb/source-loose: wire up `reprepare()` callback
authorPatrick Steinhardt <ps@pks.im>
Thu, 21 May 2026 08:22:24 +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_reprepare()` from "object-file.c" into
"odb/source-loose.c" and wire it up as the `reprepare()` callback of the
loose source.

While at it, make `odb_source_loose_clear_cache()` static, as it is no
longer needed outside of its file.

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
odb/source-loose.h

index 977d959d3331669cafce8226f436cba10dd4bb85..0f4f1e7bdc0733c48bb2b14024a8de0073c0a603 100644 (file)
@@ -2041,12 +2041,6 @@ static struct oidtree *odb_source_loose_cache(struct odb_source *source,
        return files->loose->cache;
 }
 
-void odb_source_loose_reprepare(struct odb_source *source)
-{
-       struct odb_source_files *files = odb_source_files_downcast(source);
-       odb_source_loose_clear_cache(files->loose);
-}
-
 static int check_stream_oid(git_zstream *stream,
                            const char *hdr,
                            unsigned long size,
index 02c9680980ab0f9eed70192e53455991403e22a9..420a0fff2e7d7eb25029a686d2cbbbf99eeac3a3 100644 (file)
@@ -21,9 +21,6 @@ struct object_info;
 struct odb_read_stream;
 struct odb_source;
 
-/* Reprepare the loose source by emptying the loose object cache. */
-void odb_source_loose_reprepare(struct odb_source *source);
-
 int odb_source_loose_read_object_info(struct odb_source *source,
                                      const struct object_id *oid,
                                      struct object_info *oi,
index ccc637311b9c213405ef7bce3e708a960b0d2ccb..10832e81e4e206f8479b45761cb9e60637c05d62 100644 (file)
@@ -42,7 +42,7 @@ static void odb_source_files_close(struct odb_source *source)
 static void odb_source_files_reprepare(struct odb_source *source)
 {
        struct odb_source_files *files = odb_source_files_downcast(source);
-       odb_source_loose_reprepare(&files->base);
+       odb_source_reprepare(&files->loose->base);
        packfile_store_reprepare(files->packed);
 }
 
index 92e18f5adb2b89067c79136ac44f6192a9710b61..e0fe0d513d253222f76c32158ef134f826a380f3 100644 (file)
@@ -7,7 +7,7 @@
 #include "odb/source-loose.h"
 #include "oidtree.h"
 
-void odb_source_loose_clear_cache(struct odb_source_loose *loose)
+static void odb_source_loose_clear_cache(struct odb_source_loose *loose)
 {
        oidtree_clear(loose->cache);
        FREE_AND_NULL(loose->cache);
@@ -15,6 +15,12 @@ void odb_source_loose_clear_cache(struct odb_source_loose *loose)
               sizeof(loose->subdir_seen));
 }
 
+static void odb_source_loose_reprepare(struct odb_source *source)
+{
+       struct odb_source_loose *loose = odb_source_loose_downcast(source);
+       odb_source_loose_clear_cache(loose);
+}
+
 static void odb_source_loose_reparent(const char *name UNUSED,
                                      const char *old_cwd,
                                      const char *new_cwd,
@@ -47,6 +53,7 @@ struct odb_source_loose *odb_source_loose_new(struct odb_source_files *files)
        loose->files = files;
 
        loose->base.free = odb_source_loose_free;
+       loose->base.reprepare = odb_source_loose_reprepare;
 
        if (!is_absolute_path(loose->base.path))
                chdir_notify_register(NULL, odb_source_loose_reparent, loose);
index 441da9e41882aab365a1c76fb10aab326c19f90d..825e7030724ac1ef7589954983c8688ca74a221e 100644 (file)
@@ -44,6 +44,4 @@ static inline struct odb_source_loose *odb_source_loose_downcast(struct odb_sour
        return container_of(source, struct odb_source_loose, base);
 }
 
-void odb_source_loose_clear_cache(struct odb_source_loose *loose);
-
 #endif