summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-03-18 14:19:35 -0700
committerRussell Belfer <rb@github.com>2013-03-18 14:19:35 -0700
commit41954a49c12a72eda3b3fe02c2752f6831b5dbf9 (patch)
tree4b9cff17fbd7172efddde4dba8e1d2f6b31e0c45 /src/util.c
parent5540d9477ed143707435324e785336d254b12e47 (diff)
downloadlibgit2-41954a49c12a72eda3b3fe02c2752f6831b5dbf9.tar.gz
Switch search paths to classic delimited strings
This switches the APIs for setting and getting the global/system search paths from using git_strarray to using a simple string with GIT_PATH_LIST_SEPARATOR delimited paths, just as the environment PATH variable would contain. This makes it simpler to get and set the value. I also added code to expand "$PATH" when setting a new value to embed the old value of the path. This means that I no longer require separate actions to PREPEND to the value.
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/util.c b/src/util.c
index f481646f7..ba867b440 100644
--- a/src/util.c
+++ b/src/util.c
@@ -39,7 +39,7 @@ int git_libgit2_capabilities()
extern size_t git_mwindow__window_size;
extern size_t git_mwindow__mapped_limit;
-static int convert_config_level_to_futils_dir(int config_level)
+static int config_level_to_futils_dir(int config_level)
{
int val = -1;
@@ -80,24 +80,18 @@ int git_libgit2_opts(int key, ...)
break;
case GIT_OPT_GET_SEARCH_PATH:
- {
- const git_strarray **out = va_arg(ap, const git_strarray **);
- int which = convert_config_level_to_futils_dir(va_arg(ap, int));
+ if ((error = config_level_to_futils_dir(va_arg(ap, int))) >= 0) {
+ char *out = va_arg(ap, char *);
+ size_t outlen = va_arg(ap, size_t);
- error = (which < 0) ? which : git_futils_dirs_get(out, which);
- break;
+ error = git_futils_dirs_get_str(out, outlen, error);
}
+ break;
case GIT_OPT_SET_SEARCH_PATH:
- case GIT_OPT_PREPEND_SEARCH_PATH:
- {
- int which = convert_config_level_to_futils_dir(va_arg(ap, int));
- const git_strarray *dirs = va_arg(ap, git_strarray *);
-
- error = (which < 0) ? which : git_futils_dirs_set(
- which, dirs, key == GIT_OPT_SET_SEARCH_PATH);
- break;
- }
+ if ((error = config_level_to_futils_dir(va_arg(ap, int))) >= 0)
+ error = git_futils_dirs_set(error, va_arg(ap, const char *));
+ break;
}
va_end(ap);