summaryrefslogtreecommitdiff
path: root/include/git2
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
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')
-rw-r--r--include/git2/config.h30
-rw-r--r--include/git2/config_backend.h57
-rw-r--r--include/git2/types.h6
3 files changed, 31 insertions, 62 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
diff --git a/include/git2/config_backend.h b/include/git2/config_backend.h
deleted file mode 100644
index 427cd95dd..000000000
--- a/include/git2/config_backend.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * This file is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2,
- * as published by the Free Software Foundation.
- *
- * In addition to the permissions in the GNU General Public License,
- * the authors give you unlimited permission to link the compiled
- * version of this file into combinations with other programs,
- * and to distribute those combinations without any restriction
- * coming from the use of this file. (The General Public License
- * restrictions do apply in other respects; for example, they cover
- * modification of the file, and distribution when not linked into
- * a combined executable.)
- *
- * This file is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDE_git_config_backend_h__
-#define INCLUDE_git_config_backend_h__
-
-#include "common.h"
-#include "types.h"
-#include "config.h"
-
-GIT_BEGIN_DECL
-
-struct git_config;
-
-struct git_config_backend {
- struct git_config *cfg;
- /* Open means open the file/database and parse if necessary */
- int (*open)(struct git_config_backend *);
- int (* get)(struct git_config_backend *, const char *key, const char **value);
- int (* set)(struct git_config_backend *, const char *key, const char *value);
- int (*foreach)(struct git_config_backend *, int (*fn)(const char *, void *), void *data);
- void (*free)(struct git_config_backend *);
-};
-
-/**
- * Create a file-backed configuration backend
- *
- * @param out the new backend
- * @path where the config file is located
- */
-GIT_EXTERN(int) git_config_backend_file(struct git_config_backend **out, const char *path);
-
-GIT_END_DECL
-
-#endif
diff --git a/include/git2/types.h b/include/git2/types.h
index ab7dc523e..b569e83c1 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -130,11 +130,11 @@ typedef struct git_treebuilder git_treebuilder;
/** Memory representation of an index file. */
typedef struct git_index git_index;
-/** Memory representation of a config file */
+/** Memory representation of a set of config files */
typedef struct git_config git_config;
-/** A specific implementation of a config backend */
-typedef struct git_config_backend git_config_backend;
+/** Interface to access a configuration file */
+typedef struct git_config_file git_config_file;
/** Time in a signature */
typedef struct git_time {