summaryrefslogtreecommitdiff
path: root/tests/repo
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-09-07 17:53:49 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2021-09-30 12:42:46 -0400
commitfe07fa64878f3b7dfc7ed2964c3d45fd2fd6be7f (patch)
tree62db77db4f4486766d7d5f3bb6a12a85ec305ce9 /tests/repo
parentcb2c926336f5f7f1a75c871cb74d567b52bb8c5c (diff)
downloadlibgit2-fe07fa64878f3b7dfc7ed2964c3d45fd2fd6be7f.tar.gz
str: introduce `git_str` for internal, `git_buf` is external
libgit2 has two distinct requirements that were previously solved by `git_buf`. We require: 1. A general purpose string class that provides a number of utility APIs for manipulating data (eg, concatenating, truncating, etc). 2. A structure that we can use to return strings to callers that they can take ownership of. By using a single class (`git_buf`) for both of these purposes, we have confused the API to the point that refactorings are difficult and reasoning about correctness is also difficult. Move the utility class `git_buf` to be called `git_str`: this represents its general purpose, as an internal string buffer class. The name also is an homage to Junio Hamano ("gitstr"). The public API remains `git_buf`, and has a much smaller footprint. It is generally only used as an "out" param with strict requirements that follow the documentation. (Exceptions exist for some legacy APIs to avoid breaking callers unnecessarily.) Utility functions exist to convert a user-specified `git_buf` to a `git_str` so that we can call internal functions, then converting it back again.
Diffstat (limited to 'tests/repo')
-rw-r--r--tests/repo/config.c12
-rw-r--r--tests/repo/discover.c26
-rw-r--r--tests/repo/env.c20
-rw-r--r--tests/repo/hashfile.c35
-rw-r--r--tests/repo/init.c70
-rw-r--r--tests/repo/message.c14
-rw-r--r--tests/repo/open.c60
-rw-r--r--tests/repo/repo_helpers.c14
-rw-r--r--tests/repo/reservedname.c14
-rw-r--r--tests/repo/setters.c15
-rw-r--r--tests/repo/state.c11
-rw-r--r--tests/repo/template.c58
12 files changed, 173 insertions, 176 deletions
diff --git a/tests/repo/config.c b/tests/repo/config.c
index 6ca31f550..0b9daac98 100644
--- a/tests/repo/config.c
+++ b/tests/repo/config.c
@@ -3,7 +3,7 @@
#include "futils.h"
#include <ctype.h>
-static git_buf path = GIT_BUF_INIT;
+static git_str path = GIT_STR_INIT;
void test_repo_config__initialize(void)
{
@@ -11,7 +11,7 @@ void test_repo_config__initialize(void)
cl_git_pass(cl_rename(
"empty_standard_repo/.gitted", "empty_standard_repo/.git"));
- git_buf_clear(&path);
+ git_str_clear(&path);
cl_must_pass(p_mkdir("alternate", 0777));
cl_git_pass(git_path_prettify(&path, "alternate", NULL));
@@ -21,7 +21,7 @@ void test_repo_config__cleanup(void)
{
cl_sandbox_set_search_path_defaults();
- git_buf_dispose(&path);
+ git_str_dispose(&path);
cl_git_pass(
git_futils_rmdir_r("alternate", NULL, GIT_RMDIR_REMOVE_FILES));
@@ -60,7 +60,7 @@ void test_repo_config__can_open_missing_global_with_separators(void)
git_repository *repo;
git_config *config, *global;
- cl_git_pass(git_buf_printf(
+ cl_git_pass(git_str_printf(
&path, "%c%s", GIT_PATH_LIST_SEPARATOR, "dummy"));
cl_git_pass(git_libgit2_opts(
@@ -70,7 +70,7 @@ void test_repo_config__can_open_missing_global_with_separators(void)
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_XDG, path.ptr));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
cl_git_pass(git_repository_open(&repo, "empty_standard_repo"));
cl_git_pass(git_repository_config(&config, repo));
@@ -115,7 +115,7 @@ void test_repo_config__read_with_no_configs_at_all(void)
cl_sandbox_set_search_path_defaults();
cl_must_pass(p_mkdir("alternate/1", 0777));
- cl_git_pass(git_buf_joinpath(&path, path.ptr, "1"));
+ cl_git_pass(git_str_joinpath(&path, path.ptr, "1"));
cl_git_rewritefile("alternate/1/gitconfig", "[core]\n\tabbrev = 10\n");
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, path.ptr));
diff --git a/tests/repo/discover.c b/tests/repo/discover.c
index c026eefc3..2a24f1b29 100644
--- a/tests/repo/discover.c
+++ b/tests/repo/discover.c
@@ -28,16 +28,17 @@ static void ensure_repository_discover(const char *start_path,
const char *ceiling_dirs,
const char *expected_path)
{
- git_buf found_path = GIT_BUF_INIT, resolved = GIT_BUF_INIT;
+ git_buf found_path = GIT_BUF_INIT;
+ git_str resolved = GIT_STR_INIT;
- git_buf_attach(&resolved, p_realpath(expected_path, NULL), 0);
+ git_str_attach(&resolved, p_realpath(expected_path, NULL), 0);
cl_assert(resolved.size > 0);
cl_git_pass(git_path_to_dir(&resolved));
cl_git_pass(git_repository_discover(&found_path, start_path, 1, ceiling_dirs));
cl_assert_equal_s(found_path.ptr, resolved.ptr);
- git_buf_dispose(&resolved);
+ git_str_dispose(&resolved);
git_buf_dispose(&found_path);
}
@@ -59,24 +60,24 @@ static void write_file(const char *path, const char *content)
}
/*no check is performed on ceiling_dirs length, so be sure it's long enough */
-static void append_ceiling_dir(git_buf *ceiling_dirs, const char *path)
+static void append_ceiling_dir(git_str *ceiling_dirs, const char *path)
{
- git_buf pretty_path = GIT_BUF_INIT;
+ git_str pretty_path = GIT_STR_INIT;
char ceiling_separator[2] = { GIT_PATH_LIST_SEPARATOR, '\0' };
cl_git_pass(git_path_prettify_dir(&pretty_path, path, NULL));
if (ceiling_dirs->size > 0)
- git_buf_puts(ceiling_dirs, ceiling_separator);
+ git_str_puts(ceiling_dirs, ceiling_separator);
- git_buf_puts(ceiling_dirs, pretty_path.ptr);
+ git_str_puts(ceiling_dirs, pretty_path.ptr);
- git_buf_dispose(&pretty_path);
- cl_assert(git_buf_oom(ceiling_dirs) == 0);
+ git_str_dispose(&pretty_path);
+ cl_assert(git_str_oom(ceiling_dirs) == 0);
}
static git_buf discovered;
-static git_buf ceiling_dirs;
+static git_str ceiling_dirs;
void test_repo_discover__initialize(void)
{
@@ -84,8 +85,7 @@ void test_repo_discover__initialize(void)
const mode_t mode = 0777;
git_futils_mkdir_r(DISCOVER_FOLDER, mode);
- git_buf_init(&discovered, 0);
- git_buf_init(&ceiling_dirs, 0);
+ git_str_init(&ceiling_dirs, 0);
append_ceiling_dir(&ceiling_dirs, TEMP_REPO_FOLDER);
cl_git_pass(git_repository_init(&repo, DISCOVER_FOLDER, 1));
@@ -115,7 +115,7 @@ void test_repo_discover__initialize(void)
void test_repo_discover__cleanup(void)
{
git_buf_dispose(&discovered);
- git_buf_dispose(&ceiling_dirs);
+ git_str_dispose(&ceiling_dirs);
cl_git_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER, NULL, GIT_RMDIR_REMOVE_FILES));
}
diff --git a/tests/repo/env.c b/tests/repo/env.c
index 43defc168..4bd45d1a6 100644
--- a/tests/repo/env.c
+++ b/tests/repo/env.c
@@ -38,14 +38,14 @@ static int GIT_FORMAT_PRINTF(2, 3) cl_setenv_printf(const char *name, const char
{
int ret;
va_list args;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
va_start(args, fmt);
- cl_git_pass(git_buf_vprintf(&buf, fmt, args));
+ cl_git_pass(git_str_vprintf(&buf, fmt, args));
va_end(args);
- ret = cl_setenv(name, git_buf_cstr(&buf));
- git_buf_dispose(&buf);
+ ret = cl_setenv(name, git_str_cstr(&buf));
+ git_str_dispose(&buf);
return ret;
}
@@ -80,12 +80,12 @@ static void env_cd_(
void (*passfail_)(const char *, const char *, const char *, int),
const char *file, const char *func, int line)
{
- git_buf cwd_buf = GIT_BUF_INIT;
+ git_str cwd_buf = GIT_STR_INIT;
cl_git_pass(git_path_prettify_dir(&cwd_buf, ".", NULL));
cl_must_pass(p_chdir(path));
passfail_(NULL, file, func, line);
- cl_must_pass(p_chdir(git_buf_cstr(&cwd_buf)));
- git_buf_dispose(&cwd_buf);
+ cl_must_pass(p_chdir(git_str_cstr(&cwd_buf)));
+ git_str_dispose(&cwd_buf);
}
#define env_cd_pass(path) env_cd_((path), env_pass_, __FILE__, __func__, __LINE__)
#define env_cd_fail(path) env_cd_((path), env_fail_, __FILE__, __func__, __LINE__)
@@ -128,7 +128,7 @@ static void env_check_objects_(bool a, bool t, bool p, const char *file, const c
void test_repo_env__open(void)
{
git_repository *repo = NULL;
- git_buf repo_dir_buf = GIT_BUF_INIT;
+ git_str repo_dir_buf = GIT_STR_INIT;
const char *repo_dir = NULL;
git_index *index = NULL;
const char *t_obj = "testrepo.git/objects";
@@ -142,7 +142,7 @@ void test_repo_env__open(void)
cl_git_pass(p_rename("attr/.gitted", "attr/.git"));
cl_git_pass(git_path_prettify_dir(&repo_dir_buf, "attr", NULL));
- repo_dir = git_buf_cstr(&repo_dir_buf);
+ repo_dir = git_str_cstr(&repo_dir_buf);
/* GIT_DIR that doesn't exist */
cl_setenv("GIT_DIR", "does-not-exist");
@@ -271,7 +271,7 @@ void test_repo_env__open(void)
cl_fixture_cleanup("testrepo.git");
cl_fixture_cleanup("attr");
- git_buf_dispose(&repo_dir_buf);
+ git_str_dispose(&repo_dir_buf);
clear_git_env();
}
diff --git a/tests/repo/hashfile.c b/tests/repo/hashfile.c
index bffb51bb5..1bb69c38c 100644
--- a/tests/repo/hashfile.c
+++ b/tests/repo/hashfile.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
static git_repository *_repo;
@@ -18,14 +17,14 @@ void test_repo_hashfile__cleanup(void)
void test_repo_hashfile__simple(void)
{
git_oid a, b;
- git_buf full = GIT_BUF_INIT;
+ git_str full = GIT_STR_INIT;
/* hash with repo relative path */
cl_git_pass(git_odb_hashfile(&a, "status/current_file", GIT_OBJECT_BLOB));
cl_git_pass(git_repository_hashfile(&b, _repo, "current_file", GIT_OBJECT_BLOB, NULL));
cl_assert_equal_oid(&a, &b);
- cl_git_pass(git_buf_joinpath(&full, git_repository_workdir(_repo), "current_file"));
+ cl_git_pass(git_str_joinpath(&full, git_repository_workdir(_repo), "current_file"));
/* hash with full path */
cl_git_pass(git_odb_hashfile(&a, full.ptr, GIT_OBJECT_BLOB));
@@ -36,20 +35,20 @@ void test_repo_hashfile__simple(void)
cl_git_fail(git_odb_hashfile(&a, full.ptr, GIT_OBJECT_ANY));
cl_git_fail(git_repository_hashfile(&b, _repo, full.ptr, GIT_OBJECT_OFS_DELTA, NULL));
- git_buf_dispose(&full);
+ git_str_dispose(&full);
}
void test_repo_hashfile__filtered_in_workdir(void)
{
- git_buf root = GIT_BUF_INIT, txt = GIT_BUF_INIT, bin = GIT_BUF_INIT;
+ git_str root = GIT_BUF_INIT, txt = GIT_BUF_INIT, bin = GIT_BUF_INIT;
char cwd[GIT_PATH_MAX];
git_oid a, b;
cl_must_pass(p_getcwd(cwd, GIT_PATH_MAX));
cl_must_pass(p_mkdir("absolute", 0777));
- cl_git_pass(git_buf_joinpath(&root, cwd, "status"));
- cl_git_pass(git_buf_joinpath(&txt, root.ptr, "testfile.txt"));
- cl_git_pass(git_buf_joinpath(&bin, root.ptr, "testfile.bin"));
+ cl_git_pass(git_str_joinpath(&root, cwd, "status"));
+ cl_git_pass(git_str_joinpath(&txt, root.ptr, "testfile.txt"));
+ cl_git_pass(git_str_joinpath(&bin, root.ptr, "testfile.bin"));
cl_repo_set_bool(_repo, "core.autocrlf", true);
@@ -120,22 +119,22 @@ void test_repo_hashfile__filtered_in_workdir(void)
cl_git_fail(git_odb_hashfile(&a, "status/testfile.txt", 0));
cl_git_fail(git_repository_hashfile(&b, _repo, "testfile.txt", GIT_OBJECT_ANY, NULL));
- git_buf_dispose(&txt);
- git_buf_dispose(&bin);
- git_buf_dispose(&root);
+ git_str_dispose(&txt);
+ git_str_dispose(&bin);
+ git_str_dispose(&root);
}
void test_repo_hashfile__filtered_outside_workdir(void)
{
- git_buf root = GIT_BUF_INIT, txt = GIT_BUF_INIT, bin = GIT_BUF_INIT;
+ git_str root = GIT_BUF_INIT, txt = GIT_BUF_INIT, bin = GIT_BUF_INIT;
char cwd[GIT_PATH_MAX];
git_oid a, b;
cl_must_pass(p_getcwd(cwd, GIT_PATH_MAX));
cl_must_pass(p_mkdir("absolute", 0777));
- cl_git_pass(git_buf_joinpath(&root, cwd, "absolute"));
- cl_git_pass(git_buf_joinpath(&txt, root.ptr, "testfile.txt"));
- cl_git_pass(git_buf_joinpath(&bin, root.ptr, "testfile.bin"));
+ cl_git_pass(git_str_joinpath(&root, cwd, "absolute"));
+ cl_git_pass(git_str_joinpath(&txt, root.ptr, "testfile.txt"));
+ cl_git_pass(git_str_joinpath(&bin, root.ptr, "testfile.bin"));
cl_repo_set_bool(_repo, "core.autocrlf", true);
cl_git_append2file("status/.gitattributes", "*.txt text\n*.bin binary\n\n");
@@ -166,7 +165,7 @@ void test_repo_hashfile__filtered_outside_workdir(void)
cl_git_pass(git_repository_hashfile(&b, _repo, bin.ptr, GIT_OBJECT_BLOB, NULL));
cl_assert_equal_oid(&a, &b);
- git_buf_dispose(&txt);
- git_buf_dispose(&bin);
- git_buf_dispose(&root);
+ git_str_dispose(&txt);
+ git_str_dispose(&bin);
+ git_str_dispose(&root);
}
diff --git a/tests/repo/init.c b/tests/repo/init.c
index 1aa326f7f..b41608cca 100644
--- a/tests/repo/init.c
+++ b/tests/repo/init.c
@@ -12,7 +12,7 @@ enum repo_mode {
};
static git_repository *g_repo = NULL;
-static git_buf g_global_path = GIT_BUF_INIT;
+static git_str g_global_path = GIT_STR_INIT;
void test_repo_init__initialize(void)
{
@@ -26,7 +26,7 @@ void test_repo_init__cleanup(void)
{
git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL,
g_global_path.ptr);
- git_buf_dispose(&g_global_path);
+ git_str_dispose(&g_global_path);
cl_fixture_cleanup("tmp_global_path");
}
@@ -100,16 +100,16 @@ void test_repo_init__bare_repo_noslash(void)
void test_repo_init__bare_repo_escaping_current_workdir(void)
{
- git_buf path_repository = GIT_BUF_INIT;
- git_buf path_current_workdir = GIT_BUF_INIT;
+ git_str path_repository = GIT_STR_INIT;
+ git_str path_current_workdir = GIT_STR_INIT;
cl_git_pass(git_path_prettify_dir(&path_current_workdir, ".", NULL));
- cl_git_pass(git_buf_joinpath(&path_repository, git_buf_cstr(&path_current_workdir), "a/b/c"));
- cl_git_pass(git_futils_mkdir_r(git_buf_cstr(&path_repository), GIT_DIR_MODE));
+ cl_git_pass(git_str_joinpath(&path_repository, git_str_cstr(&path_current_workdir), "a/b/c"));
+ cl_git_pass(git_futils_mkdir_r(git_str_cstr(&path_repository), GIT_DIR_MODE));
/* Change the current working directory */
- cl_git_pass(chdir(git_buf_cstr(&path_repository)));
+ cl_git_pass(chdir(git_str_cstr(&path_repository)));
/* Initialize a bare repo with a relative path escaping out of the current working directory */
cl_git_pass(git_repository_init(&g_repo, "../d/e.git", 1));
@@ -121,10 +121,10 @@ void test_repo_init__bare_repo_escaping_current_workdir(void)
/* Open a bare repo with a relative path escaping out of the current working directory */
cl_git_pass(git_repository_open(&g_repo, "../d/e.git"));
- cl_git_pass(chdir(git_buf_cstr(&path_current_workdir)));
+ cl_git_pass(chdir(git_str_cstr(&path_current_workdir)));
- git_buf_dispose(&path_current_workdir);
- git_buf_dispose(&path_repository);
+ git_str_dispose(&path_current_workdir);
+ git_str_dispose(&path_repository);
cleanup_repository("a");
}
@@ -168,26 +168,26 @@ void test_repo_init__reinit_too_recent_bare_repo(void)
void test_repo_init__additional_templates(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cl_set_cleanup(&cleanup_repository, "tester");
ensure_repository_init("tester", 0, "tester/.git/", "tester/");
cl_git_pass(
- git_buf_joinpath(&path, git_repository_path(g_repo), "description"));
- cl_assert(git_path_isfile(git_buf_cstr(&path)));
+ git_str_joinpath(&path, git_repository_path(g_repo), "description"));
+ cl_assert(git_path_isfile(git_str_cstr(&path)));
cl_git_pass(
- git_buf_joinpath(&path, git_repository_path(g_repo), "info/exclude"));
- cl_assert(git_path_isfile(git_buf_cstr(&path)));
+ git_str_joinpath(&path, git_repository_path(g_repo), "info/exclude"));
+ cl_assert(git_path_isfile(git_str_cstr(&path)));
cl_git_pass(
- git_buf_joinpath(&path, git_repository_path(g_repo), "hooks"));
- cl_assert(git_path_isdir(git_buf_cstr(&path)));
+ git_str_joinpath(&path, git_repository_path(g_repo), "hooks"));
+ cl_assert(git_path_isdir(git_str_cstr(&path)));
/* won't confirm specific contents of hooks dir since it may vary */
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
static void assert_config_entry_on_init_bytype(
@@ -447,7 +447,7 @@ void test_repo_init__extended_1(void)
void test_repo_init__relative_gitdir(void)
{
git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
- git_buf dot_git_content = GIT_BUF_INIT;
+ git_str dot_git_content = GIT_STR_INIT;
opts.workdir_path = "../c_wd";
opts.flags =
@@ -472,18 +472,18 @@ void test_repo_init__relative_gitdir(void)
cl_git_pass(git_futils_readbuffer(&dot_git_content, "root/b/c_wd/.git"));
cl_assert_equal_s("gitdir: ../my_repository/", dot_git_content.ptr);
- git_buf_dispose(&dot_git_content);
+ git_str_dispose(&dot_git_content);
cleanup_repository("root");
}
void test_repo_init__relative_gitdir_2(void)
{
git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
- git_buf dot_git_content = GIT_BUF_INIT;
- git_buf full_path = GIT_BUF_INIT;
+ git_str dot_git_content = GIT_STR_INIT;
+ git_str full_path = GIT_STR_INIT;
cl_git_pass(git_path_prettify(&full_path, ".", NULL));
- cl_git_pass(git_buf_joinpath(&full_path, full_path.ptr, "root/b/c_wd"));
+ cl_git_pass(git_str_joinpath(&full_path, full_path.ptr, "root/b/c_wd"));
opts.workdir_path = full_path.ptr;
opts.flags =
@@ -493,7 +493,7 @@ void test_repo_init__relative_gitdir_2(void)
/* make the directory first, then it should succeed */
cl_git_pass(git_repository_init_ext(&g_repo, "root/b/my_repository", &opts));
- git_buf_dispose(&full_path);
+ git_str_dispose(&full_path);
cl_assert(!git__suffixcmp(git_repository_workdir(g_repo), "root/b/c_wd/"));
cl_assert(!git__suffixcmp(git_repository_path(g_repo), "root/b/my_repository/"));
@@ -509,7 +509,7 @@ void test_repo_init__relative_gitdir_2(void)
cl_git_pass(git_futils_readbuffer(&dot_git_content, "root/b/c_wd/.git"));
cl_assert_equal_s("gitdir: ../my_repository/", dot_git_content.ptr);
- git_buf_dispose(&dot_git_content);
+ git_str_dispose(&dot_git_content);
cleanup_repository("root");
}
@@ -598,7 +598,7 @@ void test_repo_init__at_filesystem_root(void)
{
git_repository *repo;
const char *sandbox = clar_sandbox_path();
- git_buf root = GIT_BUF_INIT;
+ git_str root = GIT_STR_INIT;
int root_len;
if (!cl_is_env_set("GITTEST_INVASIVE_FS_STRUCTURE"))
@@ -607,8 +607,8 @@ void test_repo_init__at_filesystem_root(void)
root_len = git_path_root(sandbox);
cl_assert(root_len >= 0);
- git_buf_put(&root, sandbox, root_len+1);
- git_buf_joinpath(&root, root.ptr, "libgit2_test_dir");
+ git_str_put(&root, sandbox, root_len+1);
+ git_str_joinpath(&root, root.ptr, "libgit2_test_dir");
cl_assert(!git_path_exists(root.ptr));
@@ -616,7 +616,7 @@ void test_repo_init__at_filesystem_root(void)
cl_assert(git_path_isdir(root.ptr));
cl_git_pass(git_futils_rmdir_r(root.ptr, NULL, GIT_RMDIR_REMOVE_FILES));
- git_buf_dispose(&root);
+ git_str_dispose(&root);
git_repository_free(repo);
}
@@ -710,29 +710,29 @@ void test_repo_init__longpath(void)
#ifdef GIT_WIN32
size_t padding = CONST_STRLEN("objects/pack/pack-.pack.lock") + GIT_OID_HEXSZ;
size_t max, i;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_repository *one = NULL, *two = NULL;
/*
* Files within repositories need to fit within MAX_PATH;
* that means a repo path must be at most (MAX_PATH - 18).
*/
- cl_git_pass(git_buf_puts(&path, clar_sandbox_path()));
- cl_git_pass(git_buf_putc(&path, '/'));
+ cl_git_pass(git_str_puts(&path, clar_sandbox_path()));
+ cl_git_pass(git_str_putc(&path, '/'));
max = ((MAX_PATH) - path.size) - padding;
for (i = 0; i < max - 1; i++)
- cl_git_pass(git_buf_putc(&path, 'a'));
+ cl_git_pass(git_str_putc(&path, 'a'));
cl_git_pass(git_repository_init(&one, path.ptr, 1));
/* Paths longer than this are rejected */
- cl_git_pass(git_buf_putc(&path, 'z'));
+ cl_git_pass(git_str_putc(&path, 'z'));
cl_git_fail(git_repository_init(&two, path.ptr, 1));
git_repository_free(one);
git_repository_free(two);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
#endif
}
diff --git a/tests/repo/message.c b/tests/repo/message.c
index 14577c8f0..6241f48f9 100644
--- a/tests/repo/message.c
+++ b/tests/repo/message.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "refs.h"
#include "posix.h"
@@ -23,17 +22,18 @@ void test_repo_message__none(void)
void test_repo_message__message(void)
{
- git_buf path = GIT_BUF_INIT, actual = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
+ git_buf actual = GIT_BUF_INIT;
const char expected[] = "Test\n\nThis is a test of the emergency broadcast system\n";
- cl_git_pass(git_buf_joinpath(&path, git_repository_path(_repo), "MERGE_MSG"));
- cl_git_mkfile(git_buf_cstr(&path), expected);
+ cl_git_pass(git_str_joinpath(&path, git_repository_path(_repo), "MERGE_MSG"));
+ cl_git_mkfile(git_str_cstr(&path), expected);
cl_git_pass(git_repository_message(&actual, _repo));
- cl_assert_equal_s(expected, git_buf_cstr(&actual));
+ cl_assert_equal_s(expected, actual.ptr);
git_buf_dispose(&actual);
- cl_git_pass(p_unlink(git_buf_cstr(&path)));
+ cl_git_pass(p_unlink(git_str_cstr(&path)));
cl_assert_equal_i(GIT_ENOTFOUND, git_repository_message(&actual, _repo));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
diff --git a/tests/repo/open.c b/tests/repo/open.c
index bd60c12c2..6558805c8 100644
--- a/tests/repo/open.c
+++ b/tests/repo/open.c
@@ -105,12 +105,12 @@ void test_repo_open__check_if_repository(void)
static void make_gitlink_dir(const char *dir, const char *linktext)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cl_git_pass(git_futils_mkdir(dir, 0777, GIT_MKDIR_VERIFY_DIR));
- cl_git_pass(git_buf_joinpath(&path, dir, ".git"));
+ cl_git_pass(git_str_joinpath(&path, dir, ".git"));
cl_git_rewritefile(path.ptr, linktext);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_repo_open__gitlinked(void)
@@ -136,7 +136,7 @@ void test_repo_open__gitlinked(void)
void test_repo_open__with_symlinked_config(void)
{
#ifndef GIT_WIN32
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_repository *repo;
git_config *cfg;
int32_t value;
@@ -157,9 +157,9 @@ void test_repo_open__with_symlinked_config(void)
git_config_free(cfg);
git_repository_free(repo);
- cl_git_pass(git_futils_rmdir_r(git_buf_cstr(&path), NULL, GIT_RMDIR_REMOVE_FILES));
+ cl_git_pass(git_futils_rmdir_r(git_str_cstr(&path), NULL, GIT_RMDIR_REMOVE_FILES));
cl_sandbox_set_search_path_defaults();
- git_buf_dispose(&path);
+ git_str_dispose(&path);
#endif
}
@@ -173,7 +173,7 @@ void test_repo_open__from_git_new_workdir(void)
*/
git_repository *repo2;
- git_buf link_tgt = GIT_BUF_INIT, link = GIT_BUF_INIT, body = GIT_BUF_INIT;
+ git_str link_tgt = GIT_STR_INIT, link = GIT_STR_INIT, body = GIT_STR_INIT;
const char **scan;
int link_fd;
static const char *links[] = {
@@ -190,19 +190,19 @@ void test_repo_open__from_git_new_workdir(void)
cl_git_pass(p_mkdir("alternate/.git", 0777));
for (scan = links; *scan != NULL; scan++) {
- git_buf_joinpath(&link_tgt, "empty_standard_repo/.git", *scan);
+ git_str_joinpath(&link_tgt, "empty_standard_repo/.git", *scan);
if (git_path_exists(link_tgt.ptr)) {
- git_buf_joinpath(&link_tgt, "../../empty_standard_repo/.git", *scan);
- git_buf_joinpath(&link, "alternate/.git", *scan);
+ git_str_joinpath(&link_tgt, "../../empty_standard_repo/.git", *scan);
+ git_str_joinpath(&link, "alternate/.git", *scan);
if (strchr(*scan, '/'))
git_futils_mkpath2file(link.ptr, 0777);
cl_assert_(symlink(link_tgt.ptr, link.ptr) == 0, strerror(errno));
}
}
for (scan = copies; *scan != NULL; scan++) {
- git_buf_joinpath(&link_tgt, "empty_standard_repo/.git", *scan);
+ git_str_joinpath(&link_tgt, "empty_standard_repo/.git", *scan);
if (git_path_exists(link_tgt.ptr)) {
- git_buf_joinpath(&link, "alternate/.git", *scan);
+ git_str_joinpath(&link, "alternate/.git", *scan);
cl_git_pass(git_futils_readbuffer(&body, link_tgt.ptr));
cl_assert((link_fd = git_futils_creat_withpath(link.ptr, 0777, 0666)) >= 0);
@@ -211,9 +211,9 @@ void test_repo_open__from_git_new_workdir(void)
}
}
- git_buf_dispose(&link_tgt);
- git_buf_dispose(&link);
- git_buf_dispose(&body);
+ git_str_dispose(&link_tgt);
+ git_str_dispose(&link);
+ git_str_dispose(&body);
cl_git_pass(git_repository_open(&repo2, "alternate"));
@@ -233,10 +233,10 @@ void test_repo_open__from_git_new_workdir(void)
void test_repo_open__failures(void)
{
git_repository *base, *repo;
- git_buf ceiling = GIT_BUF_INIT;
+ git_str ceiling = GIT_STR_INIT;
base = cl_git_sandbox_init("attr");
- cl_git_pass(git_buf_sets(&ceiling, git_repository_workdir(base)));
+ cl_git_pass(git_str_sets(&ceiling, git_repository_workdir(base)));
/* fail with no searching */
cl_git_fail(git_repository_open(&repo, "attr/sub"));
@@ -245,7 +245,7 @@ void test_repo_open__failures(void)
/* fail with ceiling too low */
cl_git_fail(git_repository_open_ext(&repo, "attr/sub", 0, ceiling.ptr));
- cl_git_pass(git_buf_joinpath(&ceiling, ceiling.ptr, "sub"));
+ cl_git_pass(git_str_joinpath(&ceiling, ceiling.ptr, "sub"));
cl_git_fail(git_repository_open_ext(&repo, "attr/sub/sub", 0, ceiling.ptr));
/* fail with no repo */
@@ -260,7 +260,7 @@ void test_repo_open__failures(void)
GIT_REPOSITORY_OPEN_NO_SEARCH | GIT_REPOSITORY_OPEN_NO_DOTGIT,
NULL));
- git_buf_dispose(&ceiling);
+ git_str_dispose(&ceiling);
}
void test_repo_open__bad_gitlinks(void)
@@ -291,7 +291,7 @@ void test_repo_open__bad_gitlinks(void)
}
#ifdef GIT_WIN32
-static void unposix_path(git_buf *path)
+static void unposix_path(git_str *path)
{
char *src, *tgt;
@@ -318,44 +318,44 @@ void test_repo_open__win32_path(void)
{
#ifdef GIT_WIN32
git_repository *repo = cl_git_sandbox_init("empty_standard_repo"), *repo2;
- git_buf winpath = GIT_BUF_INIT;
+ git_str winpath = GIT_STR_INIT;
static const char *repo_path = "empty_standard_repo/.git/";
static const char *repo_wd = "empty_standard_repo/";
cl_assert(git__suffixcmp(git_repository_path(repo), repo_path) == 0);
cl_assert(git__suffixcmp(git_repository_workdir(repo), repo_wd) == 0);
- cl_git_pass(git_buf_sets(&winpath, git_repository_path(repo)));
+ cl_git_pass(git_str_sets(&winpath, git_repository_path(repo)));
unposix_path(&winpath);
cl_git_pass(git_repository_open(&repo2, winpath.ptr));
cl_assert(git__suffixcmp(git_repository_path(repo2), repo_path) == 0);
cl_assert(git__suffixcmp(git_repository_workdir(repo2), repo_wd) == 0);
git_repository_free(repo2);
- cl_git_pass(git_buf_sets(&winpath, git_repository_path(repo)));
- git_buf_truncate(&winpath, winpath.size - 1); /* remove trailing '/' */
+ cl_git_pass(git_str_sets(&winpath, git_repository_path(repo)));
+ git_str_truncate(&winpath, winpath.size - 1); /* remove trailing '/' */
unposix_path(&winpath);
cl_git_pass(git_repository_open(&repo2, winpath.ptr));
cl_assert(git__suffixcmp(git_repository_path(repo2), repo_path) == 0);
cl_assert(git__suffixcmp(git_repository_workdir(repo2), repo_wd) == 0);
git_repository_free(repo2);
- cl_git_pass(git_buf_sets(&winpath, git_repository_workdir(repo)));
+ cl_git_pass(git_str_sets(&winpath, git_repository_workdir(repo)));
unposix_path(&winpath);
cl_git_pass(git_repository_open(&repo2, winpath.ptr));
cl_assert(git__suffixcmp(git_repository_path(repo2), repo_path) == 0);
cl_assert(git__suffixcmp(git_repository_workdir(repo2), repo_wd) == 0);
git_repository_free(repo2);
- cl_git_pass(git_buf_sets(&winpath, git_repository_workdir(repo)));
- git_buf_truncate(&winpath, winpath.size - 1); /* remove trailing '/' */
+ cl_git_pass(git_str_sets(&winpath, git_repository_workdir(repo)));
+ git_str_truncate(&winpath, winpath.size - 1); /* remove trailing '/' */
unposix_path(&winpath);
cl_git_pass(git_repository_open(&repo2, winpath.ptr));
cl_assert(git__suffixcmp(git_repository_path(repo2), repo_path) == 0);
cl_assert(git__suffixcmp(git_repository_workdir(repo2), repo_wd) == 0);
git_repository_free(repo2);
- git_buf_dispose(&winpath);
+ git_str_dispose(&winpath);
#endif
}
@@ -367,7 +367,7 @@ void test_repo_open__opening_a_non_existing_repository_returns_ENOTFOUND(void)
void test_repo_open__no_config(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_repository *repo;
git_config *config;
@@ -389,7 +389,7 @@ void test_repo_open__no_config(void)
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_XDG, path.ptr));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
cl_git_pass(git_repository_open(&repo, "empty_standard_repo"));
cl_git_pass(git_repository_config(&config, repo));
diff --git a/tests/repo/repo_helpers.c b/tests/repo/repo_helpers.c
index b22f3f6ba..1efde70a5 100644
--- a/tests/repo/repo_helpers.c
+++ b/tests/repo/repo_helpers.c
@@ -13,25 +13,25 @@ void make_head_unborn(git_repository* repo, const char *target)
void delete_head(git_repository* repo)
{
- git_buf head_path = GIT_BUF_INIT;
+ git_str head_path = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&head_path, git_repository_path(repo), GIT_HEAD_FILE));
- cl_git_pass(p_unlink(git_buf_cstr(&head_path)));
+ cl_git_pass(git_str_joinpath(&head_path, git_repository_path(repo), GIT_HEAD_FILE));
+ cl_git_pass(p_unlink(git_str_cstr(&head_path)));
- git_buf_dispose(&head_path);
+ git_str_dispose(&head_path);
}
void create_tmp_global_config(const char *dirname, const char *key, const char *val)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_config *config;
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH,
GIT_CONFIG_LEVEL_GLOBAL, dirname));
cl_must_pass(p_mkdir(dirname, 0777));
- cl_git_pass(git_buf_joinpath(&path, dirname, ".gitconfig"));
+ cl_git_pass(git_str_joinpath(&path, dirname, ".gitconfig"));
cl_git_pass(git_config_open_ondisk(&config, path.ptr));
cl_git_pass(git_config_set_string(config, key, val));
git_config_free(config);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
diff --git a/tests/repo/reservedname.c b/tests/repo/reservedname.c
index 8e024bcbb..245d8625a 100644
--- a/tests/repo/reservedname.c
+++ b/tests/repo/reservedname.c
@@ -10,7 +10,7 @@ void test_repo_reservedname__cleanup(void)
void test_repo_reservedname__includes_shortname_on_win32(void)
{
git_repository *repo;
- git_buf *reserved;
+ git_str *reserved;
size_t reserved_len;
repo = cl_git_sandbox_init("nasty");
@@ -29,7 +29,7 @@ void test_repo_reservedname__includes_shortname_on_win32(void)
void test_repo_reservedname__includes_shortname_when_requested(void)
{
git_repository *repo;
- git_buf *reserved;
+ git_str *reserved;
size_t reserved_len;
repo = cl_git_sandbox_init("nasty");
@@ -47,7 +47,7 @@ void test_repo_reservedname__custom_shortname_recognized(void)
{
#ifdef GIT_WIN32
git_repository *repo;
- git_buf *reserved;
+ git_str *reserved;
size_t reserved_len;
if (!cl_sandbox_supports_8dot3())
@@ -83,7 +83,7 @@ void test_repo_reservedname__submodule_pointer(void)
#ifdef GIT_WIN32
git_repository *super_repo, *sub_repo;
git_submodule *sub;
- git_buf *sub_reserved;
+ git_str *sub_reserved;
size_t sub_reserved_len;
if (!cl_sandbox_supports_8dot3())
@@ -117,16 +117,16 @@ void test_repo_reservedname__submodule_pointer_during_create(void)
git_repository *repo;
git_submodule *sm;
git_submodule_update_options update_options = GIT_SUBMODULE_UPDATE_OPTIONS_INIT;
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
repo = setup_fixture_super();
- cl_git_pass(git_buf_joinpath(&url, clar_sandbox_path(), "sub.git"));
+ cl_git_pass(git_str_joinpath(&url, clar_sandbox_path(), "sub.git"));
cl_repo_set_string(repo, "submodule.sub.url", url.ptr);
cl_git_pass(git_submodule_lookup(&sm, repo, "sub"));
cl_git_pass(git_submodule_update(sm, 1, &update_options));
git_submodule_free(sm);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
diff --git a/tests/repo/setters.c b/tests/repo/setters.c
index 1fac627f6..2c33db0db 100644
--- a/tests/repo/setters.c
+++ b/tests/repo/setters.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "git2/sys/repository.h"
-#include "buffer.h"
#include "posix.h"
#include "util.h"
#include "path.h"
@@ -47,20 +46,20 @@ void test_repo_setters__setting_a_workdir_creates_a_gitlink(void)
{
git_config *cfg;
git_buf buf = GIT_BUF_INIT;
- git_buf content = GIT_BUF_INIT;
+ git_str content = GIT_STR_INIT;
cl_git_pass(git_repository_set_workdir(repo, "./new_workdir", true));
cl_assert(git_path_isfile("./new_workdir/.git"));
cl_git_pass(git_futils_readbuffer(&content, "./new_workdir/.git"));
- cl_assert(git__prefixcmp(git_buf_cstr(&content), "gitdir: ") == 0);
- cl_assert(git__suffixcmp(git_buf_cstr(&content), "testrepo.git/") == 0);
- git_buf_dispose(&content);
+ cl_assert(git__prefixcmp(git_str_cstr(&content), "gitdir: ") == 0);
+ cl_assert(git__suffixcmp(git_str_cstr(&content), "testrepo.git/") == 0);
+ git_str_dispose(&content);
cl_git_pass(git_repository_config(&cfg, repo));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "core.worktree"));
- cl_assert(git__suffixcmp(git_buf_cstr(&buf), "new_workdir/") == 0);
+ cl_assert(git__suffixcmp(buf.ptr, "new_workdir/") == 0);
git_buf_dispose(&buf);
git_config_free(cfg);
@@ -81,7 +80,7 @@ void test_repo_setters__setting_a_new_index_on_a_repo_which_has_already_loaded_o
git_index_free(new_index);
- /*
+ /*
* Ensure the cleanup method won't try to free the repo as it's already been taken care of
*/
repo = NULL;
@@ -102,7 +101,7 @@ void test_repo_setters__setting_a_new_odb_on_a_repo_which_already_loaded_one_pro
git_odb_free(new_odb);
- /*
+ /*
* Ensure the cleanup method won't try to free the repo as it's already been taken care of
*/
repo = NULL;
diff --git a/tests/repo/state.c b/tests/repo/state.c
index afb361787..92b272dce 100644
--- a/tests/repo/state.c
+++ b/tests/repo/state.c
@@ -1,11 +1,10 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "refs.h"
#include "posix.h"
#include "futils.h"
static git_repository *_repo;
-static git_buf _path;
+static git_str _path;
void test_repo_state__initialize(void)
{
@@ -15,14 +14,14 @@ void test_repo_state__initialize(void)
void test_repo_state__cleanup(void)
{
cl_git_sandbox_cleanup();
- git_buf_dispose(&_path);
+ git_str_dispose(&_path);
}
static void setup_simple_state(const char *filename)
{
- cl_git_pass(git_buf_joinpath(&_path, git_repository_path(_repo), filename));
- git_futils_mkpath2file(git_buf_cstr(&_path), 0777);
- cl_git_mkfile(git_buf_cstr(&_path), "dummy");
+ cl_git_pass(git_str_joinpath(&_path, git_repository_path(_repo), filename));
+ git_futils_mkpath2file(git_str_cstr(&_path), 0777);
+ cl_git_mkfile(git_str_cstr(&_path), "dummy");
}
static void assert_repo_state(git_repository_state_t state)
diff --git a/tests/repo/template.c b/tests/repo/template.c
index 3513190ac..6f369c6d6 100644
--- a/tests/repo/template.c
+++ b/tests/repo/template.c
@@ -7,7 +7,7 @@
static git_repository *_repo = NULL;
static mode_t g_umask = 0;
-static git_buf _global_path = GIT_BUF_INIT;
+static git_str _global_path = GIT_STR_INIT;
static const char *fixture_repo;
static const char *fixture_templates;
@@ -27,7 +27,7 @@ void test_repo_template__cleanup(void)
{
git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL,
_global_path.ptr);
- git_buf_dispose(&_global_path);
+ git_str_dispose(&_global_path);
cl_fixture_cleanup("tmp_global_path");
@@ -51,14 +51,14 @@ static void assert_hooks_match(
const char *hook_path,
bool core_filemode)
{
- git_buf expected = GIT_BUF_INIT;
- git_buf actual = GIT_BUF_INIT;
+ git_str expected = GIT_STR_INIT;
+ git_str actual = GIT_STR_INIT;
struct stat expected_st, st;
- cl_git_pass(git_buf_joinpath(&expected, template_dir, hook_path));
+ cl_git_pass(git_str_joinpath(&expected, template_dir, hook_path));
cl_git_pass(git_path_lstat(expected.ptr, &expected_st));
- cl_git_pass(git_buf_joinpath(&actual, repo_dir, hook_path));
+ cl_git_pass(git_str_joinpath(&actual, repo_dir, hook_path));
cl_git_pass(git_path_lstat(actual.ptr, &st));
cl_assert(expected_st.st_size == st.st_size);
@@ -76,20 +76,20 @@ static void assert_hooks_match(
cl_assert_equal_i_fmt(expected_mode, st.st_mode, "%07o");
}
- git_buf_dispose(&expected);
- git_buf_dispose(&actual);
+ git_str_dispose(&expected);
+ git_str_dispose(&actual);
}
static void assert_mode_seems_okay(
const char *base, const char *path,
git_filemode_t expect_mode, bool expect_setgid, bool core_filemode)
{
- git_buf full = GIT_BUF_INIT;
+ git_str full = GIT_STR_INIT;
struct stat st;
- cl_git_pass(git_buf_joinpath(&full, base, path));
+ cl_git_pass(git_str_joinpath(&full, base, path));
cl_git_pass(git_path_lstat(full.ptr, &st));
- git_buf_dispose(&full);
+ git_str_dispose(&full);
if (!core_filemode) {
CLEAR_FOR_CORE_FILEMODE(expect_mode);
@@ -115,7 +115,7 @@ static void setup_repo(const char *name, git_repository_init_options *opts)
static void setup_templates(const char *name, bool setup_globally)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cl_fixture_sandbox("template");
if (strcmp(name, "template"))
@@ -127,40 +127,40 @@ static void setup_templates(const char *name, bool setup_globally)
* Create a symlink from link.sample to update.sample if the filesystem
* supports it.
*/
- cl_git_pass(git_buf_join3(&path, '/', name, "hooks", "link.sample"));
+ cl_git_pass(git_str_join3(&path, '/', name, "hooks", "link.sample"));
#ifdef GIT_WIN32
cl_git_mkfile(path.ptr, "#!/bin/sh\necho hello, world\n");
#else
cl_must_pass(p_symlink("update.sample", path.ptr));
#endif
- git_buf_clear(&path);
+ git_str_clear(&path);
/* Create a file starting with a dot */
- cl_git_pass(git_buf_join3(&path, '/', name, "hooks", ".dotfile"));
+ cl_git_pass(git_str_join3(&path, '/', name, "hooks", ".dotfile"));
cl_git_mkfile(path.ptr, "something\n");
- git_buf_clear(&path);
+ git_str_clear(&path);
if (setup_globally) {
- cl_git_pass(git_buf_joinpath(&path, clar_sandbox_path(), name));
+ cl_git_pass(git_str_joinpath(&path, clar_sandbox_path(), name));
create_tmp_global_config("tmp_global_path", "init.templatedir", path.ptr);
}
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
static void validate_templates(git_repository *repo, const char *template_path)
{
- git_buf path = GIT_BUF_INIT, expected = GIT_BUF_INIT, actual = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT, expected = GIT_STR_INIT, actual = GIT_STR_INIT;
int filemode;
- cl_git_pass(git_buf_joinpath(&path, template_path, "description"));
+ cl_git_pass(git_str_joinpath(&path, template_path, "description"));
cl_git_pass(git_futils_readbuffer(&expected, path.ptr));
- git_buf_clear(&path);
+ git_str_clear(&path);
- cl_git_pass(git_buf_joinpath(&path, git_repository_path(repo), "description"));
+ cl_git_pass(git_str_joinpath(&path, git_repository_path(repo), "description"));
cl_git_pass(git_futils_readbuffer(&actual, path.ptr));
cl_assert_equal_s(expected.ptr, actual.ptr);
@@ -177,9 +177,9 @@ static void validate_templates(git_repository *repo, const char *template_path)
template_path, git_repository_path(repo),
"hooks/.dotfile", filemode);
- git_buf_dispose(&expected);
- git_buf_dispose(&actual);
- git_buf_dispose(&path);
+ git_str_dispose(&expected);
+ git_str_dispose(&actual);
+ git_str_dispose(&path);
}
void test_repo_template__external_templates_specified_in_options(void)
@@ -252,7 +252,7 @@ void test_repo_template__extended_with_template_and_shared_mode(void)
void test_repo_template__templated_head_is_used(void)
{
git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
- git_buf head = GIT_BUF_INIT;
+ git_str head = GIT_STR_INIT;
opts.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE;
@@ -263,13 +263,13 @@ void test_repo_template__templated_head_is_used(void)
cl_git_pass(git_futils_readbuffer(&head, "repo/.git/HEAD"));
cl_assert_equal_s("foobar\n", head.ptr);
- git_buf_dispose(&head);
+ git_str_dispose(&head);
}
void test_repo_template__initial_head_option_overrides_template_head(void)
{
git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
- git_buf head = GIT_BUF_INIT;
+ git_str head = GIT_STR_INIT;
opts.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE;
opts.initial_head = "manual";
@@ -281,7 +281,7 @@ void test_repo_template__initial_head_option_overrides_template_head(void)
cl_git_pass(git_futils_readbuffer(&head, "repo/.git/HEAD"));
cl_assert_equal_s("ref: refs/heads/manual\n", head.ptr);
- git_buf_dispose(&head);
+ git_str_dispose(&head);
}
void test_repo_template__empty_template_path(void)