summaryrefslogtreecommitdiff
path: root/include/git2/config.h
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-05-20 03:20:12 +0300
committerVicent Marti <tanoku@gmail.com>2011-05-20 03:20:12 +0300
commitb0b527e0ad7b2b0d58e3d5039339d29892206f2d (patch)
treee8a6a8bc5d5b090d158d38cc02e8e2a9b42def14 /include/git2/config.h
parent8adbf2ed12b7067660a4012f54d76650663edee1 (diff)
downloadlibgit2-b0b527e0ad7b2b0d58e3d5039339d29892206f2d.tar.gz
config: Cleanup & renaming of the external API
"git_config_backend" have been renamed to "git_config_file", which implements a generic interface to access a configuration file -- be it either on disk, from a DB or whatever mumbojumbo. I think this makes more sense.
Diffstat (limited to 'include/git2/config.h')
-rw-r--r--include/git2/config.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/include/git2/config.h b/include/git2/config.h
index 9ae54f112..78a1f622a 100644
--- a/include/git2/config.h
+++ b/include/git2/config.h
@@ -38,6 +38,32 @@
GIT_BEGIN_DECL
/**
+ * Generic backend that implements the interface to
+ * access a configuration file
+ */
+struct git_config_file {
+ struct git_config *cfg;
+
+ /* Open means open the file/database and parse if necessary */
+ int (*open)(struct git_config_file *);
+ int (*get)(struct git_config_file *, const char *key, const char **value);
+ int (*set)(struct git_config_file *, const char *key, const char *value);
+ int (*foreach)(struct git_config_file *, int (*fn)(const char *, void *), void *data);
+ void (*free)(struct git_config_file *);
+};
+
+/**
+ * Create a configuration file backend for ondisk files
+ *
+ * These are the normal `.gitconfig` files that Core Git
+ * processes.
+ *
+ * @param out the new backend
+ * @path where the config file is located
+ */
+GIT_EXTERN(int) git_config_file__ondisk(struct git_config_file **out, const char *path);
+
+/**
* Allocate a new configuration
*/
GIT_EXTERN(int) git_config_new(git_config **out);
@@ -48,7 +74,7 @@ GIT_EXTERN(int) git_config_new(git_config **out);
* @param cfg_out pointer to the configuration data
* @param path where to load the confiration from
*/
-GIT_EXTERN(int) git_config_open_bare(git_config **cfg_out, const char *path);
+GIT_EXTERN(int) git_config_open_file(git_config **cfg_out, const char *path);
/**
* Open the global configuration file at $HOME/.gitconfig
@@ -67,7 +93,7 @@ GIT_EXTERN(int) git_config_open_global(git_config **cfg);
* @param backend the backend to add
* @param priority the priority the backend should have
*/
-GIT_EXTERN(int) git_config_add_backend(git_config *cfg, git_config_backend *backend, int priority);
+GIT_EXTERN(int) git_config_add_file(git_config *cfg, git_config_file *file, int priority);
/**
* Free the configuration and its associated memory