mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 13:52:17 +00:00
settings: use git_buf for returning strings
This survived the last round of culling, as the signature is only in the comments.
This commit is contained in:
parent
0deb534d76
commit
42dee8ecd7
@ -161,12 +161,12 @@ typedef enum {
|
||||
* >Set the maximum amount of memory that can be mapped at any time
|
||||
* by the library
|
||||
*
|
||||
* * opts(GIT_OPT_GET_SEARCH_PATH, int level, char *out, size_t len)
|
||||
* * opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf)
|
||||
*
|
||||
* > Get the search path for a given level of config data. "level" must
|
||||
* > be one of `GIT_CONFIG_LEVEL_SYSTEM`, `GIT_CONFIG_LEVEL_GLOBAL`, or
|
||||
* > `GIT_CONFIG_LEVEL_XDG`. The search path is written to the `out`
|
||||
* > buffer up to size `len`. Returns GIT_EBUFS if buffer is too small.
|
||||
* > buffer.
|
||||
*
|
||||
* * opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
|
||||
*
|
||||
@ -210,11 +210,10 @@ typedef enum {
|
||||
* > Get the current bytes in cache and the maximum that would be
|
||||
* > allowed in the cache.
|
||||
*
|
||||
* * opts(GIT_OPT_GET_TEMPLATE_PATH, char *out, size_t len)
|
||||
* * opts(GIT_OPT_GET_TEMPLATE_PATH, git_buf *out)
|
||||
*
|
||||
* > Get the default template path.
|
||||
* > The path is written to the `out`
|
||||
* > buffer up to size `len`. Returns GIT_EBUFS if buffer is too small.
|
||||
* > The path is written to the `out` buffer.
|
||||
*
|
||||
* * opts(GIT_OPT_SET_TEMPLATE_PATH, const char *path)
|
||||
*
|
||||
|
@ -78,10 +78,14 @@ int git_libgit2_opts(int key, ...)
|
||||
|
||||
case GIT_OPT_GET_SEARCH_PATH:
|
||||
if ((error = config_level_to_sysdir(va_arg(ap, int))) >= 0) {
|
||||
char *out = va_arg(ap, char *);
|
||||
size_t outlen = va_arg(ap, size_t);
|
||||
git_buf *out = va_arg(ap, git_buf *);
|
||||
const git_buf *tmp;
|
||||
|
||||
error = git_sysdir_get_str(out, outlen, error);
|
||||
git_buf_sanitize(out);
|
||||
if ((error = git_sysdir_get(&tmp, error)) < 0)
|
||||
break;
|
||||
|
||||
error = git_buf_sets(out, tmp->ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -113,10 +117,14 @@ int git_libgit2_opts(int key, ...)
|
||||
|
||||
case GIT_OPT_GET_TEMPLATE_PATH:
|
||||
{
|
||||
char *out = va_arg(ap, char *);
|
||||
size_t outlen = va_arg(ap, size_t);
|
||||
git_buf *out = va_arg(ap, git_buf *);
|
||||
const git_buf *tmp;
|
||||
|
||||
error = git_sysdir_get_str(out, outlen, GIT_SYSDIR_TEMPLATE);
|
||||
git_buf_sanitize(out);
|
||||
if ((error = git_sysdir_get(&tmp, GIT_SYSDIR_TEMPLATE)) < 0)
|
||||
break;
|
||||
|
||||
error = git_buf_sets(out, tmp->ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -218,7 +218,7 @@ void test_core_env__1(void)
|
||||
static void check_global_searchpath(
|
||||
const char *path, int position, const char *file, git_buf *temp)
|
||||
{
|
||||
char out[GIT_PATH_MAX];
|
||||
git_buf out = GIT_BUF_INIT;
|
||||
|
||||
/* build and set new path */
|
||||
if (position < 0)
|
||||
@ -233,12 +233,12 @@ static void check_global_searchpath(
|
||||
|
||||
/* get path and make sure $PATH expansion worked */
|
||||
cl_git_pass(git_libgit2_opts(
|
||||
GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, out, sizeof(out)));
|
||||
GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &out));
|
||||
|
||||
if (position < 0)
|
||||
cl_assert(git__prefixcmp(out, path) == 0);
|
||||
cl_assert(git__prefixcmp(out.ptr, path) == 0);
|
||||
else if (position > 0)
|
||||
cl_assert(git__suffixcmp(out, path) == 0);
|
||||
cl_assert(git__suffixcmp(out.ptr, path) == 0);
|
||||
else
|
||||
cl_assert_equal_s(out, path);
|
||||
|
||||
@ -250,6 +250,8 @@ static void check_global_searchpath(
|
||||
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, NULL));
|
||||
cl_assert_equal_i(
|
||||
GIT_ENOTFOUND, git_sysdir_find_global_file(temp, file));
|
||||
|
||||
git_buf_free(&out);
|
||||
}
|
||||
|
||||
void test_core_env__2(void)
|
||||
|
Loading…
Reference in New Issue
Block a user