LIB_OBJS += odb/source.o
LIB_OBJS += odb/source-files.o
LIB_OBJS += odb/streaming.o
+LIB_OBJS += odb/transaction.o
LIB_OBJS += oid-array.o
LIB_OBJS += oidmap.o
LIB_OBJS += oidset.o
#include "run-command.h"
#include "object-file.h"
#include "odb.h"
+#include "odb/transaction.h"
#include "parse-options.h"
#include "path.h"
#include "preload-index.h"
#include "hex.h"
#include "object-file.h"
#include "odb.h"
+#include "odb/transaction.h"
#include "object.h"
#include "delta.h"
#include "pack.h"
#include "tree-walk.h"
#include "object-file.h"
#include "odb.h"
+#include "odb/transaction.h"
#include "refs.h"
#include "resolve-undo.h"
#include "parse-options.h"
#include "cache-tree.h"
#include "object-file.h"
#include "odb.h"
+#include "odb/transaction.h"
#include "read-cache-ll.h"
#include "replace-object.h"
#include "repository.h"
'odb/source.c',
'odb/source-files.c',
'odb/streaming.c',
+ 'odb/transaction.c',
'oid-array.c',
'oidmap.c',
'oidset.c',
#include "object-file.h"
#include "odb.h"
#include "odb/streaming.h"
+#include "odb/transaction.h"
#include "oidtree.h"
#include "pack.h"
#include "packfile.h"
obj_read_unlock();
}
-
-struct odb_transaction *odb_transaction_begin(struct object_database *odb)
-{
- if (odb->transaction)
- return NULL;
-
- odb->transaction = odb_transaction_files_begin(odb->sources);
-
- return odb->transaction;
-}
-
-void odb_transaction_commit(struct odb_transaction *transaction)
-{
- if (!transaction)
- return;
-
- /*
- * Ensure the transaction ending matches the pending transaction.
- */
- ASSERT(transaction == transaction->source->odb->transaction);
-
- transaction->commit(transaction);
- transaction->source->odb->transaction = NULL;
- free(transaction);
-}
struct packfile_store;
struct cached_object_entry;
-/*
- * A transaction may be started for an object database prior to writing new
- * objects via odb_transaction_begin(). These objects are not committed until
- * odb_transaction_commit() is invoked. Only a single transaction may be pending
- * at a time.
- *
- * Each ODB source is expected to implement its own transaction handling.
- */
-struct odb_transaction;
-typedef void (*odb_transaction_commit_fn)(struct odb_transaction *transaction);
-struct odb_transaction {
- /* The ODB source the transaction is opened against. */
- struct odb_source *source;
-
- /* The ODB source specific callback invoked to commit a transaction. */
- odb_transaction_commit_fn commit;
-};
-
/*
* The object database encapsulates access to objects in a repository. It
* manages one or more sources that store the actual objects which are
*/
void odb_reprepare(struct object_database *o);
-/*
- * Starts an ODB transaction. Subsequent objects are written to the transaction
- * and not committed until odb_transaction_commit() is invoked on the
- * transaction. If the ODB already has a pending transaction, NULL is returned.
- */
-struct odb_transaction *odb_transaction_begin(struct object_database *odb);
-
-/*
- * Commits an ODB transaction making the written objects visible. If the
- * specified transaction is NULL, the function is a no-op.
- */
-void odb_transaction_commit(struct odb_transaction *transaction);
-
/*
* Find source by its object directory path. Returns a `NULL` pointer in case
* the source could not be found.
--- /dev/null
+#include "git-compat-util.h"
+#include "object-file.h"
+#include "odb/transaction.h"
+
+struct odb_transaction *odb_transaction_begin(struct object_database *odb)
+{
+ if (odb->transaction)
+ return NULL;
+
+ odb->transaction = odb_transaction_files_begin(odb->sources);
+
+ return odb->transaction;
+}
+
+void odb_transaction_commit(struct odb_transaction *transaction)
+{
+ if (!transaction)
+ return;
+
+ /*
+ * Ensure the transaction ending matches the pending transaction.
+ */
+ ASSERT(transaction == transaction->source->odb->transaction);
+
+ transaction->commit(transaction);
+ transaction->source->odb->transaction = NULL;
+ free(transaction);
+}
--- /dev/null
+#ifndef ODB_TRANSACTION_H
+#define ODB_TRANSACTION_H
+
+#include "odb.h"
+#include "odb/source.h"
+
+/*
+ * A transaction may be started for an object database prior to writing new
+ * objects via odb_transaction_begin(). These objects are not committed until
+ * odb_transaction_commit() is invoked. Only a single transaction may be pending
+ * at a time.
+ *
+ * Each ODB source is expected to implement its own transaction handling.
+ */
+struct odb_transaction;
+typedef void (*odb_transaction_commit_fn)(struct odb_transaction *transaction);
+struct odb_transaction {
+ /* The ODB source the transaction is opened against. */
+ struct odb_source *source;
+
+ /* The ODB source specific callback invoked to commit a transaction. */
+ odb_transaction_commit_fn commit;
+};
+
+/*
+ * Starts an ODB transaction. Subsequent objects are written to the transaction
+ * and not committed until odb_transaction_commit() is invoked on the
+ * transaction. If the ODB already has a pending transaction, NULL is returned.
+ */
+struct odb_transaction *odb_transaction_begin(struct object_database *odb);
+
+/*
+ * Commits an ODB transaction making the written objects visible. If the
+ * specified transaction is NULL, the function is a no-op.
+ */
+void odb_transaction_commit(struct odb_transaction *transaction);
+
+#endif
#include "dir.h"
#include "object-file.h"
#include "odb.h"
+#include "odb/transaction.h"
#include "oid-array.h"
#include "tree.h"
#include "commit.h"