aboutsummaryrefslogtreecommitdiffstats
path: root/object-store.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-07-01 14:22:14 +0200
committerJunio C Hamano <gitster@pobox.com>2025-07-01 14:46:34 -0700
commita1e2581a1e9ca2a85ae0a018ba5fb8fe5db3c322 (patch)
tree8443c60b4d56d958eef875e53afa3a33c9643d37 /object-store.h
parent1ace06644926bcf1f05e291e8a9476c977c25eeb (diff)
downloadgit-a1e2581a1e9ca2a85ae0a018ba5fb8fe5db3c322.tar.gz
object-store: rename `object_directory` to `odb_source`
The `object_directory` structure is used as an access point for a single object directory like ".git/objects". While the structure isn't yet fully self-contained, the intent is for it to eventually contain all information required to access objects in one specific location. While the name "object directory" is a good fit for now, this will change over time as we continue with the agenda to make pluggable object databases a thing. Eventually, objects may not be accessed via any kind of directory at all anymore, but they could instead be backed by any kind of durable storage mechanism. While it seems quite far-fetched for now, it is thinkable that eventually this might even be some form of a database, for example. As such, the current name of this structure will become worse over time as we evolve into the direction of pluggable ODBs. Immediate next steps will start to carve out proper self-contained object directories, which requires us to pass in these object directories as parameters. Based on our modern naming schema this means that those functions should then be named after their subsystem, which means that we would start to bake the current name into the codebase more and more. Let's preempt this by renaming the structure. There have been a couple alternatives that were discussed: - `odb_backend` was discarded because it led to the association that one object database has a single backend, but the model is that one alternate has one backend. Furthermore, "backend" is more about the actual backing implementation and less about the high-level concept. - `odb_alternate` was discarded because it is a bit of a stretch to also call the main object directory an "alternate". Instead, pick `odb_source` as the new name. It makes it sufficiently clear that there can be multiple sources and does not cause confusion when mixed with the already-existing "alternate" terminology. In the future, this change allows us to easily introduce for example a `odb_files_source` and other format-specific implementations. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-store.h')
-rw-r--r--object-store.h38
1 files changed, 25 insertions, 13 deletions
diff --git a/object-store.h b/object-store.h
index a3be27d117..d199d757d7 100644
--- a/object-store.h
+++ b/object-store.h
@@ -13,8 +13,20 @@ struct oidtree;
struct strbuf;
struct repository;
-struct object_directory {
- struct object_directory *next;
+/*
+ * The source is the part of the object database that stores the actual
+ * objects. It thus encapsulates the logic to read and write the specific
+ * on-disk format. An object database can have multiple sources:
+ *
+ * - The primary source, which is typically located in "$GIT_DIR/objects".
+ * This is where new objects are usually written to.
+ *
+ * - Alternate sources, which are configured via "objects/info/alternates" or
+ * via the GIT_ALTERNATE_OBJECT_DIRECTORIES environment variable. These
+ * alternate sources are only used to read objects.
+ */
+struct odb_source {
+ struct odb_source *next;
/*
* Used to store the results of readdir(3) calls when we are OK
@@ -44,8 +56,8 @@ struct object_directory {
int will_destroy;
/*
- * Path to the alternative object store. If this is a relative path,
- * it is relative to the current working directory.
+ * Path to the source. If this is a relative path, it is relative to
+ * the current working directory.
*/
char *path;
};
@@ -53,8 +65,8 @@ struct object_directory {
void prepare_alt_odb(struct repository *r);
int has_alt_odb(struct repository *r);
char *compute_alternate_path(const char *path, struct strbuf *err);
-struct object_directory *find_odb(struct repository *r, const char *obj_dir);
-typedef int alt_odb_fn(struct object_directory *, void *);
+struct odb_source *find_odb(struct repository *r, const char *obj_dir);
+typedef int alt_odb_fn(struct odb_source *, void *);
int foreach_alt_odb(alt_odb_fn, void*);
typedef void alternate_ref_fn(const struct object_id *oid, void *);
void for_each_alternate_ref(alternate_ref_fn, void *);
@@ -76,12 +88,12 @@ void add_to_alternates_memory(const char *dir);
* Replace the current writable object directory with the specified temporary
* object directory; returns the former primary object directory.
*/
-struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy);
+struct odb_source *set_temporary_primary_odb(const char *dir, int will_destroy);
/*
* Restore a previous ODB replaced by set_temporary_main_odb.
*/
-void restore_primary_odb(struct object_directory *restore_odb, const char *old_path);
+void restore_primary_odb(struct odb_source *restore_alternate, const char *old_path);
struct packed_git;
struct multi_pack_index;
@@ -89,7 +101,7 @@ struct cached_object_entry;
/*
* The object database encapsulates access to objects in a repository. It
- * manages one or more backends that store the actual objects which are
+ * manages one or more sources that store the actual objects which are
* configured via alternates.
*/
struct object_database {
@@ -98,16 +110,16 @@ struct object_database {
* cannot be NULL after initialization). Subsequent directories are
* alternates.
*/
- struct object_directory *odb;
- struct object_directory **odb_tail;
- struct kh_odb_path_map *odb_by_path;
+ struct odb_source *sources;
+ struct odb_source **sources_tail;
+ struct kh_odb_path_map *source_by_path;
int loaded_alternates;
/*
* A list of alternate object directories loaded from the environment;
* this should not generally need to be accessed directly, but will
- * populate the "odb" list when prepare_alt_odb() is run.
+ * populate the "sources" list when prepare_alt_odb() is run.
*/
char *alternate_db;