diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2014-01-26 16:11:18 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-01-27 04:44:05 +0100 |
| commit | ee550477d1c22273d6d9701b444041ff101144ec (patch) | |
| tree | d512e555ecfb8c9e94cc2c2bbff435f4a47b3598 /src/config.c | |
| parent | b25d87c9cdef0bc09007c756d7e52f15eb4622d7 (diff) | |
| download | libgit2-ee550477d1c22273d6d9701b444041ff101144ec.tar.gz | |
config: use git_buf for returning paths
Again, we already did this internally, so simply remove the conversions.
Diffstat (limited to 'src/config.c')
| -rw-r--r-- | src/config.c | 52 |
1 files changed, 6 insertions, 46 deletions
diff --git a/src/config.c b/src/config.c index fa1dd8182..6aa71468a 100644 --- a/src/config.c +++ b/src/config.c @@ -935,61 +935,21 @@ void git_config_iterator_free(git_config_iterator *iter) iter->free(iter); } -static int git_config__find_file_to_path( - char *out, size_t outlen, int (*find)(git_buf *buf)) -{ - int error = 0; - git_buf path = GIT_BUF_INIT; - - if ((error = find(&path)) < 0) - goto done; - - if (path.size >= outlen) { - giterr_set(GITERR_NOMEMORY, "Buffer is too short for the path"); - error = GIT_EBUFS; - goto done; - } - - git_buf_copy_cstr(out, outlen, &path); - -done: - git_buf_free(&path); - return error; -} - -int git_config_find_global_r(git_buf *path) +int git_config_find_global(git_buf *path) { return git_futils_find_global_file(path, GIT_CONFIG_FILENAME_GLOBAL); } -int git_config_find_global(char *global_config_path, size_t length) -{ - return git_config__find_file_to_path( - global_config_path, length, git_config_find_global_r); -} - -int git_config_find_xdg_r(git_buf *path) +int git_config_find_xdg(git_buf *path) { return git_futils_find_xdg_file(path, GIT_CONFIG_FILENAME_XDG); } -int git_config_find_xdg(char *xdg_config_path, size_t length) -{ - return git_config__find_file_to_path( - xdg_config_path, length, git_config_find_xdg_r); -} - -int git_config_find_system_r(git_buf *path) +int git_config_find_system(git_buf *path) { return git_futils_find_system_file(path, GIT_CONFIG_FILENAME_SYSTEM); } -int git_config_find_system(char *system_config_path, size_t length) -{ - return git_config__find_file_to_path( - system_config_path, length, git_config_find_system_r); -} - int git_config__global_location(git_buf *buf) { const git_buf *paths; @@ -1026,16 +986,16 @@ int git_config_open_default(git_config **out) if ((error = git_config_new(&cfg)) < 0) return error; - if (!git_config_find_global_r(&buf) || !git_config__global_location(&buf)) { + if (!git_config_find_global(&buf) || !git_config__global_location(&buf)) { error = git_config_add_file_ondisk(cfg, buf.ptr, GIT_CONFIG_LEVEL_GLOBAL, 0); } - if (!error && !git_config_find_xdg_r(&buf)) + if (!error && !git_config_find_xdg(&buf)) error = git_config_add_file_ondisk(cfg, buf.ptr, GIT_CONFIG_LEVEL_XDG, 0); - if (!error && !git_config_find_system_r(&buf)) + if (!error && !git_config_find_system(&buf)) error = git_config_add_file_ondisk(cfg, buf.ptr, GIT_CONFIG_LEVEL_SYSTEM, 0); |
