summaryrefslogtreecommitdiff
path: root/src/libgit2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libgit2.c')
-rw-r--r--src/libgit2.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/libgit2.c b/src/libgit2.c
index cc793b458..b3a72de18 100644
--- a/src/libgit2.c
+++ b/src/libgit2.c
@@ -9,6 +9,7 @@
#include <git2.h>
#include "alloc.h"
+#include "buf.h"
#include "cache.h"
#include "common.h"
#include "filter.h"
@@ -192,15 +193,17 @@ int git_libgit2_opts(int key, ...)
{
int sysdir = va_arg(ap, int);
git_buf *out = va_arg(ap, git_buf *);
- const git_buf *tmp;
+ git_str str = GIT_STR_INIT;
+ const git_str *tmp;
int level;
- if ((error = config_level_to_sysdir(&level, sysdir)) < 0 ||
- (error = git_buf_sanitize(out)) < 0 ||
- (error = git_sysdir_get(&tmp, level)) < 0)
+ if ((error = git_buf_tostr(&str, out)) < 0 ||
+ (error = config_level_to_sysdir(&level, sysdir)) < 0 ||
+ (error = git_sysdir_get(&tmp, level)) < 0 ||
+ (error = git_str_put(&str, tmp->ptr, tmp->size)) < 0)
break;
- error = git_buf_sets(out, tmp->ptr);
+ error = git_buf_fromstr(out, &str);
}
break;
@@ -237,13 +240,15 @@ int git_libgit2_opts(int key, ...)
case GIT_OPT_GET_TEMPLATE_PATH:
{
git_buf *out = va_arg(ap, git_buf *);
- const git_buf *tmp;
+ git_str str = GIT_STR_INIT;
+ const git_str *tmp;
- if ((error = git_buf_sanitize(out)) < 0 ||
- (error = git_sysdir_get(&tmp, GIT_SYSDIR_TEMPLATE)) < 0)
+ if ((error = git_buf_tostr(&str, out)) < 0 ||
+ (error = git_sysdir_get(&tmp, GIT_SYSDIR_TEMPLATE)) < 0 ||
+ (error = git_str_put(&str, tmp->ptr, tmp->size)) < 0)
break;
- error = git_buf_sets(out, tmp->ptr);
+ error = git_buf_fromstr(out, &str);
}
break;
@@ -306,9 +311,13 @@ int git_libgit2_opts(int key, ...)
case GIT_OPT_GET_USER_AGENT:
{
git_buf *out = va_arg(ap, git_buf *);
- if ((error = git_buf_sanitize(out)) < 0)
+ git_str str = GIT_STR_INIT;
+
+ if ((error = git_buf_tostr(&str, out)) < 0 ||
+ (error = git_str_puts(&str, git__user_agent)) < 0)
break;
- error = git_buf_sets(out, git__user_agent);
+
+ error = git_buf_fromstr(out, &str);
}
break;