diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2015-01-26 11:28:59 -0600 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2015-01-26 11:28:59 -0600 |
| commit | 1ac5acdc695b837a921897a9d42acc75649cfd4f (patch) | |
| tree | 6c5972270209a8cfe17f45534c28d211c8a3db71 /include/git2 | |
| parent | 2724219918abeb51b8a5cb8f92cb09acfd447c57 (diff) | |
| parent | eac773d92bccc7d3fc7ce1b18578d374873e0d7a (diff) | |
| download | libgit2-1ac5acdc695b837a921897a9d42acc75649cfd4f.tar.gz | |
Merge pull request #2819 from libgit2/cmn/config-get-path
config: add parsing and getter for paths
Diffstat (limited to 'include/git2')
| -rw-r--r-- | include/git2/config.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/git2/config.h b/include/git2/config.h index e32c614ea..1ed8d2441 100644 --- a/include/git2/config.h +++ b/include/git2/config.h @@ -320,6 +320,24 @@ GIT_EXTERN(int) git_config_get_int64(int64_t *out, const git_config *cfg, const GIT_EXTERN(int) git_config_get_bool(int *out, const git_config *cfg, const char *name); /** + * Get the value of a path config variable. + * + * A leading '~' will be expanded to the global search path (which + * defaults to the user's home directory but can be overridden via + * `git_libgit2_opts()`. + * + * All config files will be looked into, in the order of their + * defined level. A higher level means a higher priority. The + * first occurrence of the variable will be returned here. + * + * @param out the buffer in which to store the result + * @param cfg where to look for the variable + * @param name the variable's name + * @param 0 or an error code + */ +GIT_EXTERN(int) git_config_get_path(git_buf *out, const git_config *cfg, const char *name); + +/** * Get the value of a string config variable. * * The string is owned by the variable and should not be freed by the @@ -615,6 +633,20 @@ GIT_EXTERN(int) git_config_parse_int32(int32_t *out, const char *value); */ GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value); +/** + * Parse a string value as a path. + * + * A leading '~' will be expanded to the global search path (which + * defaults to the user's home directory but can be overridden via + * `git_libgit2_opts()`. + * + * If the value does not begin with a tilde, the input will be + * returned. + * + * @param out placae to store the result of parsing + * @param value the path to evaluate + */ +GIT_EXTERN(int) git_config_parse_path(git_buf *out, const char *value); /** * Perform an operation on each config variable in given config backend |
