aboutsummaryrefslogtreecommitdiff
path: root/odb/source-files.h
diff options
context:
space:
mode:
Diffstat (limited to 'odb/source-files.h')
-rw-r--r--odb/source-files.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/odb/source-files.h b/odb/source-files.h
new file mode 100644
index 0000000000..23a3b4e04b
--- /dev/null
+++ b/odb/source-files.h
@@ -0,0 +1,35 @@
+#ifndef ODB_SOURCE_FILES_H
+#define ODB_SOURCE_FILES_H
+
+#include "odb/source.h"
+
+struct odb_source_loose;
+struct packfile_store;
+
+/*
+ * The files object database source uses a combination of loose objects and
+ * packfiles. It is the default backend used by Git to store objects.
+ */
+struct odb_source_files {
+ struct odb_source base;
+ struct odb_source_loose *loose;
+ struct packfile_store *packed;
+};
+
+/* Allocate and initialize a new object source. */
+struct odb_source_files *odb_source_files_new(struct object_database *odb,
+ const char *path,
+ bool local);
+
+/*
+ * Cast the given object database source to the files backend. This will cause
+ * a BUG in case the source doesn't use this backend.
+ */
+static inline struct odb_source_files *odb_source_files_downcast(struct odb_source *source)
+{
+ if (source->type != ODB_SOURCE_FILES)
+ BUG("trying to downcast source of type '%d' to files", source->type);
+ return container_of(source, struct odb_source_files, base);
+}
+
+#endif