Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-06-01 21:02:23 +0300
committerCarlos Martín Nieto <cmn@dwim.me>2015-08-12 05:09:38 +0300
commit36f784b538c4b27f7b52427d2cfce06c535abba0 (patch)
treecea0d9dd8e9807e30583ba54c5aa2e58c6c14fe2 /include
parentb1667039640ba3464ea0e2d13ad28c9244d80b4d (diff)
config: expose locking via the main API
This lock/unlock pair allows for the cller to lock a configuration file to avoid concurrent operations. It also allows for a transactional approach to updating a configuration file. If multiple updates must be made atomically, they can be done while the config is locked.
Diffstat (limited to 'include')
-rw-r--r--include/git2/config.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/git2/config.h b/include/git2/config.h
index 6d3fdb0c2..2550f8edb 100644
--- a/include/git2/config.h
+++ b/include/git2/config.h
@@ -689,6 +689,33 @@ GIT_EXTERN(int) git_config_backend_foreach_match(
void *payload);
+/**
+ * Lock the backend with the highest priority
+ *
+ * Locking disallows anybody else from writing to that backend. Any
+ * updates made after locking will not be visible to a reader until
+ * the file is unlocked.
+ *
+ * @param cfg the configuration in which to lock
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_config_lock(git_config *cfg);
+
+/**
+ * Unlock the backend with the highest priority
+ *
+ * Unlocking will allow other writers to updat the configuration
+ * file. Optionally, any changes performed since the lock will be
+ * applied to the configuration.
+ *
+ * @param cfg the configuration
+ * @param commit boolean which indicates whether to commit any changes
+ * done since locking
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_config_unlock(git_config *cfg, int commit);
+
+
/** @} */
GIT_END_DECL
#endif