summaryrefslogtreecommitdiff
path: root/include/git2/config.h
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@elego.de>2011-03-30 11:30:40 +0200
committerCarlos Martín Nieto <cmn@elego.de>2011-03-30 13:42:24 +0200
commit2974aa94c33b3845db3c999354d4202ff2b5bd2d (patch)
tree46ebdab537e5cf19b6b9a8abf7295f84941e4e21 /include/git2/config.h
parent2e445cacd23dd494e182024cf1b229a3727339aa (diff)
downloadlibgit2-2974aa94c33b3845db3c999354d4202ff2b5bd2d.tar.gz
Determine variable type at runtime
Config variables should be interpreted at run-time, as we don't know if a zero means false or zero, or if yes means true or "yes". As a variable has no intrinsic type, git_cvtype is gone and the public API takes care of enforcing a few rules. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Diffstat (limited to 'include/git2/config.h')
-rw-r--r--include/git2/config.h60
1 files changed, 12 insertions, 48 deletions
diff --git a/include/git2/config.h b/include/git2/config.h
index c91482636..e1e78858b 100644
--- a/include/git2/config.h
+++ b/include/git2/config.h
@@ -53,20 +53,6 @@ GIT_EXTERN(int) git_config_open(git_config **cfg_out, const char *path);
GIT_EXTERN(void) git_config_free(git_config *cfg);
/**
- * Get the value of an integer or boolean config variable.
- *
- * This is a more general function to retrieve the value of a integer
- * or boolean variable.
- *
- * @param cfg where to look for the variable
- * @param name the variable's name
- * @param out pointer to the variable where the value should be stored
- * @param type either GIT_VAR_INT or GIT_VAR_BOOL
- * @return GIT_SUCCESS on success; error code otherwise
- */
-GIT_EXTERN(int) git_config_get(git_config *cfg, const char *name, int *out, git_cvar_type type);
-
-/**
* Get the value of an integer config variable.
*
* @param cfg where to look for the variable
@@ -74,23 +60,20 @@ GIT_EXTERN(int) git_config_get(git_config *cfg, const char *name, int *out, git_
* @param out pointer to the variable where the value should be stored
* @return GIT_SUCCESS on success; error code otherwise
*/
-GIT_INLINE(int) git_config_get_int(git_config *cfg, const char *name, int *out)
-{
- return git_config_get(cfg, name, out, GIT_VAR_INT);
-}
+GIT_EXTERN(int) git_config_get_int(git_config *cfg, const char *name, int *out);
/**
* Get the value of a boolean config variable.
*
+ * This function uses the usual C convention of 0 being false and
+ * anything else true.
+ *
* @param cfg where to look for the variable
* @param name the variable's name
* @param out pointer to the variable where the value should be stored
* @return GIT_SUCCESS on success; error code otherwise
*/
-GIT_INLINE(int) git_config_get_bool(git_config *cfg, const char *name, int *out)
-{
- return git_config_get(cfg, name, out, GIT_VAR_BOOL);
-}
+GIT_EXTERN(int) git_config_get_bool(git_config *cfg, const char *name, int *out);
/**
* Get the value of a string config variable.
@@ -104,19 +87,6 @@ GIT_INLINE(int) git_config_get_bool(git_config *cfg, const char *name, int *out)
* @return GIT_SUCCESS on success; error code otherwise
*/
GIT_EXTERN(int) git_config_get_string(git_config *cfg, const char *name, const char **out);
-/**
- * Set the value of an integer or boolean config variable.
- *
- * This is a more general function to set the value of a integer or
- * boolean variable.
- *
- * @param cfg where to look for the variable
- * @param name the variable's name
- * @param value the value to store
- * @param type either GIT_VAR_INT or GIT_VAR_BOOL
- * @return GIT_SUCCESS on success; error code otherwise
- */
-GIT_EXTERN(int) git_config_set(git_config *cfg, const char *name, int value, git_cvar_type type);
/**
* Set the value of an integer config variable.
@@ -126,10 +96,7 @@ GIT_EXTERN(int) git_config_set(git_config *cfg, const char *name, int value, git
* @param out pointer to the variable where the value should be stored
* @return GIT_SUCCESS on success; error code otherwise
*/
-GIT_INLINE(int) git_config_set_int(git_config *cfg, const char *name, int value)
-{
- return git_config_set(cfg, name, value, GIT_VAR_INT);
-}
+GIT_EXTERN(int) git_config_set_int(git_config *cfg, const char *name, int value);
/**
* Set the value of a boolean config variable.
@@ -139,10 +106,7 @@ GIT_INLINE(int) git_config_set_int(git_config *cfg, const char *name, int value)
* @param value the value to store
* @return GIT_SUCCESS on success; error code otherwise
*/
-GIT_INLINE(int) git_config_set_bool(git_config *cfg, const char *name, int value)
-{
- return git_config_set(cfg, name, value, GIT_VAR_BOOL);
-}
+GIT_EXTERN(int) git_config_set_bool(git_config *cfg, const char *name, int value);
/**
* Set the value of a string config variable.
@@ -160,17 +124,17 @@ GIT_EXTERN(int) git_config_set_string(git_config *cfg, const char *name, const c
/**
* Perform an operation on each config variable.
*
- * The callback is passed a pointer to a config variable and the data
- * pointer passed to this function. As soon as one of the callback
- * functions returns something other than 0, this function returns
- * that value.
+ * The callback is passed a pointer to a config variable name and the
+ * data pointer passed to this function. As soon as one of the
+ * callback functions returns something other than 0, this function
+ * returns that value.
*
* @param cfg where to get the variables from
* @param callback the function to call on each variable
* @param data the data to pass to the callback
* @return GIT_SUCCESS or the return value of the callback which didn't return 0
*/
-GIT_EXTERN(int) git_config_foreach(git_config *cfg, int (*callback)(git_cvar *, void *data), void *data);
+GIT_EXTERN(int) git_config_foreach(git_config *cfg, int (*callback)(const char *, void *data), void *data);
/** @} */
GIT_END_DECL