summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-01-26 16:11:18 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2014-01-27 04:44:05 +0100
commitee550477d1c22273d6d9701b444041ff101144ec (patch)
treed512e555ecfb8c9e94cc2c2bbff435f4a47b3598 /src
parentb25d87c9cdef0bc09007c756d7e52f15eb4622d7 (diff)
downloadlibgit2-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')
-rw-r--r--src/config.c52
-rw-r--r--src/config.h5
-rw-r--r--src/repository.c6
3 files changed, 9 insertions, 54 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);
diff --git a/src/config.h b/src/config.h
index 3cd888c88..03d910616 100644
--- a/src/config.h
+++ b/src/config.h
@@ -24,11 +24,6 @@ struct git_config {
git_vector files;
};
-extern int git_config_find_global_r(git_buf *global_config_path);
-extern int git_config_find_xdg_r(git_buf *system_config_path);
-extern int git_config_find_system_r(git_buf *system_config_path);
-
-
extern int git_config__global_location(git_buf *buf);
extern int git_config_rename_section(
diff --git a/src/repository.c b/src/repository.c
index db66e6bd5..285d8897f 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -582,9 +582,9 @@ int git_repository_config__weakptr(git_config **out, git_repository *repo)
git_buf system_buf = GIT_BUF_INIT;
git_config *config;
- git_config_find_global_r(&global_buf);
- git_config_find_xdg_r(&xdg_buf);
- git_config_find_system_r(&system_buf);
+ git_config_find_global(&global_buf);
+ git_config_find_xdg(&xdg_buf);
+ git_config_find_system(&system_buf);
/* If there is no global file, open a backend for it anyway */
if (git_buf_len(&global_buf) == 0)