config: implement basic transactional support

When a configuration file is locked, any updates made to it will be done
to the in-memory copy of the file. This allows for multiple updates to
happen while we hold the lock, preventing races during complex
config-file manipulation.
This commit is contained in:
Carlos Martín Nieto
2015-08-12 04:09:09 +02:00
parent 3ce9e4d235
commit b166703964
4 changed files with 151 additions and 12 deletions
+14
View File
@@ -67,6 +67,20 @@ struct git_config_backend {
int (*iterator)(git_config_iterator **, struct git_config_backend *);
/** Produce a read-only version of this backend */
int (*snapshot)(struct git_config_backend **, struct git_config_backend *);
/**
* Lock this backend.
*
* Prevent any writes to the data store backing this
* backend. Any updates must not be visible to any other
* readers.
*/
int (*lock)(struct git_config_backend *);
/**
* Unlock the data store backing this backend. If success is
* true, the changes should be committed, otherwise rolled
* back.
*/
int (*unlock)(struct git_config_backend *, int success);
void (*free)(struct git_config_backend *);
};
#define GIT_CONFIG_BACKEND_VERSION 1