]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb/source-loose: move loose source into "odb/" subsystem
authorPatrick Steinhardt <ps@pks.im>
Thu, 21 May 2026 08:22:21 +0000 (10:22 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 May 2026 13:35:18 +0000 (22:35 +0900)
In subsequent patches we'll be turning `struct odb_source_loose` into a
proper `struct odb_source`. As a first step towards this goal, move its
struct out of "object-file.c" and into "odb/source-loose.c".

This detaches the implementation of the loose object source from the
generic object file code, following the same convention already used by
the "files" and "in-memory" sources.

No functional changes are intended.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
meson.build
object-file.c
object-file.h
odb/source-loose.c [new file with mode: 0644]
odb/source-loose.h [new file with mode: 0644]

index a43b8ee0674df811cfd43ecefe029ead088c4837..01356235c3e11d8a35209a6b102f63bbd3d66df5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1217,6 +1217,7 @@ LIB_OBJS += odb.o
 LIB_OBJS += odb/source.o
 LIB_OBJS += odb/source-files.o
 LIB_OBJS += odb/source-inmemory.o
+LIB_OBJS += odb/source-loose.o
 LIB_OBJS += odb/streaming.o
 LIB_OBJS += odb/transaction.o
 LIB_OBJS += oid-array.o
index 664d8313295a2660e7439b9fa5c26313d6cdb1de..c85e5988351b1fa29c88905fbcb0e94618dd0324 100644 (file)
@@ -405,6 +405,7 @@ libgit_sources = [
   'odb/source.c',
   'odb/source-files.c',
   'odb/source-inmemory.c',
+  'odb/source-loose.c',
   'odb/streaming.c',
   'odb/transaction.c',
   'oid-array.c',
index 90f995d0000bf67d2a6756e6c50251997afe3831..641bd9c0799dec10bd2e998112395f87d68ccb69 100644 (file)
@@ -2205,14 +2205,6 @@ struct odb_transaction *odb_transaction_files_begin(struct odb_source *source)
        return &transaction->base;
 }
 
-struct odb_source_loose *odb_source_loose_new(struct odb_source *source)
-{
-       struct odb_source_loose *loose;
-       CALLOC_ARRAY(loose, 1);
-       loose->source = source;
-       return loose;
-}
-
 void odb_source_loose_free(struct odb_source_loose *loose)
 {
        if (!loose)
index 5241b8dd5c564da6cbb3deda8af9f4b4386edbfb..1d8312cf7f9ff91e05f758bc7a1c89c37516f42f 100644 (file)
@@ -4,6 +4,7 @@
 #include "git-zlib.h"
 #include "object.h"
 #include "odb.h"
+#include "odb/source-loose.h"
 
 struct index_state;
 
@@ -20,26 +21,6 @@ struct object_info;
 struct odb_read_stream;
 struct odb_source;
 
-struct odb_source_loose {
-       struct odb_source *source;
-
-       /*
-        * Used to store the results of readdir(3) calls when we are OK
-        * sacrificing accuracy due to races for speed. That includes
-        * object existence with OBJECT_INFO_QUICK, as well as
-        * our search for unique abbreviated hashes. Don't use it for tasks
-        * requiring greater accuracy!
-        *
-        * Be sure to call odb_load_loose_cache() before using.
-        */
-       uint32_t subdir_seen[8]; /* 256 bits */
-       struct oidtree *cache;
-
-       /* Map between object IDs for loose objects. */
-       struct loose_object_map *map;
-};
-
-struct odb_source_loose *odb_source_loose_new(struct odb_source *source);
 void odb_source_loose_free(struct odb_source_loose *loose);
 
 /* Reprepare the loose source by emptying the loose object cache. */
diff --git a/odb/source-loose.c b/odb/source-loose.c
new file mode 100644 (file)
index 0000000..b944d21
--- /dev/null
@@ -0,0 +1,10 @@
+#include "git-compat-util.h"
+#include "odb/source-loose.h"
+
+struct odb_source_loose *odb_source_loose_new(struct odb_source *source)
+{
+       struct odb_source_loose *loose;
+       CALLOC_ARRAY(loose, 1);
+       loose->source = source;
+       return loose;
+}
diff --git a/odb/source-loose.h b/odb/source-loose.h
new file mode 100644 (file)
index 0000000..8b4bac7
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef ODB_SOURCE_LOOSE_H
+#define ODB_SOURCE_LOOSE_H
+
+#include "odb/source.h"
+
+struct object_database;
+struct oidtree;
+
+/*
+ * An object database source that stores its objects in loose format, one
+ * file per object. This source is part of the files source.
+ */
+struct odb_source_loose {
+       struct odb_source *source;
+
+       /*
+        * Used to store the results of readdir(3) calls when we are OK
+        * sacrificing accuracy due to races for speed. That includes
+        * object existence with OBJECT_INFO_QUICK, as well as
+        * our search for unique abbreviated hashes. Don't use it for tasks
+        * requiring greater accuracy!
+        *
+        * Be sure to call odb_load_loose_cache() before using.
+        */
+       uint32_t subdir_seen[8]; /* 256 bits */
+       struct oidtree *cache;
+
+       /* Map between object IDs for loose objects. */
+       struct loose_object_map *map;
+};
+
+struct odb_source_loose *odb_source_loose_new(struct odb_source *source);
+
+#endif