summaryrefslogtreecommitdiff
path: root/src/refdb.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-06-28 06:39:38 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2014-09-30 15:44:32 +0200
commitab8d9242f54e2c570f86a45a509b9420911a4d44 (patch)
tree6070f721e7e93982a0fe37882e5700de5c1186a9 /src/refdb.c
parentbdeb8772fe846eeeea92cb2d9adb85315f3b8417 (diff)
downloadlibgit2-ab8d9242f54e2c570f86a45a509b9420911a4d44.tar.gz
Introduce reference transactions
A transaction allows you to lock multiple references and set up changes for them before applying the changes all at once (or as close as the backend supports). This can be used for replication purposes, or for making sure some operations run when the reference is locked and thus cannot be changed.
Diffstat (limited to 'src/refdb.c')
-rw-r--r--src/refdb.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/refdb.c b/src/refdb.c
index 69bf74734..16fb519a6 100644
--- a/src/refdb.c
+++ b/src/refdb.c
@@ -242,3 +242,22 @@ int git_refdb_init_backend(git_refdb_backend *backend, unsigned int version)
backend, version, git_refdb_backend, GIT_REFDB_BACKEND_INIT);
return 0;
}
+
+int git_refdb_lock(void **payload, git_refdb *db, const char *refname)
+{
+ assert(payload && db && refname);
+
+ if (!db->backend->lock) {
+ giterr_set(GITERR_REFERENCE, "backend does not support locking");
+ return -1;
+ }
+
+ return db->backend->lock(payload, db->backend, refname);
+}
+
+int git_refdb_unlock(git_refdb *db, void *payload, int success, int update_reflog, const git_reference *ref, const git_signature *sig, const char *message)
+{
+ assert(db);
+
+ return db->backend->unlock(db->backend, payload, success, update_reflog, ref, sig, message);
+}