summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/apply/fromdiff.c26
-rw-r--r--tests/apply/fromfile.c8
-rw-r--r--tests/apply/partial.c8
-rw-r--r--tests/attr/repo.c26
-rw-r--r--tests/buf/basic.c51
-rw-r--r--tests/buf/splice.c93
-rw-r--r--tests/checkout/checkout_helpers.c6
-rw-r--r--tests/checkout/checkout_helpers.h1
-rw-r--r--tests/checkout/conflict.c38
-rw-r--r--tests/checkout/crlf.c84
-rw-r--r--tests/checkout/icase.c8
-rw-r--r--tests/checkout/index.c18
-rw-r--r--tests/checkout/nasty.c13
-rw-r--r--tests/checkout/tree.c23
-rw-r--r--tests/checkout/typechange.c22
-rw-r--r--tests/cherrypick/bare.c1
-rw-r--r--tests/cherrypick/workdir.c19
-rw-r--r--tests/clar_libgit2.c74
-rw-r--r--tests/clar_libgit2_timer.c1
-rw-r--r--tests/clone/local.c57
-rw-r--r--tests/clone/nonetwork.c14
-rw-r--r--tests/commit/parse.c18
-rw-r--r--tests/config/conditionals.c34
-rw-r--r--tests/config/config_helpers.c5
-rw-r--r--tests/config/configlevel.c2
-rw-r--r--tests/config/global.c19
-rw-r--r--tests/config/include.c45
-rw-r--r--tests/config/new.c6
-rw-r--r--tests/config/read.c55
-rw-r--r--tests/config/stress.c4
-rw-r--r--tests/config/write.c49
-rw-r--r--tests/core/buf.c54
-rw-r--r--tests/core/dirent.c18
-rw-r--r--tests/core/env.c50
-rw-r--r--tests/core/filebuf.c10
-rw-r--r--tests/core/futils.c28
-rw-r--r--tests/core/gitstr.c (renamed from tests/core/buffer.c)793
-rw-r--r--tests/core/link.c119
-rw-r--r--tests/core/mkdir.c20
-rw-r--r--tests/core/path.c106
-rw-r--r--tests/core/posix.c12
-rw-r--r--tests/core/rmdir.c66
-rw-r--r--tests/core/sortedcache.c4
-rw-r--r--tests/core/stat.c6
-rw-r--r--tests/core/useragent.c4
-rw-r--r--tests/core/zstream.c35
-rw-r--r--tests/describe/describe.c4
-rw-r--r--tests/describe/describe_helpers.c4
-rw-r--r--tests/describe/describe_helpers.h1
-rw-r--r--tests/diff/binary.c35
-rw-r--r--tests/diff/blob.c16
-rw-r--r--tests/diff/drivers.c19
-rw-r--r--tests/diff/format_email.c9
-rw-r--r--tests/diff/parse.c14
-rw-r--r--tests/diff/patch.c50
-rw-r--r--tests/diff/rename.c70
-rw-r--r--tests/diff/stats.c37
-rw-r--r--tests/diff/submodules.c2
-rw-r--r--tests/diff/workdir.c29
-rw-r--r--tests/email/create.c17
-rw-r--r--tests/fetchhead/nonetwork.c16
-rw-r--r--tests/filter/crlf.c1
-rw-r--r--tests/filter/custom_helpers.c12
-rw-r--r--tests/filter/custom_helpers.h8
-rw-r--r--tests/filter/file.c7
-rw-r--r--tests/filter/query.c1
-rw-r--r--tests/filter/stream.c6
-rw-r--r--tests/filter/systemattrs.c14
-rw-r--r--tests/filter/wildcard.c4
-rw-r--r--tests/graph/commit_graph.c37
-rw-r--r--tests/graph/reachable_from_any.c10
-rw-r--r--tests/ignore/status.c8
-rw-r--r--tests/index/crlf.c84
-rw-r--r--tests/index/filemodes.c11
-rw-r--r--tests/index/nsec.c6
-rw-r--r--tests/index/racy.c25
-rw-r--r--tests/index/tests.c30
-rw-r--r--tests/iterator/index.c18
-rw-r--r--tests/iterator/tree.c6
-rw-r--r--tests/iterator/workdir.c18
-rw-r--r--tests/mailmap/parsing.c10
-rw-r--r--tests/merge/analysis.c24
-rw-r--r--tests/merge/driver.c28
-rw-r--r--tests/merge/files.c1
-rw-r--r--tests/merge/merge_helpers.c32
-rw-r--r--tests/merge/trees/automerge.c1
-rw-r--r--tests/merge/trees/modeconflict.c1
-rw-r--r--tests/merge/trees/renames.c9
-rw-r--r--tests/merge/trees/trivial.c10
-rw-r--r--tests/merge/trees/whitespace.c1
-rw-r--r--tests/merge/workdir/dirty.c31
-rw-r--r--tests/merge/workdir/recursive.c8
-rw-r--r--tests/merge/workdir/renames.c1
-rw-r--r--tests/merge/workdir/setup.c58
-rw-r--r--tests/merge/workdir/simple.c37
-rw-r--r--tests/merge/workdir/submodules.c1
-rw-r--r--tests/merge/workdir/trivial.c10
-rw-r--r--tests/message/trailer.c1
-rw-r--r--tests/network/fetchlocal.c1
-rw-r--r--tests/network/remote/defaultbranch.c1
-rw-r--r--tests/network/remote/local.c17
-rw-r--r--tests/network/remote/remotes.c41
-rw-r--r--tests/notes/notes.c4
-rw-r--r--tests/notes/notesref.c3
-rw-r--r--tests/object/blob/filter.c18
-rw-r--r--tests/object/blob/fromstream.c13
-rw-r--r--tests/object/blob/write.c17
-rw-r--r--tests/object/commit/commitstagedfile.c3
-rw-r--r--tests/object/lookup.c18
-rw-r--r--tests/object/message.c4
-rw-r--r--tests/object/raw/hash.c2
-rw-r--r--tests/object/tree/write.c6
-rw-r--r--tests/odb/alternates.c20
-rw-r--r--tests/odb/foreach.c7
-rw-r--r--tests/odb/freshen.c10
-rw-r--r--tests/odb/largefiles.c10
-rw-r--r--tests/online/clone.c46
-rw-r--r--tests/online/customcert.c10
-rw-r--r--tests/online/fetch.c6
-rw-r--r--tests/online/fetchhead.c8
-rw-r--r--tests/online/push.c43
-rw-r--r--tests/online/push_util.c24
-rw-r--r--tests/pack/filelimit.c18
-rw-r--r--tests/pack/indexer.c26
-rw-r--r--tests/pack/midx.c51
-rw-r--r--tests/pack/packbuilder.c10
-rw-r--r--tests/patch/parse.c12
-rw-r--r--tests/path/core.c14
-rw-r--r--tests/rebase/sign.c14
-rw-r--r--tests/rebase/submodule.c8
-rw-r--r--tests/refs/basic.c10
-rw-r--r--tests/refs/branches/create.c8
-rw-r--r--tests/refs/branches/delete.c20
-rw-r--r--tests/refs/branches/move.c25
-rw-r--r--tests/refs/branches/remote.c9
-rw-r--r--tests/refs/branches/upstreamname.c5
-rw-r--r--tests/refs/delete.c6
-rw-r--r--tests/refs/pack.c14
-rw-r--r--tests/refs/read.c6
-rw-r--r--tests/refs/ref_helpers.c7
-rw-r--r--tests/refs/reflog/messages.c8
-rw-r--r--tests/refs/reflog/reflog.c86
-rw-r--r--tests/refs/reflog/reflog_helpers.c32
-rw-r--r--tests/refs/rename.c22
-rw-r--r--tests/refs/revparse.c21
-rw-r--r--tests/remote/fetch.c16
-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
-rw-r--r--tests/reset/hard.c62
-rw-r--r--tests/reset/mixed.c12
-rw-r--r--tests/reset/soft.c18
-rw-r--r--tests/revert/bare.c1
-rw-r--r--tests/revert/workdir.c11
-rw-r--r--tests/stash/apply.c8
-rw-r--r--tests/stash/save.c8
-rw-r--r--tests/status/renames.c11
-rw-r--r--tests/status/worktree.c84
-rw-r--r--tests/str/basic.c50
-rw-r--r--tests/str/oom.c (renamed from tests/buf/oom.c)31
-rw-r--r--tests/str/percent.c (renamed from tests/buf/percent.c)21
-rw-r--r--tests/str/quote.c (renamed from tests/buf/quote.c)39
-rw-r--r--tests/str/splice.c92
-rw-r--r--tests/stress/diff.c12
-rw-r--r--tests/submodule/add.c22
-rw-r--r--tests/submodule/escape.c12
-rw-r--r--tests/submodule/init.c18
-rw-r--r--tests/submodule/inject_option.c12
-rw-r--r--tests/submodule/lookup.c12
-rw-r--r--tests/submodule/modify.c6
-rw-r--r--tests/submodule/nosubs.c4
-rw-r--r--tests/submodule/open.c34
-rw-r--r--tests/submodule/repository_init.c4
-rw-r--r--tests/submodule/status.c6
-rw-r--r--tests/submodule/submodule_helpers.c39
-rw-r--r--tests/valgrind-supp-mac.txt6
-rw-r--r--tests/win32/forbidden.c1
-rw-r--r--tests/win32/longpath.c21
-rw-r--r--tests/worktree/merge.c14
-rw-r--r--tests/worktree/open.c10
-rw-r--r--tests/worktree/refs.c6
-rw-r--r--tests/worktree/submodule.c6
-rw-r--r--tests/worktree/worktree.c102
192 files changed, 2487 insertions, 2483 deletions
diff --git a/tests/apply/fromdiff.c b/tests/apply/fromdiff.c
index 69dfe0987..9da6ac923 100644
--- a/tests/apply/fromdiff.c
+++ b/tests/apply/fromdiff.c
@@ -22,15 +22,15 @@ void test_apply_fromdiff__cleanup(void)
}
static int apply_gitbuf(
- const git_buf *old,
+ const git_str *old,
const char *oldname,
- const git_buf *new,
+ const git_str *new,
const char *newname,
const char *patch_expected,
const git_diff_options *diff_opts)
{
git_patch *patch;
- git_buf result = GIT_BUF_INIT;
+ git_str result = GIT_STR_INIT;
git_buf patchbuf = GIT_BUF_INIT;
char *filename;
unsigned int mode;
@@ -62,7 +62,7 @@ static int apply_gitbuf(
}
git__free(filename);
- git_buf_dispose(&result);
+ git_str_dispose(&result);
git_buf_dispose(&patchbuf);
git_patch_free(patch);
@@ -77,7 +77,7 @@ static int apply_buf(
const char *patch_expected,
const git_diff_options *diff_opts)
{
- git_buf o = GIT_BUF_INIT, n = GIT_BUF_INIT,
+ git_str o = GIT_STR_INIT, n = GIT_STR_INIT,
*optr = NULL, *nptr = NULL;
if (old) {
@@ -275,7 +275,7 @@ void test_apply_fromdiff__no_change(void)
void test_apply_fromdiff__binary_add(void)
{
- git_buf newfile = GIT_BUF_INIT;
+ git_str newfile = GIT_STR_INIT;
newfile.ptr = FILE_BINARY_DELTA_MODIFIED;
newfile.size = FILE_BINARY_DELTA_MODIFIED_LEN;
@@ -288,7 +288,7 @@ void test_apply_fromdiff__binary_add(void)
void test_apply_fromdiff__binary_no_change(void)
{
- git_buf original = GIT_BUF_INIT;
+ git_str original = GIT_STR_INIT;
original.ptr = FILE_BINARY_DELTA_ORIGINAL;
original.size = FILE_BINARY_DELTA_ORIGINAL_LEN;
@@ -301,7 +301,7 @@ void test_apply_fromdiff__binary_no_change(void)
void test_apply_fromdiff__binary_change_delta(void)
{
- git_buf original = GIT_BUF_INIT, modified = GIT_BUF_INIT;
+ git_str original = GIT_STR_INIT, modified = GIT_STR_INIT;
original.ptr = FILE_BINARY_DELTA_ORIGINAL;
original.size = FILE_BINARY_DELTA_ORIGINAL_LEN;
@@ -317,7 +317,7 @@ void test_apply_fromdiff__binary_change_delta(void)
void test_apply_fromdiff__binary_change_literal(void)
{
- git_buf original = GIT_BUF_INIT, modified = GIT_BUF_INIT;
+ git_str original = GIT_STR_INIT, modified = GIT_STR_INIT;
original.ptr = FILE_BINARY_LITERAL_ORIGINAL;
original.size = FILE_BINARY_LITERAL_ORIGINAL_LEN;
@@ -333,7 +333,7 @@ void test_apply_fromdiff__binary_change_literal(void)
void test_apply_fromdiff__binary_delete(void)
{
- git_buf original = GIT_BUF_INIT;
+ git_str original = GIT_STR_INIT;
original.ptr = FILE_BINARY_DELTA_MODIFIED;
original.size = FILE_BINARY_DELTA_MODIFIED_LEN;
@@ -346,7 +346,7 @@ void test_apply_fromdiff__binary_delete(void)
void test_apply_fromdiff__patching_correctly_truncates_source(void)
{
- git_buf original = GIT_BUF_INIT, patched = GIT_BUF_INIT;
+ git_str original = GIT_STR_INIT, patched = GIT_STR_INIT;
git_patch *patch;
unsigned int mode;
char *path;
@@ -371,8 +371,8 @@ void test_apply_fromdiff__patching_correctly_truncates_source(void)
cl_git_pass(git_apply__patch(&patched, &path, &mode,
"foo\nbar\n", 7, patch, NULL));
- git_buf_dispose(&original);
- git_buf_dispose(&patched);
+ git_str_dispose(&original);
+ git_str_dispose(&patched);
git_patch_free(patch);
git__free(path);
}
diff --git a/tests/apply/fromfile.c b/tests/apply/fromfile.c
index ae519eab0..8cde62392 100644
--- a/tests/apply/fromfile.c
+++ b/tests/apply/fromfile.c
@@ -30,8 +30,8 @@ static int apply_patchfile(
unsigned int mode_expected)
{
git_patch *patch;
- git_buf result = GIT_BUF_INIT;
- git_buf patchbuf = GIT_BUF_INIT;
+ git_str result = GIT_STR_INIT;
+ git_str patchbuf = GIT_STR_INIT;
char *filename;
unsigned int mode;
int error;
@@ -50,8 +50,8 @@ static int apply_patchfile(
}
git__free(filename);
- git_buf_dispose(&result);
- git_buf_dispose(&patchbuf);
+ git_str_dispose(&result);
+ git_str_dispose(&patchbuf);
git_patch_free(patch);
return error;
diff --git a/tests/apply/partial.c b/tests/apply/partial.c
index 548faaadb..fd4908d4b 100644
--- a/tests/apply/partial.c
+++ b/tests/apply/partial.c
@@ -83,8 +83,8 @@ static int apply_buf(
void *payload)
{
git_patch *patch;
- git_buf result = GIT_BUF_INIT;
- git_buf patchbuf = GIT_BUF_INIT;
+ git_str result = GIT_STR_INIT;
+ git_str patchbuf = GIT_STR_INIT;
git_apply_options opts = GIT_APPLY_OPTIONS_INIT;
char *filename;
unsigned int mode;
@@ -103,8 +103,8 @@ static int apply_buf(
}
git__free(filename);
- git_buf_dispose(&result);
- git_buf_dispose(&patchbuf);
+ git_str_dispose(&result);
+ git_str_dispose(&patchbuf);
git_patch_free(patch);
return error;
diff --git a/tests/attr/repo.c b/tests/attr/repo.c
index eabc033eb..e7b975290 100644
--- a/tests/attr/repo.c
+++ b/tests/attr/repo.c
@@ -230,12 +230,12 @@ void test_attr_repo__manpage_example(void)
static void add_to_workdir(const char *filename, const char *content)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&buf, "attr", filename));
- cl_git_rewritefile(git_buf_cstr(&buf), content);
+ cl_git_pass(git_str_joinpath(&buf, "attr", filename));
+ cl_git_rewritefile(git_str_cstr(&buf), content);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
static void assert_proper_normalization(git_index *index, const char *filename, const char *expected_sha)
@@ -311,12 +311,12 @@ void test_attr_repo__bare_repo_with_index(void)
void test_attr_repo__sysdir(void)
{
- git_buf sysdir = GIT_BUF_INIT;
+ git_str sysdir = GIT_STR_INIT;
const char *value;
cl_git_pass(p_mkdir("system", 0777));
cl_git_rewritefile("system/gitattributes", "file merge=foo");
- cl_git_pass(git_buf_joinpath(&sysdir, clar_sandbox_path(), "system"));
+ cl_git_pass(git_str_joinpath(&sysdir, clar_sandbox_path(), "system"));
cl_git_pass(git_sysdir_set(GIT_SYSDIR_SYSTEM, sysdir.ptr));
g_repo = cl_git_sandbox_reopen();
@@ -325,18 +325,18 @@ void test_attr_repo__sysdir(void)
cl_git_pass(p_unlink("system/gitattributes"));
cl_git_pass(p_rmdir("system"));
- git_buf_dispose(&sysdir);
+ git_str_dispose(&sysdir);
}
void test_attr_repo__sysdir_with_session(void)
{
const char *values[2], *attrs[2] = { "foo", "bar" };
- git_buf sysdir = GIT_BUF_INIT;
+ git_str sysdir = GIT_STR_INIT;
git_attr_session session;
cl_git_pass(p_mkdir("system", 0777));
cl_git_rewritefile("system/gitattributes", "file foo=1 bar=2");
- cl_git_pass(git_buf_joinpath(&sysdir, clar_sandbox_path(), "system"));
+ cl_git_pass(git_str_joinpath(&sysdir, clar_sandbox_path(), "system"));
cl_git_pass(git_sysdir_set(GIT_SYSDIR_SYSTEM, sysdir.ptr));
g_repo = cl_git_sandbox_reopen();
@@ -348,7 +348,7 @@ void test_attr_repo__sysdir_with_session(void)
cl_git_pass(p_unlink("system/gitattributes"));
cl_git_pass(p_rmdir("system"));
- git_buf_dispose(&sysdir);
+ git_str_dispose(&sysdir);
git_attr_session__free(&session);
}
@@ -371,11 +371,11 @@ void test_attr_repo__rewrite(void)
void test_attr_repo__rewrite_sysdir(void)
{
- git_buf sysdir = GIT_BUF_INIT;
+ git_str sysdir = GIT_STR_INIT;
const char *value;
cl_git_pass(p_mkdir("system", 0777));
- cl_git_pass(git_buf_joinpath(&sysdir, clar_sandbox_path(), "system"));
+ cl_git_pass(git_str_joinpath(&sysdir, clar_sandbox_path(), "system"));
cl_git_pass(git_sysdir_set(GIT_SYSDIR_SYSTEM, sysdir.ptr));
g_repo = cl_git_sandbox_reopen();
@@ -387,7 +387,7 @@ void test_attr_repo__rewrite_sysdir(void)
cl_git_pass(git_attr_get(&value, g_repo, 0, "file", "foo"));
cl_assert_equal_s(value, "second");
- git_buf_dispose(&sysdir);
+ git_str_dispose(&sysdir);
}
void test_attr_repo__unlink(void)
diff --git a/tests/buf/basic.c b/tests/buf/basic.c
deleted file mode 100644
index f90c4c6ed..000000000
--- a/tests/buf/basic.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "clar_libgit2.h"
-#include "buffer.h"
-
-static const char *test_string = "Have you seen that? Have you seeeen that??";
-
-void test_buf_basic__resize(void)
-{
- git_buf buf1 = GIT_BUF_INIT;
- git_buf_puts(&buf1, test_string);
- cl_assert(git_buf_oom(&buf1) == 0);
- cl_assert_equal_s(git_buf_cstr(&buf1), test_string);
-
- git_buf_puts(&buf1, test_string);
- cl_assert(strlen(git_buf_cstr(&buf1)) == strlen(test_string) * 2);
- git_buf_dispose(&buf1);
-}
-
-void test_buf_basic__resize_incremental(void)
-{
- git_buf buf1 = GIT_BUF_INIT;
-
- /* Presently, asking for 6 bytes will round up to 8. */
- cl_git_pass(git_buf_puts(&buf1, "Hello"));
- cl_assert_equal_i(5, buf1.size);
- cl_assert_equal_i(8, buf1.asize);
-
- /* Ensure an additional byte does not realloc. */
- cl_git_pass(git_buf_grow_by(&buf1, 1));
- cl_assert_equal_i(5, buf1.size);
- cl_assert_equal_i(8, buf1.asize);
-
- /* But requesting many does. */
- cl_git_pass(git_buf_grow_by(&buf1, 16));
- cl_assert_equal_i(5, buf1.size);
- cl_assert(buf1.asize > 8);
-
- git_buf_dispose(&buf1);
-}
-
-void test_buf_basic__printf(void)
-{
- git_buf buf2 = GIT_BUF_INIT;
- git_buf_printf(&buf2, "%s %s %d ", "shoop", "da", 23);
- cl_assert(git_buf_oom(&buf2) == 0);
- cl_assert_equal_s(git_buf_cstr(&buf2), "shoop da 23 ");
-
- git_buf_printf(&buf2, "%s %d", "woop", 42);
- cl_assert(git_buf_oom(&buf2) == 0);
- cl_assert_equal_s(git_buf_cstr(&buf2), "shoop da 23 woop 42");
- git_buf_dispose(&buf2);
-}
diff --git a/tests/buf/splice.c b/tests/buf/splice.c
deleted file mode 100644
index 18c7c3f2b..000000000
--- a/tests/buf/splice.c
+++ /dev/null
@@ -1,93 +0,0 @@
-#include "clar_libgit2.h"
-#include "buffer.h"
-
-static git_buf _buf;
-
-void test_buf_splice__initialize(void) {
- git_buf_init(&_buf, 16);
-}
-
-void test_buf_splice__cleanup(void) {
- git_buf_dispose(&_buf);
-}
-
-void test_buf_splice__preprend(void)
-{
- git_buf_sets(&_buf, "world!");
-
- cl_git_pass(git_buf_splice(&_buf, 0, 0, "Hello Dolly", strlen("Hello ")));
-
- cl_assert_equal_s("Hello world!", git_buf_cstr(&_buf));
-}
-
-void test_buf_splice__append(void)
-{
- git_buf_sets(&_buf, "Hello");
-
- cl_git_pass(git_buf_splice(&_buf, git_buf_len(&_buf), 0, " world!", strlen(" world!")));
-
- cl_assert_equal_s("Hello world!", git_buf_cstr(&_buf));
-}
-
-void test_buf_splice__insert_at(void)
-{
- git_buf_sets(&_buf, "Hell world!");
-
- cl_git_pass(git_buf_splice(&_buf, strlen("Hell"), 0, "o", strlen("o")));
-
- cl_assert_equal_s("Hello world!", git_buf_cstr(&_buf));
-}
-
-void test_buf_splice__remove_at(void)
-{
- git_buf_sets(&_buf, "Hello world of warcraft!");
-
- cl_git_pass(git_buf_splice(&_buf, strlen("Hello world"), strlen(" of warcraft"), "", 0));
-
- cl_assert_equal_s("Hello world!", git_buf_cstr(&_buf));
-}
-
-void test_buf_splice__replace(void)
-{
- git_buf_sets(&_buf, "Hell0 w0rld!");
-
- cl_git_pass(git_buf_splice(&_buf, strlen("Hell"), strlen("0 w0"), "o wo", strlen("o wo")));
-
- cl_assert_equal_s("Hello world!", git_buf_cstr(&_buf));
-}
-
-void test_buf_splice__replace_with_longer(void)
-{
- git_buf_sets(&_buf, "Hello you!");
-
- cl_git_pass(git_buf_splice(&_buf, strlen("Hello "), strlen("you"), "world", strlen("world")));
-
- cl_assert_equal_s("Hello world!", git_buf_cstr(&_buf));
-}
-
-void test_buf_splice__replace_with_shorter(void)
-{
- git_buf_sets(&_buf, "Brave new world!");
-
- cl_git_pass(git_buf_splice(&_buf, 0, strlen("Brave new"), "Hello", strlen("Hello")));
-
- cl_assert_equal_s("Hello world!", git_buf_cstr(&_buf));
-}
-
-void test_buf_splice__truncate(void)
-{
- git_buf_sets(&_buf, "Hello world!!");
-
- cl_git_pass(git_buf_splice(&_buf, strlen("Hello world!"), strlen("!"), "", 0));
-
- cl_assert_equal_s("Hello world!", git_buf_cstr(&_buf));
-}
-
-void test_buf_splice__dont_do_anything(void)
-{
- git_buf_sets(&_buf, "Hello world!");
-
- cl_git_pass(git_buf_splice(&_buf, 3, 0, "Hello", 0));
-
- cl_assert_equal_s("Hello world!", git_buf_cstr(&_buf));
-}
diff --git a/tests/checkout/checkout_helpers.c b/tests/checkout/checkout_helpers.c
index 95af5d396..1e9c21bdc 100644
--- a/tests/checkout/checkout_helpers.c
+++ b/tests/checkout/checkout_helpers.c
@@ -7,16 +7,16 @@
void assert_on_branch(git_repository *repo, const char *branch)
{
git_reference *head;
- git_buf bname = GIT_BUF_INIT;
+ git_str bname = GIT_STR_INIT;
cl_git_pass(git_reference_lookup(&head, repo, GIT_HEAD_FILE));
cl_assert_(git_reference_type(head) == GIT_REFERENCE_SYMBOLIC, branch);
- cl_git_pass(git_buf_joinpath(&bname, "refs/heads", branch));
+ cl_git_pass(git_str_joinpath(&bname, "refs/heads", branch));
cl_assert_equal_s(bname.ptr, git_reference_symbolic_target(head));
git_reference_free(head);
- git_buf_dispose(&bname);
+ git_str_dispose(&bname);
}
void reset_index_to_treeish(git_object *treeish)
diff --git a/tests/checkout/checkout_helpers.h b/tests/checkout/checkout_helpers.h
index 6058a196c..879b48b06 100644
--- a/tests/checkout/checkout_helpers.h
+++ b/tests/checkout/checkout_helpers.h
@@ -1,4 +1,3 @@
-#include "buffer.h"
#include "git2/object.h"
#include "git2/repository.h"
diff --git a/tests/checkout/conflict.c b/tests/checkout/conflict.c
index dae3f295e..3f5e7162d 100644
--- a/tests/checkout/conflict.c
+++ b/tests/checkout/conflict.c
@@ -85,14 +85,14 @@ void test_checkout_conflict__cleanup(void)
static void create_index(struct checkout_index_entry *entries, size_t entries_len)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
size_t i;
for (i = 0; i < entries_len; i++) {
- git_buf_joinpath(&path, TEST_REPO_PATH, entries[i].path);
+ git_str_joinpath(&path, TEST_REPO_PATH, entries[i].path);
if (entries[i].stage == 3 && (i == 0 || strcmp(entries[i-1].path, entries[i].path) != 0 || entries[i-1].stage != 2))
- p_unlink(git_buf_cstr(&path));
+ p_unlink(git_str_cstr(&path));
cl_git_pass(git_index_remove_bypath(g_index, entries[i].path));
}
@@ -110,7 +110,7 @@ static void create_index(struct checkout_index_entry *entries, size_t entries_le
cl_git_pass(git_index_add(g_index, &entry));
}
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
static void create_index_names(struct checkout_name_entry *entries, size_t entries_len)
@@ -139,16 +139,16 @@ static void create_conflicting_index(void)
static void ensure_workdir_contents(const char *path, const char *contents)
{
- git_buf fullpath = GIT_BUF_INIT, data_buf = GIT_BUF_INIT;
+ git_str fullpath = GIT_STR_INIT, data_buf = GIT_STR_INIT;
cl_git_pass(
- git_buf_joinpath(&fullpath, git_repository_workdir(g_repo), path));
+ git_str_joinpath(&fullpath, git_repository_workdir(g_repo), path));
- cl_git_pass(git_futils_readbuffer(&data_buf, git_buf_cstr(&fullpath)));
- cl_assert(strcmp(git_buf_cstr(&data_buf), contents) == 0);
+ cl_git_pass(git_futils_readbuffer(&data_buf, git_str_cstr(&fullpath)));
+ cl_assert(strcmp(git_str_cstr(&data_buf), contents) == 0);
- git_buf_dispose(&fullpath);
- git_buf_dispose(&data_buf);
+ git_str_dispose(&fullpath);
+ git_str_dispose(&data_buf);
}
static void ensure_workdir_oid(const char *path, const char *oid_str)
@@ -166,16 +166,16 @@ static void ensure_workdir_mode(const char *path, int mode)
GIT_UNUSED(path);
GIT_UNUSED(mode);
#else
- git_buf fullpath = GIT_BUF_INIT;
+ git_str fullpath = GIT_STR_INIT;
struct stat st;
cl_git_pass(
- git_buf_joinpath(&fullpath, git_repository_workdir(g_repo), path));
+ git_str_joinpath(&fullpath, git_repository_workdir(g_repo), path));
- cl_git_pass(p_stat(git_buf_cstr(&fullpath), &st));
+ cl_git_pass(p_stat(git_str_cstr(&fullpath), &st));
cl_assert_equal_i((mode & S_IRWXU), (st.st_mode & S_IRWXU));
- git_buf_dispose(&fullpath);
+ git_str_dispose(&fullpath);
#endif
}
@@ -197,22 +197,22 @@ static void ensure_workdir_link(
if (!symlinks) {
ensure_workdir_contents(path, target);
} else {
- git_buf fullpath = GIT_BUF_INIT;
+ git_str fullpath = GIT_STR_INIT;
char actual[1024];
struct stat st;
int len;
cl_git_pass(
- git_buf_joinpath(&fullpath, git_repository_workdir(g_repo), path));
+ git_str_joinpath(&fullpath, git_repository_workdir(g_repo), path));
- cl_git_pass(p_lstat(git_buf_cstr(&fullpath), &st));
+ cl_git_pass(p_lstat(git_str_cstr(&fullpath), &st));
cl_assert(S_ISLNK(st.st_mode));
- cl_assert((len = p_readlink(git_buf_cstr(&fullpath), actual, 1024)) > 0);
+ cl_assert((len = p_readlink(git_str_cstr(&fullpath), actual, 1024)) > 0);
actual[len] = '\0';
cl_assert(strcmp(actual, target) == 0);
- git_buf_dispose(&fullpath);
+ git_str_dispose(&fullpath);
}
}
diff --git a/tests/checkout/crlf.c b/tests/checkout/crlf.c
index 495020161..eb4c61f39 100644
--- a/tests/checkout/crlf.c
+++ b/tests/checkout/crlf.c
@@ -11,9 +11,9 @@
static git_repository *g_repo;
static const char *systype;
-static git_buf expected_fixture = GIT_BUF_INIT;
+static git_str expected_fixture = GIT_STR_INIT;
-static int unlink_file(void *payload, git_buf *path)
+static int unlink_file(void *payload, git_str *path)
{
char *fn;
@@ -30,7 +30,7 @@ static int unlink_file(void *payload, git_buf *path)
void test_checkout_crlf__initialize(void)
{
- git_buf reponame = GIT_BUF_INIT;
+ git_str reponame = GIT_STR_INIT;
g_repo = cl_git_sandbox_init("crlf");
@@ -38,7 +38,7 @@ void test_checkout_crlf__initialize(void)
* remove the contents of the working directory so that we can
* check out over it.
*/
- cl_git_pass(git_buf_puts(&reponame, "crlf"));
+ cl_git_pass(git_str_puts(&reponame, "crlf"));
cl_git_pass(git_path_direach(&reponame, 0, unlink_file, NULL));
if (GIT_EOL_NATIVE == GIT_EOL_CRLF)
@@ -46,7 +46,7 @@ void test_checkout_crlf__initialize(void)
else
systype = "posix";
- git_buf_dispose(&reponame);
+ git_str_dispose(&reponame);
}
void test_checkout_crlf__cleanup(void)
@@ -55,7 +55,7 @@ void test_checkout_crlf__cleanup(void)
if (expected_fixture.size) {
cl_fixture_cleanup(expected_fixture.ptr);
- git_buf_dispose(&expected_fixture);
+ git_str_dispose(&expected_fixture);
}
}
@@ -66,11 +66,11 @@ struct compare_data
const char *attrs;
};
-static int compare_file(void *payload, git_buf *actual_path)
+static int compare_file(void *payload, git_str *actual_path)
{
- git_buf expected_path = GIT_BUF_INIT;
- git_buf actual_contents = GIT_BUF_INIT;
- git_buf expected_contents = GIT_BUF_INIT;
+ git_str expected_path = GIT_STR_INIT;
+ git_str actual_contents = GIT_STR_INIT;
+ git_str expected_contents = GIT_STR_INIT;
struct compare_data *cd = payload;
bool failed = true;
int cmp_git, cmp_gitattributes;
@@ -85,7 +85,7 @@ static int compare_file(void *payload, git_buf *actual_path)
goto done;
}
- cl_git_pass(git_buf_joinpath(&expected_path, cd->dirname, basename));
+ cl_git_pass(git_str_joinpath(&expected_path, cd->dirname, basename));
if (!git_path_isfile(expected_path.ptr) ||
!git_path_isfile(actual_path->ptr))
@@ -105,61 +105,61 @@ static int compare_file(void *payload, git_buf *actual_path)
done:
if (failed) {
- git_buf details = GIT_BUF_INIT;
- git_buf_printf(&details, "filename=%s, system=%s, autocrlf=%s, attrs={%s}",
+ git_str details = GIT_STR_INIT;
+ git_str_printf(&details, "filename=%s, system=%s, autocrlf=%s, attrs={%s}",
git_path_basename(actual_path->ptr), systype, cd->autocrlf, cd->attrs);
clar__fail(__FILE__, __func__, __LINE__,
"checked out contents did not match expected", details.ptr, 0);
- git_buf_dispose(&details);
+ git_str_dispose(&details);
}
git__free(basename);
- git_buf_dispose(&expected_contents);
- git_buf_dispose(&actual_contents);
- git_buf_dispose(&expected_path);
+ git_str_dispose(&expected_contents);
+ git_str_dispose(&actual_contents);
+ git_str_dispose(&expected_path);
return 0;
}
static void test_checkout(const char *autocrlf, const char *attrs)
{
- git_buf attrbuf = GIT_BUF_INIT;
- git_buf expected_dirname = GIT_BUF_INIT;
- git_buf systype_and_direction = GIT_BUF_INIT;
- git_buf sandboxname = GIT_BUF_INIT;
- git_buf reponame = GIT_BUF_INIT;
+ git_str attrbuf = GIT_STR_INIT;
+ git_str expected_dirname = GIT_STR_INIT;
+ git_str systype_and_direction = GIT_STR_INIT;
+ git_str sandboxname = GIT_STR_INIT;
+ git_str reponame = GIT_STR_INIT;
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
struct compare_data compare_data = { NULL, autocrlf, attrs };
const char *c;
- cl_git_pass(git_buf_puts(&reponame, "crlf"));
+ cl_git_pass(git_str_puts(&reponame, "crlf"));
- cl_git_pass(git_buf_puts(&systype_and_direction, systype));
- cl_git_pass(git_buf_puts(&systype_and_direction, "_to_workdir"));
+ cl_git_pass(git_str_puts(&systype_and_direction, systype));
+ cl_git_pass(git_str_puts(&systype_and_direction, "_to_workdir"));
- cl_git_pass(git_buf_puts(&sandboxname, "autocrlf_"));
- cl_git_pass(git_buf_puts(&sandboxname, autocrlf));
+ cl_git_pass(git_str_puts(&sandboxname, "autocrlf_"));
+ cl_git_pass(git_str_puts(&sandboxname, autocrlf));
if (*attrs) {
- cl_git_pass(git_buf_puts(&sandboxname, ","));
+ cl_git_pass(git_str_puts(&sandboxname, ","));
for (c = attrs; *c; c++) {
if (*c == ' ')
- cl_git_pass(git_buf_putc(&sandboxname, ','));
+ cl_git_pass(git_str_putc(&sandboxname, ','));
else if (*c == '=')
- cl_git_pass(git_buf_putc(&sandboxname, '_'));
+ cl_git_pass(git_str_putc(&sandboxname, '_'));
else
- cl_git_pass(git_buf_putc(&sandboxname, *c));
+ cl_git_pass(git_str_putc(&sandboxname, *c));
}
- cl_git_pass(git_buf_printf(&attrbuf, "* %s\n", attrs));
+ cl_git_pass(git_str_printf(&attrbuf, "* %s\n", attrs));
cl_git_mkfile("crlf/.gitattributes", attrbuf.ptr);
}
cl_repo_set_string(g_repo, "core.autocrlf", autocrlf);
- cl_git_pass(git_buf_joinpath(&expected_dirname, systype_and_direction.ptr, sandboxname.ptr));
- cl_git_pass(git_buf_joinpath(&expected_fixture, "crlf_data", expected_dirname.ptr));
+ cl_git_pass(git_str_joinpath(&expected_dirname, systype_and_direction.ptr, sandboxname.ptr));
+ cl_git_pass(git_str_joinpath(&expected_fixture, "crlf_data", expected_dirname.ptr));
cl_fixture_sandbox(expected_fixture.ptr);
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
@@ -169,14 +169,14 @@ static void test_checkout(const char *autocrlf, const char *attrs)
cl_git_pass(git_path_direach(&reponame, 0, compare_file, &compare_data));
cl_fixture_cleanup(expected_fixture.ptr);
- git_buf_dispose(&expected_fixture);
-
- git_buf_dispose(&attrbuf);
- git_buf_dispose(&expected_fixture);
- git_buf_dispose(&expected_dirname);
- git_buf_dispose(&sandboxname);
- git_buf_dispose(&systype_and_direction);
- git_buf_dispose(&reponame);
+ git_str_dispose(&expected_fixture);
+
+ git_str_dispose(&attrbuf);
+ git_str_dispose(&expected_fixture);
+ git_str_dispose(&expected_dirname);
+ git_str_dispose(&sandboxname);
+ git_str_dispose(&systype_and_direction);
+ git_str_dispose(&reponame);
}
static void empty_workdir(const char *name)
diff --git a/tests/checkout/icase.c b/tests/checkout/icase.c
index 077d24cd3..6c30765a3 100644
--- a/tests/checkout/icase.c
+++ b/tests/checkout/icase.c
@@ -46,7 +46,7 @@ void test_checkout_icase__cleanup(void)
static char *get_filename(const char *in)
{
char *search_dirname, *search_filename, *filename = NULL;
- git_buf out = GIT_BUF_INIT;
+ git_str out = GIT_STR_INIT;
DIR *dir;
struct dirent *de;
@@ -57,8 +57,8 @@ static char *get_filename(const char *in)
while ((de = readdir(dir))) {
if (strcasecmp(de->d_name, search_filename) == 0) {
- git_buf_join(&out, '/', search_dirname, de->d_name);
- filename = git_buf_detach(&out);
+ git_str_join(&out, '/', search_dirname, de->d_name);
+ filename = git_str_detach(&out);
break;
}
}
@@ -67,7 +67,7 @@ static char *get_filename(const char *in)
git__free(search_dirname);
git__free(search_filename);
- git_buf_dispose(&out);
+ git_str_dispose(&out);
return filename;
}
diff --git a/tests/checkout/index.c b/tests/checkout/index.c
index 508975365..13eecc984 100644
--- a/tests/checkout/index.c
+++ b/tests/checkout/index.c
@@ -8,7 +8,7 @@
#include "repo/repo_helpers.h"
static git_repository *g_repo;
-static git_buf g_global_path = GIT_BUF_INIT;
+static git_str g_global_path = GIT_STR_INIT;
void test_checkout_index__initialize(void)
{
@@ -33,7 +33,7 @@ void test_checkout_index__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_git_sandbox_cleanup();
@@ -203,14 +203,14 @@ void test_checkout_index__honor_coreautocrlf_setting_set_to_true(void)
static void populate_symlink_workdir(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_repository *repo;
git_remote *origin;
git_object *target;
const char *url = git_repository_path(g_repo);
- cl_git_pass(git_buf_joinpath(&path, clar_sandbox_path(), "symlink.git"));
+ cl_git_pass(git_str_joinpath(&path, clar_sandbox_path(), "symlink.git"));
cl_git_pass(git_repository_init(&repo, path.ptr, true));
cl_git_pass(git_repository_set_workdir(repo, "symlink", 1));
@@ -226,7 +226,7 @@ static void populate_symlink_workdir(void)
git_object_free(target);
git_repository_free(repo);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_checkout_index__honor_coresymlinks_default_true(void)
@@ -808,7 +808,7 @@ void test_checkout_index__writes_conflict_file(void)
{
git_index *index;
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
- git_buf conflicting_buf = GIT_BUF_INIT;
+ git_str conflicting_buf = GIT_STR_INIT;
cl_git_pass(git_repository_index(&index, g_repo));
@@ -824,7 +824,7 @@ void test_checkout_index__writes_conflict_file(void)
"=======\n"
"this file is changed in branch and master\n"
">>>>>>> theirs\n") == 0);
- git_buf_dispose(&conflicting_buf);
+ git_str_dispose(&conflicting_buf);
git_index_free(index);
}
@@ -855,7 +855,7 @@ void test_checkout_index__conflicts_honor_coreautocrlf(void)
#ifdef GIT_WIN32
git_index *index;
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
- git_buf conflicting_buf = GIT_BUF_INIT;
+ git_str conflicting_buf = GIT_STR_INIT;
cl_git_pass(p_unlink("./testrepo/.gitattributes"));
cl_repo_set_bool(g_repo, "core.autocrlf", true);
@@ -874,7 +874,7 @@ void test_checkout_index__conflicts_honor_coreautocrlf(void)
"=======\r\n"
"this file is changed in branch and master\r\n"
">>>>>>> theirs\r\n") == 0);
- git_buf_dispose(&conflicting_buf);
+ git_str_dispose(&conflicting_buf);
git_index_free(index);
#endif
diff --git a/tests/checkout/nasty.c b/tests/checkout/nasty.c
index 611e850d3..a1b3164be 100644
--- a/tests/checkout/nasty.c
+++ b/tests/checkout/nasty.c
@@ -3,7 +3,6 @@
#include "git2/checkout.h"
#include "repository.h"
-#include "buffer.h"
#include "futils.h"
static const char *repo_name = "nasty";
@@ -28,9 +27,9 @@ static void test_checkout_passes(const char *refname, const char *filename)
git_oid commit_id;
git_commit *commit;
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&path, repo_name, filename));
+ cl_git_pass(git_str_joinpath(&path, repo_name, filename));
cl_git_pass(git_reference_name_to_id(&commit_id, repo, refname));
cl_git_pass(git_commit_lookup(&commit, repo, &commit_id));
@@ -42,7 +41,7 @@ static void test_checkout_passes(const char *refname, const char *filename)
cl_assert(!git_path_exists(path.ptr));
git_commit_free(commit);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
static void test_checkout_fails(const char *refname, const char *filename)
@@ -50,9 +49,9 @@ static void test_checkout_fails(const char *refname, const char *filename)
git_oid commit_id;
git_commit *commit;
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&path, repo_name, filename));
+ cl_git_pass(git_str_joinpath(&path, repo_name, filename));
cl_git_pass(git_reference_name_to_id(&commit_id, repo, refname));
cl_git_pass(git_commit_lookup(&commit, repo, &commit_id));
@@ -63,7 +62,7 @@ static void test_checkout_fails(const char *refname, const char *filename)
cl_assert(!git_path_exists(path.ptr));
git_commit_free(commit);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
/* A tree that contains ".git" as a tree, with a blob inside
diff --git a/tests/checkout/tree.c b/tests/checkout/tree.c
index 3241a3eb7..cdfb456b7 100644
--- a/tests/checkout/tree.c
+++ b/tests/checkout/tree.c
@@ -3,7 +3,6 @@
#include "git2/checkout.h"
#include "repository.h"
-#include "buffer.h"
#include "futils.h"
static git_repository *g_repo;
@@ -519,7 +518,7 @@ void assert_conflict(
git_index *index;
git_object *hack_tree;
git_reference *branch, *head;
- git_buf file_path = GIT_BUF_INIT;
+ git_str file_path = GIT_STR_INIT;
cl_git_pass(git_repository_index(&index, g_repo));
@@ -549,9 +548,9 @@ void assert_conflict(
g_object = NULL;
/* Create a conflicting file */
- cl_git_pass(git_buf_joinpath(&file_path, "./testrepo", entry_path));
- cl_git_mkfile(git_buf_cstr(&file_path), new_content);
- git_buf_dispose(&file_path);
+ cl_git_pass(git_str_joinpath(&file_path, "./testrepo", entry_path));
+ cl_git_mkfile(git_str_cstr(&file_path), new_content);
+ git_str_dispose(&file_path);
/* Trying to checkout the original commit */
cl_git_pass(git_revparse_single(&g_object, g_repo, commit_sha));
@@ -1037,17 +1036,17 @@ void test_checkout_tree__filemode_preserved_in_index(void)
mode_t read_filemode(const char *path)
{
- git_buf fullpath = GIT_BUF_INIT;
+ git_str fullpath = GIT_STR_INIT;
struct stat st;
mode_t result;
- git_buf_joinpath(&fullpath, "testrepo", path);
+ git_str_joinpath(&fullpath, "testrepo", path);
cl_must_pass(p_stat(fullpath.ptr, &st));
result = GIT_PERMS_IS_EXEC(st.st_mode) ?
GIT_FILEMODE_BLOB_EXECUTABLE : GIT_FILEMODE_BLOB;
- git_buf_dispose(&fullpath);
+ git_str_dispose(&fullpath);
return result;
}
@@ -1317,7 +1316,7 @@ void test_checkout_tree__caches_attributes_during_checkout(void)
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
git_oid oid;
git_object *obj = NULL;
- git_buf ident1 = GIT_BUF_INIT, ident2 = GIT_BUF_INIT;
+ git_str ident1 = GIT_STR_INIT, ident2 = GIT_STR_INIT;
char *ident_paths[] = { "ident1.txt", "ident2.txt" };
opts.progress_cb = update_attr_callback;
@@ -1346,8 +1345,8 @@ void test_checkout_tree__caches_attributes_during_checkout(void)
cl_assert_equal_strn(ident1.ptr, "# $Id: ", 7);
cl_assert_equal_strn(ident2.ptr, "# $Id: ", 7);
- git_buf_dispose(&ident1);
- git_buf_dispose(&ident2);
+ git_str_dispose(&ident1);
+ git_str_dispose(&ident2);
git_object_free(obj);
}
@@ -1679,6 +1678,6 @@ void test_checkout_tree__dry_run(void)
/* check that notify callback was invoked */
cl_assert_equal_i(ct.n_updates, 2);
-
+
git_object_free(obj);
}
diff --git a/tests/checkout/typechange.c b/tests/checkout/typechange.c
index db3f02a5c..205ce657f 100644
--- a/tests/checkout/typechange.c
+++ b/tests/checkout/typechange.c
@@ -90,7 +90,7 @@ static void assert_workdir_matches_tree(
git_object *obj;
git_tree *tree;
size_t i, max_i;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
if (!root)
root = git_repository_workdir(repo);
@@ -106,7 +106,7 @@ static void assert_workdir_matches_tree(
const git_tree_entry *te = git_tree_entry_byindex(tree, i);
cl_assert(te);
- cl_git_pass(git_buf_joinpath(&path, root, git_tree_entry_name(te)));
+ cl_git_pass(git_str_joinpath(&path, root, git_tree_entry_name(te)));
switch (git_tree_entry_type(te)) {
case GIT_OBJECT_COMMIT:
@@ -139,7 +139,7 @@ static void assert_workdir_matches_tree(
}
git_tree_free(tree);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_checkout_typechange__checkout_typechanges_safe(void)
@@ -226,31 +226,31 @@ static void force_create_file(const char *file)
static int make_submodule_dirty(git_submodule *sm, const char *name, void *payload)
{
- git_buf submodulepath = GIT_BUF_INIT;
- git_buf dirtypath = GIT_BUF_INIT;
+ git_str submodulepath = GIT_STR_INIT;
+ git_str dirtypath = GIT_STR_INIT;
git_repository *submodule_repo;
GIT_UNUSED(name);
GIT_UNUSED(payload);
/* remove submodule directory in preparation for init and repo_init */
- cl_git_pass(git_buf_joinpath(
+ cl_git_pass(git_str_joinpath(
&submodulepath,
git_repository_workdir(g_repo),
git_submodule_path(sm)
));
- git_futils_rmdir_r(git_buf_cstr(&submodulepath), NULL, GIT_RMDIR_REMOVE_FILES);
+ git_futils_rmdir_r(git_str_cstr(&submodulepath), NULL, GIT_RMDIR_REMOVE_FILES);
/* initialize submodule's repository */
cl_git_pass(git_submodule_repo_init(&submodule_repo, sm, 0));
/* create a file in the submodule workdir to make it dirty */
cl_git_pass(
- git_buf_joinpath(&dirtypath, git_repository_workdir(submodule_repo), "dirty"));
- force_create_file(git_buf_cstr(&dirtypath));
+ git_str_joinpath(&dirtypath, git_repository_workdir(submodule_repo), "dirty"));
+ force_create_file(git_str_cstr(&dirtypath));
- git_buf_dispose(&dirtypath);
- git_buf_dispose(&submodulepath);
+ git_str_dispose(&dirtypath);
+ git_str_dispose(&submodulepath);
git_repository_free(submodule_repo);
return 0;
diff --git a/tests/cherrypick/bare.c b/tests/cherrypick/bare.c
index 50e8d8600..f90ce0226 100644
--- a/tests/cherrypick/bare.c
+++ b/tests/cherrypick/bare.c
@@ -1,7 +1,6 @@
#include "clar.h"
#include "clar_libgit2.h"
-#include "buffer.h"
#include "futils.h"
#include "git2/cherrypick.h"
diff --git a/tests/cherrypick/workdir.c b/tests/cherrypick/workdir.c
index 10e8c2d8b..f7765f2c2 100644
--- a/tests/cherrypick/workdir.c
+++ b/tests/cherrypick/workdir.c
@@ -1,7 +1,6 @@
#include "clar.h"
#include "clar_libgit2.h"
-#include "buffer.h"
#include "futils.h"
#include "git2/cherrypick.h"
@@ -140,7 +139,7 @@ void test_cherrypick_workdir__conflicts(void)
{
git_commit *head = NULL, *commit = NULL;
git_oid head_oid, cherry_oid;
- git_buf conflicting_buf = GIT_BUF_INIT, mergemsg_buf = GIT_BUF_INIT;
+ git_str conflicting_buf = GIT_STR_INIT, mergemsg_buf = GIT_STR_INIT;
struct merge_index_entry merge_index_entries[] = {
{ 0100644, "242e7977ba73637822ffb265b46004b9b0e5153b", 0, "file1.txt" },
@@ -168,7 +167,7 @@ void test_cherrypick_workdir__conflicts(void)
cl_git_pass(git_futils_readbuffer(&mergemsg_buf,
TEST_REPO_PATH "/.git/MERGE_MSG"));
- cl_assert(strcmp(git_buf_cstr(&mergemsg_buf),
+ cl_assert(strcmp(git_str_cstr(&mergemsg_buf),
"Change all files\n" \
"\n" \
"Conflicts:\n" \
@@ -178,7 +177,7 @@ void test_cherrypick_workdir__conflicts(void)
cl_git_pass(git_futils_readbuffer(&conflicting_buf,
TEST_REPO_PATH "/file2.txt"));
- cl_assert(strcmp(git_buf_cstr(&conflicting_buf),
+ cl_assert(strcmp(git_str_cstr(&conflicting_buf),
"!File 2\n" \
"File 2\n" \
"File 2\n" \
@@ -204,7 +203,7 @@ void test_cherrypick_workdir__conflicts(void)
cl_git_pass(git_futils_readbuffer(&conflicting_buf,
TEST_REPO_PATH "/file3.txt"));
- cl_assert(strcmp(git_buf_cstr(&conflicting_buf),
+ cl_assert(strcmp(git_str_cstr(&conflicting_buf),
"!File 3\n" \
"File 3\n" \
"File 3\n" \
@@ -228,8 +227,8 @@ void test_cherrypick_workdir__conflicts(void)
git_commit_free(commit);
git_commit_free(head);
- git_buf_dispose(&mergemsg_buf);
- git_buf_dispose(&conflicting_buf);
+ git_str_dispose(&mergemsg_buf);
+ git_str_dispose(&conflicting_buf);
}
/* git reset --hard bafbf6912c09505ac60575cd43d3f2aba3bd84d8
@@ -324,7 +323,7 @@ void test_cherrypick_workdir__both_renamed(void)
{
git_commit *head, *commit;
git_oid head_oid, cherry_oid;
- git_buf mergemsg_buf = GIT_BUF_INIT;
+ git_str mergemsg_buf = GIT_STR_INIT;
git_cherrypick_options opts = GIT_CHERRYPICK_OPTIONS_INIT;
struct merge_index_entry merge_index_entries[] = {
@@ -350,7 +349,7 @@ void test_cherrypick_workdir__both_renamed(void)
cl_git_pass(git_futils_readbuffer(&mergemsg_buf,
TEST_REPO_PATH "/.git/MERGE_MSG"));
- cl_assert(strcmp(git_buf_cstr(&mergemsg_buf),
+ cl_assert(strcmp(git_str_cstr(&mergemsg_buf),
"Renamed file3.txt -> file3.txt.renamed\n" \
"\n" \
"Conflicts:\n" \
@@ -358,7 +357,7 @@ void test_cherrypick_workdir__both_renamed(void)
"\tfile3.txt.renamed\n" \
"\tfile3.txt.renamed_on_branch\n") == 0);
- git_buf_dispose(&mergemsg_buf);
+ git_str_dispose(&mergemsg_buf);
git_commit_free(commit);
git_commit_free(head);
}
diff --git a/tests/clar_libgit2.c b/tests/clar_libgit2.c
index c4550c32a..adea597e3 100644
--- a/tests/clar_libgit2.c
+++ b/tests/clar_libgit2.c
@@ -68,7 +68,7 @@ void cl_git_rmfile(const char *filename)
char *cl_getenv(const char *name)
{
- git_buf out = GIT_BUF_INIT;
+ git_str out = GIT_STR_INIT;
int error = git__getenv(&out, name);
cl_assert(error >= 0 || error == GIT_ENOTFOUND);
@@ -83,7 +83,7 @@ char *cl_getenv(const char *name)
return dup;
}
- return git_buf_detach(&out);
+ return git_str_detach(&out);
}
bool cl_is_env_set(const char *name)
@@ -278,11 +278,11 @@ const char* cl_git_path_url(const char *path)
static char url[4096 + 1];
const char *in_buf;
- git_buf path_buf = GIT_BUF_INIT;
- git_buf url_buf = GIT_BUF_INIT;
+ git_str path_buf = GIT_STR_INIT;
+ git_str url_buf = GIT_STR_INIT;
cl_git_pass(git_path_prettify_dir(&path_buf, path, NULL));
- cl_git_pass(git_buf_puts(&url_buf, "file://"));
+ cl_git_pass(git_str_puts(&url_buf, "file://"));
#ifdef GIT_WIN32
/*
@@ -294,29 +294,29 @@ const char* cl_git_path_url(const char *path)
* *nix: file:///usr/home/...
* Windows: file:///C:/Users/...
*/
- cl_git_pass(git_buf_putc(&url_buf, '/'));
+ cl_git_pass(git_str_putc(&url_buf, '/'));
#endif
- in_buf = git_buf_cstr(&path_buf);
+ in_buf = git_str_cstr(&path_buf);
/*
* A very hacky Url encoding that only takes care of escaping the spaces
*/
while (*in_buf) {
if (*in_buf == ' ')
- cl_git_pass(git_buf_puts(&url_buf, "%20"));
+ cl_git_pass(git_str_puts(&url_buf, "%20"));
else
- cl_git_pass(git_buf_putc(&url_buf, *in_buf));
+ cl_git_pass(git_str_putc(&url_buf, *in_buf));
in_buf++;
}
cl_assert(url_buf.size < sizeof(url) - 1);
- strncpy(url, git_buf_cstr(&url_buf), sizeof(url) - 1);
+ strncpy(url, git_str_cstr(&url_buf), sizeof(url) - 1);
url[sizeof(url) - 1] = '\0';
- git_buf_dispose(&url_buf);
- git_buf_dispose(&path_buf);
+ git_str_dispose(&url_buf);
+ git_str_dispose(&path_buf);
return url;
}
@@ -324,15 +324,15 @@ const char *cl_git_sandbox_path(int is_dir, ...)
{
const char *path = NULL;
static char _temp[GIT_PATH_MAX];
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
va_list arg;
- cl_git_pass(git_buf_sets(&buf, clar_sandbox_path()));
+ cl_git_pass(git_str_sets(&buf, clar_sandbox_path()));
va_start(arg, is_dir);
while ((path = va_arg(arg, const char *)) != NULL) {
- cl_git_pass(git_buf_joinpath(&buf, buf.ptr, path));
+ cl_git_pass(git_str_joinpath(&buf, buf.ptr, path));
}
va_end(arg);
@@ -341,10 +341,10 @@ const char *cl_git_sandbox_path(int is_dir, ...)
git_path_to_dir(&buf);
/* make sure we won't truncate */
- cl_assert(git_buf_len(&buf) < sizeof(_temp));
- git_buf_copy_cstr(_temp, sizeof(_temp), &buf);
+ cl_assert(git_str_len(&buf) < sizeof(_temp));
+ git_str_copy_cstr(_temp, sizeof(_temp), &buf);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
return _temp;
}
@@ -354,7 +354,7 @@ typedef struct {
size_t filename_len;
} remove_data;
-static int remove_placeholders_recurs(void *_data, git_buf *path)
+static int remove_placeholders_recurs(void *_data, git_str *path)
{
remove_data *data = (remove_data *)_data;
size_t pathlen;
@@ -380,12 +380,12 @@ int cl_git_remove_placeholders(const char *directory_path, const char *filename)
{
int error;
remove_data data;
- git_buf buffer = GIT_BUF_INIT;
+ git_str buffer = GIT_STR_INIT;
if (git_path_isdir(directory_path) == false)
return -1;
- if (git_buf_sets(&buffer, directory_path) < 0)
+ if (git_str_sets(&buffer, directory_path) < 0)
return -1;
data.filename = filename;
@@ -393,7 +393,7 @@ int cl_git_remove_placeholders(const char *directory_path, const char *filename)
error = remove_placeholders_recurs(&data, &buffer);
- git_buf_dispose(&buffer);
+ git_str_dispose(&buffer);
return error;
}
@@ -548,30 +548,26 @@ void clar__assert_equal_file(
(size_t)expected_bytes, (size_t)total_bytes);
}
-static char *_cl_restore_home = NULL;
+static git_buf _cl_restore_home = GIT_BUF_INIT;
void cl_fake_home_cleanup(void *payload)
{
- char *restore = _cl_restore_home;
- _cl_restore_home = NULL;
-
GIT_UNUSED(payload);
- if (restore) {
+ if (_cl_restore_home.ptr) {
cl_git_pass(git_libgit2_opts(
- GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, restore));
- git__free(restore);
+ GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, _cl_restore_home.ptr));
+ git_buf_dispose(&_cl_restore_home);
}
}
void cl_fake_home(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cl_git_pass(git_libgit2_opts(
- GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &path));
+ GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &_cl_restore_home));
- _cl_restore_home = git_buf_detach(&path);
cl_set_cleanup(cl_fake_home_cleanup, NULL);
if (!git_path_exists("home"))
@@ -579,14 +575,14 @@ void cl_fake_home(void)
cl_git_pass(git_path_prettify(&path, "home", NULL));
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, path.ptr));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void cl_sandbox_set_search_path_defaults(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
- git_buf_joinpath(&path, clar_sandbox_path(), "__config");
+ git_str_joinpath(&path, clar_sandbox_path(), "__config");
if (!git_path_exists(path.ptr))
cl_must_pass(p_mkdir(path.ptr, 0777));
@@ -600,18 +596,18 @@ void cl_sandbox_set_search_path_defaults(void)
git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_PROGRAMDATA, path.ptr);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
#ifdef GIT_WIN32
bool cl_sandbox_supports_8dot3(void)
{
- git_buf longpath = GIT_BUF_INIT;
+ git_str longpath = GIT_STR_INIT;
char *shortname;
bool supported;
cl_git_pass(
- git_buf_joinpath(&longpath, clar_sandbox_path(), "longer_than_8dot3"));
+ git_str_joinpath(&longpath, clar_sandbox_path(), "longer_than_8dot3"));
cl_git_write2file(longpath.ptr, "", 0, O_RDWR|O_CREAT, 0666);
shortname = git_win32_path_8dot3_name(longpath.ptr);
@@ -619,7 +615,7 @@ bool cl_sandbox_supports_8dot3(void)
supported = (shortname != NULL);
git__free(shortname);
- git_buf_dispose(&longpath);
+ git_str_dispose(&longpath);
return supported;
}
diff --git a/tests/clar_libgit2_timer.c b/tests/clar_libgit2_timer.c
index 737506da2..2330f9351 100644
--- a/tests/clar_libgit2_timer.c
+++ b/tests/clar_libgit2_timer.c
@@ -1,6 +1,5 @@
#include "clar_libgit2.h"
#include "clar_libgit2_timer.h"
-#include "buffer.h"
void cl_perf_timer__init(cl_perf_timer *t)
{
diff --git a/tests/clone/local.c b/tests/clone/local.c
index b90ff3107..e0bd74df7 100644
--- a/tests/clone/local.c
+++ b/tests/clone/local.c
@@ -2,42 +2,41 @@
#include "git2/clone.h"
#include "clone.h"
-#include "buffer.h"
#include "path.h"
#include "posix.h"
#include "futils.h"
-static int file_url(git_buf *buf, const char *host, const char *path)
+static int file_url(git_str *buf, const char *host, const char *path)
{
if (path[0] == '/')
path++;
- git_buf_clear(buf);
- return git_buf_printf(buf, "file://%s/%s", host, path);
+ git_str_clear(buf);
+ return git_str_printf(buf, "file://%s/%s", host, path);
}
#ifdef GIT_WIN32
-static int git_style_unc_path(git_buf *buf, const char *host, const char *path)
+static int git_style_unc_path(git_str *buf, const char *host, const char *path)
{
- git_buf_clear(buf);
+ git_str_clear(buf);
if (host)
- git_buf_printf(buf, "//%s/", host);
+ git_str_printf(buf, "//%s/", host);
if (path[0] == '/')
path++;
if (git__isalpha(path[0]) && path[1] == ':' && path[2] == '/') {
- git_buf_printf(buf, "%c$/", path[0]);
+ git_str_printf(buf, "%c$/", path[0]);
path += 3;
}
- git_buf_puts(buf, path);
+ git_str_puts(buf, path);
- return git_buf_oom(buf) ? -1 : 0;
+ return git_str_oom(buf) ? -1 : 0;
}
-static int unc_path(git_buf *buf, const char *host, const char *path)
+static int unc_path(git_str *buf, const char *host, const char *path)
{
char *c;
@@ -54,7 +53,7 @@ static int unc_path(git_buf *buf, const char *host, const char *path)
void test_clone_local__should_clone_local(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
/* we use a fixture path because it needs to exist for us to want to clone */
const char *path = cl_fixture("testrepo.git");
@@ -79,8 +78,8 @@ void test_clone_local__should_clone_local(void)
/* Ensure that file:/// urls are percent decoded: .git == %2e%67%69%74 */
cl_git_pass(file_url(&buf, "", path));
- git_buf_shorten(&buf, 4);
- cl_git_pass(git_buf_puts(&buf, "%2e%67%69%74"));
+ git_str_shorten(&buf, 4);
+ cl_git_pass(git_str_puts(&buf, "%2e%67%69%74"));
cl_assert_equal_i(0, git_clone__should_clone_local(buf.ptr, GIT_CLONE_LOCAL_AUTO));
cl_assert_equal_i(1, git_clone__should_clone_local(buf.ptr, GIT_CLONE_LOCAL));
cl_assert_equal_i(1, git_clone__should_clone_local(buf.ptr, GIT_CLONE_LOCAL_NO_LINKS));
@@ -91,14 +90,14 @@ void test_clone_local__should_clone_local(void)
cl_assert_equal_i(1, git_clone__should_clone_local(path, GIT_CLONE_LOCAL_NO_LINKS));
cl_assert_equal_i(0, git_clone__should_clone_local(path, GIT_CLONE_NO_LOCAL));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
void test_clone_local__hardlinks(void)
{
git_repository *repo;
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
struct stat st;
/*
@@ -117,21 +116,21 @@ void test_clone_local__hardlinks(void)
cl_git_pass(git_clone(&repo, cl_git_path_url("clone.git"), "./clone2.git", &opts));
#ifndef GIT_WIN32
- git_buf_clear(&buf);
- cl_git_pass(git_buf_join_n(&buf, '/', 4, git_repository_path(repo), "objects", "08", "b041783f40edfe12bb406c9c9a8a040177c125"));
+ git_str_clear(&buf);
+ cl_git_pass(git_str_join_n(&buf, '/', 4, git_repository_path(repo), "objects", "08", "b041783f40edfe12bb406c9c9a8a040177c125"));
cl_git_pass(p_stat(buf.ptr, &st));
cl_assert_equal_i(2, st.st_nlink);
#endif
git_repository_free(repo);
- git_buf_clear(&buf);
+ git_str_clear(&buf);
opts.local = GIT_CLONE_LOCAL_NO_LINKS;
cl_git_pass(git_clone(&repo, cl_git_path_url("clone.git"), "./clone3.git", &opts));
- git_buf_clear(&buf);
- cl_git_pass(git_buf_join_n(&buf, '/', 4, git_repository_path(repo), "objects", "08", "b041783f40edfe12bb406c9c9a8a040177c125"));
+ git_str_clear(&buf);
+ cl_git_pass(git_str_join_n(&buf, '/', 4, git_repository_path(repo), "objects", "08", "b041783f40edfe12bb406c9c9a8a040177c125"));
cl_git_pass(p_stat(buf.ptr, &st));
cl_assert_equal_i(1, st.st_nlink);
@@ -142,14 +141,14 @@ void test_clone_local__hardlinks(void)
cl_git_pass(git_clone(&repo, "./clone.git", "./clone4.git", NULL));
#ifndef GIT_WIN32
- git_buf_clear(&buf);
- cl_git_pass(git_buf_join_n(&buf, '/', 4, git_repository_path(repo), "objects", "08", "b041783f40edfe12bb406c9c9a8a040177c125"));
+ git_str_clear(&buf);
+ cl_git_pass(git_str_join_n(&buf, '/', 4, git_repository_path(repo), "objects", "08", "b041783f40edfe12bb406c9c9a8a040177c125"));
cl_git_pass(p_stat(buf.ptr, &st));
cl_assert_equal_i(3, st.st_nlink);
#endif
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
git_repository_free(repo);
cl_git_pass(git_futils_rmdir_r("./clone.git", NULL, GIT_RMDIR_REMOVE_FILES));
@@ -164,7 +163,7 @@ void test_clone_local__standard_unc_paths_are_written_git_style(void)
git_repository *repo;
git_remote *remote;
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
- git_buf unc = GIT_BUF_INIT, git_unc = GIT_BUF_INIT;
+ git_str unc = GIT_STR_INIT, git_unc = GIT_STR_INIT;
/* we use a fixture path because it needs to exist for us to want to clone */
const char *path = cl_fixture("testrepo.git");
@@ -179,8 +178,8 @@ void test_clone_local__standard_unc_paths_are_written_git_style(void)
git_remote_free(remote);
git_repository_free(repo);
- git_buf_dispose(&unc);
- git_buf_dispose(&git_unc);
+ git_str_dispose(&unc);
+ git_str_dispose(&git_unc);
cl_git_pass(git_futils_rmdir_r("./clone.git", NULL, GIT_RMDIR_REMOVE_FILES));
#endif
@@ -192,7 +191,7 @@ void test_clone_local__git_style_unc_paths(void)
git_repository *repo;
git_remote *remote;
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
- git_buf git_unc = GIT_BUF_INIT;
+ git_str git_unc = GIT_STR_INIT;
/* we use a fixture path because it needs to exist for us to want to clone */
const char *path = cl_fixture("testrepo.git");
@@ -206,7 +205,7 @@ void test_clone_local__git_style_unc_paths(void)
git_remote_free(remote);
git_repository_free(repo);
- git_buf_dispose(&git_unc);
+ git_str_dispose(&git_unc);
cl_git_pass(git_futils_rmdir_r("./clone.git", NULL, GIT_RMDIR_REMOVE_FILES));
#endif
diff --git a/tests/clone/nonetwork.c b/tests/clone/nonetwork.c
index ec12fee18..7625a2183 100644
--- a/tests/clone/nonetwork.c
+++ b/tests/clone/nonetwork.c
@@ -145,15 +145,15 @@ void test_clone_nonetwork__cope_with_already_existing_directory(void)
void test_clone_nonetwork__can_prevent_the_checkout_of_a_standard_repo(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
g_options.checkout_opts.checkout_strategy = 0;
cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "master.txt"));
- cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&path)));
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_repo), "master.txt"));
+ cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&path)));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_clone_nonetwork__can_checkout_given_branch(void)
@@ -304,9 +304,9 @@ static void assert_correct_reflog(const char *name)
{
git_reflog *log;
const git_reflog_entry *entry;
- git_buf expected_message = GIT_BUF_INIT;
+ git_str expected_message = GIT_STR_INIT;
- git_buf_printf(&expected_message,
+ git_str_printf(&expected_message,
"clone: from %s", cl_git_fixture_url("testrepo.git"));
cl_git_pass(git_reflog_read(&log, g_repo, name));
@@ -316,7 +316,7 @@ static void assert_correct_reflog(const char *name)
git_reflog_free(log);
- git_buf_dispose(&expected_message);
+ git_str_dispose(&expected_message);
}
void test_clone_nonetwork__clone_updates_reflog_properly(void)
diff --git a/tests/commit/parse.c b/tests/commit/parse.c
index f0a31de9a..04366d7d2 100644
--- a/tests/commit/parse.c
+++ b/tests/commit/parse.c
@@ -445,15 +445,15 @@ cpxtDQQMGYFpXK/71stq\n\
cl_git_pass(git_commit_header_field(&buf, commit, "tree"));
cl_assert_equal_s("6b79e22d69bf46e289df0345a14ca059dfc9bdf6", buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
cl_git_pass(git_commit_header_field(&buf, commit, "parent"));
cl_assert_equal_s("34734e478d6cf50c27c9d69026d93974d052c454", buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
cl_git_pass(git_commit_header_field(&buf, commit, "gpgsig"));
cl_assert_equal_s(gpgsig, buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
cl_git_fail_with(GIT_ENOTFOUND, git_commit_header_field(&buf, commit, "awesomeness"));
cl_git_fail_with(GIT_ENOTFOUND, git_commit_header_field(&buf, commit, "par"));
@@ -513,7 +513,6 @@ committer Some User <someuser@gmail.com> 1454537944 -0700\n\
\n\
corrupt signature\n";
-
cl_git_pass(git_repository_odb__weakptr(&odb, g_repo));
cl_git_pass(git_odb_write(&commit_id, odb, passing_commit_cases[4], strlen(passing_commit_cases[4]), GIT_OBJECT_COMMIT));
@@ -521,13 +520,16 @@ corrupt signature\n";
cl_assert_equal_s(gpgsig, signature.ptr);
cl_assert_equal_s(data, signed_data.ptr);
- git_buf_clear(&signature);
- git_buf_clear(&signed_data);
+ git_buf_dispose(&signature);
+ git_buf_dispose(&signed_data);
cl_git_pass(git_commit_extract_signature(&signature, &signed_data, g_repo, &commit_id, "gpgsig"));
cl_assert_equal_s(gpgsig, signature.ptr);
cl_assert_equal_s(data, signed_data.ptr);
+ git_buf_dispose(&signature);
+ git_buf_dispose(&signed_data);
+
/* Try to parse a tree */
cl_git_pass(git_oid_fromstr(&commit_id, "45dd856fdd4d89b884c340ba0e047752d9b085d6"));
cl_git_fail_with(GIT_ENOTFOUND, git_commit_extract_signature(&signature, &signed_data, g_repo, &commit_id, NULL));
@@ -539,15 +541,11 @@ corrupt signature\n";
cl_assert_equal_i(GIT_ERROR_OBJECT, git_error_last()->klass);
/* Parse the commit with a single-line signature */
- git_buf_clear(&signature);
- git_buf_clear(&signed_data);
cl_git_pass(git_odb_write(&commit_id, odb, oneline_signature, strlen(oneline_signature), GIT_OBJECT_COMMIT));
cl_git_pass(git_commit_extract_signature(&signature, &signed_data, g_repo, &commit_id, NULL));
cl_assert_equal_s("bad", signature.ptr);
cl_assert_equal_s(oneline_data, signed_data.ptr);
-
git_buf_dispose(&signature);
git_buf_dispose(&signed_data);
-
}
diff --git a/tests/config/conditionals.c b/tests/config/conditionals.c
index 5858782c1..6249dbd79 100644
--- a/tests/config/conditionals.c
+++ b/tests/config/conditionals.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "futils.h"
#include "repository.h"
@@ -23,43 +22,46 @@ void test_config_conditionals__cleanup(void)
static void assert_condition_includes(const char *keyword, const char *path, bool expected)
{
- git_buf buf = GIT_BUF_INIT;
+ git_buf value = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
git_config *cfg;
- cl_git_pass(git_buf_printf(&buf, "[includeIf \"%s:%s\"]\n", keyword, path));
- cl_git_pass(git_buf_puts(&buf, "path = other\n"));
+ cl_git_pass(git_str_printf(&buf, "[includeIf \"%s:%s\"]\n", keyword, path));
+ cl_git_pass(git_str_puts(&buf, "path = other\n"));
cl_git_mkfile("empty_standard_repo/.git/config", buf.ptr);
cl_git_mkfile("empty_standard_repo/.git/other", "[foo]\nbar=baz\n");
_repo = cl_git_sandbox_reopen();
+ git_str_dispose(&buf);
+
cl_git_pass(git_repository_config(&cfg, _repo));
if (expected) {
- git_buf_clear(&buf);
- cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar"));
- cl_assert_equal_s("baz", git_buf_cstr(&buf));
+ cl_git_pass(git_config_get_string_buf(&value, cfg, "foo.bar"));
+ cl_assert_equal_s("baz", value.ptr);
} else {
cl_git_fail_with(GIT_ENOTFOUND,
- git_config_get_string_buf(&buf, cfg, "foo.bar"));
+ git_config_get_string_buf(&value, cfg, "foo.bar"));
}
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
+ git_buf_dispose(&value);
git_config_free(cfg);
}
-static char *sandbox_path(git_buf *buf, const char *suffix)
+static char *sandbox_path(git_str *buf, const char *suffix)
{
char *path = p_realpath(clar_sandbox_path(), NULL);
cl_assert(path);
- cl_git_pass(git_buf_attach(buf, path, 0));
- cl_git_pass(git_buf_joinpath(buf, buf->ptr, suffix));
+ cl_git_pass(git_str_attach(buf, path, 0));
+ cl_git_pass(git_str_joinpath(buf, buf->ptr, suffix));
return buf->ptr;
}
void test_config_conditionals__gitdir(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
assert_condition_includes("gitdir", ROOT_PREFIX "/", true);
assert_condition_includes("gitdir", "empty_stand", false);
@@ -90,17 +92,17 @@ void test_config_conditionals__gitdir(void)
assert_condition_includes("gitdir", sandbox_path(&path, "Empty_Standard_Repo"), false);
assert_condition_includes("gitdir", sandbox_path(&path, "Empty_Standard_Repo/"), false);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_config_conditionals__gitdir_i(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
assert_condition_includes("gitdir/i", sandbox_path(&path, "empty_standard_repo/"), true);
assert_condition_includes("gitdir/i", sandbox_path(&path, "EMPTY_STANDARD_REPO/"), true);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_config_conditionals__invalid_conditional_fails(void)
diff --git a/tests/config/config_helpers.c b/tests/config/config_helpers.c
index d92ff1a4e..ecdab5bf6 100644
--- a/tests/config/config_helpers.c
+++ b/tests/config/config_helpers.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "config_helpers.h"
#include "repository.h"
-#include "buffer.h"
void assert_config_entry_existence(
git_repository *repo,
@@ -13,7 +12,7 @@ void assert_config_entry_existence(
int result;
cl_git_pass(git_repository_config__weakptr(&config, repo));
-
+
result = git_config_get_entry(&entry, config, name);
git_config_entry_free(entry);
@@ -35,7 +34,7 @@ void assert_config_entry_value(
cl_git_pass(git_config_get_string_buf(&buf, config, name));
- cl_assert_equal_s(expected_value, git_buf_cstr(&buf));
+ cl_assert_equal_s(expected_value, buf.ptr);
git_buf_dispose(&buf);
}
diff --git a/tests/config/configlevel.c b/tests/config/configlevel.c
index 15c469fcb..8422d32c9 100644
--- a/tests/config/configlevel.c
+++ b/tests/config/configlevel.c
@@ -22,7 +22,7 @@ void test_config_configlevel__adding_the_same_level_twice_returns_EEXISTS(void)
void test_config_configlevel__can_replace_a_config_file_at_an_existing_level(void)
{
git_config *cfg;
- git_buf buf = {0};
+ git_buf buf = GIT_BUF_INIT;
cl_git_pass(git_config_new(&cfg));
cl_git_pass(git_config_add_file_ondisk(cfg, cl_fixture("config/config18"),
diff --git a/tests/config/global.c b/tests/config/global.c
index ed47d0251..d59c39fa2 100644
--- a/tests/config/global.c
+++ b/tests/config/global.c
@@ -1,10 +1,9 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "futils.h"
void test_config_global__initialize(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cl_git_pass(git_futils_mkdir_r("home", 0777));
cl_git_pass(git_path_prettify(&path, "home", NULL));
@@ -21,7 +20,7 @@ void test_config_global__initialize(void)
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, path.ptr));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_config_global__cleanup(void)
@@ -132,24 +131,25 @@ void test_config_global__open_programdata(void)
{
git_config *cfg;
git_repository *repo;
- git_buf config_path = GIT_BUF_INIT;
+ git_buf dir_path = GIT_BUF_INIT;
+ git_str config_path = GIT_STR_INIT;
git_buf var_contents = GIT_BUF_INIT;
if (cl_is_env_set("GITTEST_INVASIVE_FS_STRUCTURE"))
cl_skip();
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH,
- GIT_CONFIG_LEVEL_PROGRAMDATA, &config_path));
+ GIT_CONFIG_LEVEL_PROGRAMDATA, &dir_path));
- if (!git_path_isdir(config_path.ptr))
- cl_git_pass(p_mkdir(config_path.ptr, 0777));
+ if (!git_path_isdir(dir_path.ptr))
+ cl_git_pass(p_mkdir(dir_path.ptr, 0777));
- cl_git_pass(git_buf_puts(&config_path, "/config"));
+ cl_git_pass(git_str_joinpath(&config_path, dir_path.ptr, "config"));
cl_git_pass(git_config_open_ondisk(&cfg, config_path.ptr));
cl_git_pass(git_config_set_string(cfg, "programdata.var", "even higher level"));
- git_buf_dispose(&config_path);
+ git_str_dispose(&config_path);
git_config_free(cfg);
git_config_open_default(&cfg);
@@ -165,6 +165,7 @@ void test_config_global__open_programdata(void)
cl_assert_equal_s("even higher level", var_contents.ptr);
git_config_free(cfg);
+ git_buf_dispose(&dir_path);
git_buf_dispose(&var_contents);
git_repository_free(repo);
cl_fixture_cleanup("./foo.git");
diff --git a/tests/config/include.c b/tests/config/include.c
index b702d6211..9328f3cf6 100644
--- a/tests/config/include.c
+++ b/tests/config/include.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "futils.h"
static git_config *cfg;
@@ -7,14 +6,14 @@ static git_buf buf;
void test_config_include__initialize(void)
{
- cfg = NULL;
- git_buf_init(&buf, 0);
+ cfg = NULL;
+ memset(&buf, 0, sizeof(git_buf));
}
void test_config_include__cleanup(void)
{
- git_config_free(cfg);
- git_buf_dispose(&buf);
+ git_config_free(cfg);
+ git_buf_dispose(&buf);
}
void test_config_include__relative(void)
@@ -22,19 +21,21 @@ void test_config_include__relative(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config-include")));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar.baz"));
- cl_assert_equal_s("huzzah", git_buf_cstr(&buf));
+ cl_assert_equal_s("huzzah", buf.ptr);
}
void test_config_include__absolute(void)
{
- cl_git_pass(git_buf_printf(&buf, "[include]\npath = %s/config-included", cl_fixture("config")));
+ git_str cfgdata = GIT_STR_INIT;
+ cl_git_pass(git_str_printf(&cfgdata, "[include]\npath = %s/config-included", cl_fixture("config")));
+
+ cl_git_mkfile("config-include-absolute", cfgdata.ptr);
+ git_str_dispose(&cfgdata);
- cl_git_mkfile("config-include-absolute", git_buf_cstr(&buf));
- git_buf_dispose(&buf);
cl_git_pass(git_config_open_ondisk(&cfg, "config-include-absolute"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar.baz"));
- cl_assert_equal_s("huzzah", git_buf_cstr(&buf));
+ cl_assert_equal_s("huzzah", buf.ptr);
cl_git_pass(p_unlink("config-include-absolute"));
}
@@ -47,7 +48,7 @@ void test_config_include__homedir(void)
cl_git_pass(git_config_open_ondisk(&cfg, "config-include-homedir"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar.baz"));
- cl_assert_equal_s("huzzah", git_buf_cstr(&buf));
+ cl_assert_equal_s("huzzah", buf.ptr);
cl_sandbox_set_search_path_defaults();
@@ -66,10 +67,10 @@ void test_config_include__ordering(void)
cl_git_pass(git_config_open_ondisk(&cfg, "including"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar.frotz"));
- cl_assert_equal_s("hiya", git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s("hiya", buf.ptr);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar.baz"));
- cl_assert_equal_s("huzzah", git_buf_cstr(&buf));
+ cl_assert_equal_s("huzzah", buf.ptr);
cl_git_pass(p_unlink("included"));
cl_git_pass(p_unlink("including"));
@@ -92,7 +93,7 @@ void test_config_include__empty_path_sanely_handled(void)
cl_git_mkfile("a", "[include]\npath");
cl_git_pass(git_config_open_ondisk(&cfg, "a"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "include.path"));
- cl_assert_equal_s("", git_buf_cstr(&buf));
+ cl_assert_equal_s("", buf.ptr);
cl_git_pass(p_unlink("a"));
}
@@ -105,7 +106,7 @@ void test_config_include__missing(void)
cl_git_pass(git_config_open_ondisk(&cfg, "including"));
cl_assert(git_error_last() == NULL);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar"));
- cl_assert_equal_s("baz", git_buf_cstr(&buf));
+ cl_assert_equal_s("baz", buf.ptr);
cl_git_pass(p_unlink("including"));
}
@@ -119,7 +120,7 @@ void test_config_include__missing_homedir(void)
cl_git_pass(git_config_open_ondisk(&cfg, "including"));
cl_assert(git_error_last() == NULL);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar"));
- cl_assert_equal_s("baz", git_buf_cstr(&buf));
+ cl_assert_equal_s("baz", buf.ptr);
cl_sandbox_set_search_path_defaults();
cl_git_pass(p_unlink("including"));
@@ -137,11 +138,11 @@ void test_config_include__depth2(void)
cl_git_pass(git_config_open_ondisk(&cfg, "top-level"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar"));
- cl_assert_equal_s("baz", git_buf_cstr(&buf));
+ cl_assert_equal_s("baz", buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar2"));
- cl_assert_equal_s("baz2", git_buf_cstr(&buf));
+ cl_assert_equal_s("baz2", buf.ptr);
cl_git_pass(p_unlink("top-level"));
cl_git_pass(p_unlink("middle"));
@@ -186,13 +187,13 @@ void test_config_include__rewriting_include_twice_refreshes_values(void)
cl_git_pass(git_config_open_ondisk(&cfg, "top-level"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar"));
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
cl_git_mkfile("included", "[foo]\nother = value2");
cl_git_fail(git_config_get_string_buf(&buf, cfg, "foo.bar"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.other"));
cl_assert_equal_s(buf.ptr, "value2");
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
cl_git_mkfile("included", "[foo]\nanother = bar");
cl_git_fail(git_config_get_string_buf(&buf, cfg, "foo.other"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.another"));
diff --git a/tests/config/new.c b/tests/config/new.c
index 22c330f6f..baca05332 100644
--- a/tests/config/new.c
+++ b/tests/config/new.c
@@ -22,10 +22,10 @@ void test_config_new__write_new_config(void)
cl_git_pass(git_config_open_ondisk(&config, TEST_CONFIG));
cl_git_pass(git_config_get_string_buf(&buf, config, "color.ui"));
- cl_assert_equal_s("auto", git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s("auto", buf.ptr);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, config, "core.editor"));
- cl_assert_equal_s("ed", git_buf_cstr(&buf));
+ cl_assert_equal_s("ed", buf.ptr);
git_buf_dispose(&buf);
git_config_free(config);
diff --git a/tests/config/read.c b/tests/config/read.c
index 8d1bb8b0a..77f8a1262 100644
--- a/tests/config/read.c
+++ b/tests/config/read.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "path.h"
static git_buf buf = GIT_BUF_INIT;
@@ -36,11 +35,11 @@ void test_config_read__case_sensitive(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config1")));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "this.that.other"));
- cl_assert_equal_s("true", git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s("true", buf.ptr);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "this.That.other"));
- cl_assert_equal_s("yes", git_buf_cstr(&buf));
+ cl_assert_equal_s("yes", buf.ptr);
cl_git_pass(git_config_get_bool(&i, cfg, "this.that.other"));
cl_assert(i == 1);
@@ -64,7 +63,7 @@ void test_config_read__multiline_value(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config2")));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "this.That.and"));
- cl_assert_equal_s("one one one two two three three", git_buf_cstr(&buf));
+ cl_assert_equal_s("one one one two two three three", buf.ptr);
git_config_free(cfg);
}
@@ -84,7 +83,7 @@ void test_config_read__multiline_value_and_eof(void)
cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "header.key1"));
- cl_assert_equal_s("foo", git_buf_cstr(&buf));
+ cl_assert_equal_s("foo", buf.ptr);
git_config_free(cfg);
}
@@ -98,7 +97,7 @@ void test_config_read__multiline_eof(void)
cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "header.key1"));
- cl_assert_equal_s("", git_buf_cstr(&buf));
+ cl_assert_equal_s("", buf.ptr);
git_config_free(cfg);
}
@@ -113,7 +112,7 @@ void test_config_read__subsection_header(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config3")));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "section.subsection.var"));
- cl_assert_equal_s("hello", git_buf_cstr(&buf));
+ cl_assert_equal_s("hello", buf.ptr);
/* The subsection is transformed to lower-case */
cl_must_fail(git_config_get_string_buf(&buf, cfg, "section.subSectIon.var"));
@@ -131,14 +130,14 @@ void test_config_read__lone_variable(void)
cl_git_fail(git_config_get_int32(&i, cfg, "some.section.variable"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.section.variable"));
- cl_assert_equal_s("", git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s("", buf.ptr);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_bool(&i, cfg, "some.section.variable"));
cl_assert(i == 1);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.section.variableeq"));
- cl_assert_equal_s("", git_buf_cstr(&buf));
+ cl_assert_equal_s("", buf.ptr);
cl_git_pass(git_config_get_bool(&i, cfg, "some.section.variableeq"));
cl_assert(i == 0);
@@ -234,11 +233,11 @@ void test_config_read__prefixes(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config9")));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "remote.ab.url"));
- cl_assert_equal_s("http://example.com/git/ab", git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s("http://example.com/git/ab", buf.ptr);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "remote.abba.url"));
- cl_assert_equal_s("http://example.com/git/abba", git_buf_cstr(&buf));
+ cl_assert_equal_s("http://example.com/git/abba", buf.ptr);
git_config_free(cfg);
}
@@ -249,7 +248,7 @@ void test_config_read__escaping_quotes(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config13")));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "core.editor"));
- cl_assert_equal_s("\"C:/Program Files/Nonsense/bah.exe\" \"--some option\"", git_buf_cstr(&buf));
+ cl_assert_equal_s("\"C:/Program Files/Nonsense/bah.exe\" \"--some option\"", buf.ptr);
git_config_free(cfg);
}
@@ -446,11 +445,11 @@ void test_config_read__whitespace_not_required_around_assignment(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config14")));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "a.b"));
- cl_assert_equal_s("c", git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s("c", buf.ptr);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "d.e"));
- cl_assert_equal_s("f", git_buf_cstr(&buf));
+ cl_assert_equal_s("f", buf.ptr);
git_config_free(cfg);
}
@@ -596,7 +595,7 @@ void test_config_read__simple_read_from_specific_level(void)
cl_git_pass(git_config_get_bool(&i, cfg_specific, "core.boolglobal"));
cl_assert_equal_b(true, i);
cl_git_pass(git_config_get_string_buf(&buf, cfg_specific, "core.stringglobal"));
- cl_assert_equal_s("I'm a global config value!", git_buf_cstr(&buf));
+ cl_assert_equal_s("I'm a global config value!", buf.ptr);
git_config_free(cfg_specific);
git_config_free(cfg);
@@ -692,7 +691,7 @@ void test_config_read__override_variable(void)
cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.var"));
- cl_assert_equal_s("two", git_buf_cstr(&buf));
+ cl_assert_equal_s("two", buf.ptr);
git_config_free(cfg);
}
@@ -702,8 +701,8 @@ void test_config_read__path(void)
git_config *cfg;
git_buf path = GIT_BUF_INIT;
git_buf old_path = GIT_BUF_INIT;
- git_buf home_path = GIT_BUF_INIT;
- git_buf expected_path = GIT_BUF_INIT;
+ git_str home_path = GIT_STR_INIT;
+ git_str expected_path = GIT_STR_INIT;
cl_git_pass(p_mkdir("fakehome", 0777));
cl_git_pass(git_path_prettify(&home_path, "fakehome", NULL));
@@ -725,7 +724,7 @@ void test_config_read__path(void)
git_buf_dispose(&path);
cl_git_mkfile("./testconfig", "[some]\n path = ~");
- cl_git_pass(git_buf_sets(&expected_path, home_path.ptr));
+ cl_git_pass(git_str_sets(&expected_path, home_path.ptr));
cl_git_pass(git_config_get_path(&path, cfg, "some.path"));
cl_assert_equal_s(expected_path.ptr, path.ptr);
@@ -736,8 +735,8 @@ void test_config_read__path(void)
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, old_path.ptr));
git_buf_dispose(&old_path);
- git_buf_dispose(&home_path);
- git_buf_dispose(&expected_path);
+ git_str_dispose(&home_path);
+ git_str_dispose(&expected_path);
git_config_free(cfg);
}
@@ -884,18 +883,18 @@ void test_config_read__single_line(void)
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.var"));
cl_assert_equal_s(buf.ptr, "value");
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.OtheR.var"));
cl_assert_equal_s(buf.ptr, "value");
git_config_free(cfg);
cl_git_mkfile("./testconfig", "[some] var = value\n[some \"OtheR\"]var = value");
cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.var"));
cl_assert_equal_s(buf.ptr, "value");
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.OtheR.var"));
cl_assert_equal_s(buf.ptr, "value");
diff --git a/tests/config/stress.c b/tests/config/stress.c
index 577452e8d..7ec274b18 100644
--- a/tests/config/stress.c
+++ b/tests/config/stress.c
@@ -41,9 +41,9 @@ void test_config_stress__dont_break_on_invalid_input(void)
void assert_config_value(git_config *config, const char *key, const char *value)
{
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, config, key));
- cl_assert_equal_s(value, git_buf_cstr(&buf));
+ cl_assert_equal_s(value, buf.ptr);
}
void test_config_stress__comments(void)
diff --git a/tests/config/write.c b/tests/config/write.c
index 78ed7f15b..4ee83833f 100644
--- a/tests/config/write.c
+++ b/tests/config/write.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "futils.h"
#include "git2/sys/config.h"
#include "config.h"
@@ -290,7 +289,7 @@ void test_config_write__write_subsection(void)
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "my.own.var"));
- cl_assert_equal_s("works", git_buf_cstr(&buf));
+ cl_assert_equal_s("works", buf.ptr);
git_buf_dispose(&buf);
git_config_free(cfg);
@@ -313,27 +312,27 @@ void test_config_write__value_containing_quotes(void)
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
cl_git_pass(git_config_set_string(cfg, "core.somevar", "this \"has\" quotes"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "core.somevar"));
- cl_assert_equal_s("this \"has\" quotes", git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s("this \"has\" quotes", buf.ptr);
+ git_buf_dispose(&buf);
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "core.somevar"));
- cl_assert_equal_s("this \"has\" quotes", git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s("this \"has\" quotes", buf.ptr);
+ git_buf_dispose(&buf);
git_config_free(cfg);
/* The code path for values that already exist is different, check that one as well */
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
cl_git_pass(git_config_set_string(cfg, "core.somevar", "this also \"has\" quotes"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "core.somevar"));
- cl_assert_equal_s("this also \"has\" quotes", git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s("this also \"has\" quotes", buf.ptr);
+ git_buf_dispose(&buf);
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "core.somevar"));
- cl_assert_equal_s("this also \"has\" quotes", git_buf_cstr(&buf));
+ cl_assert_equal_s("this also \"has\" quotes", buf.ptr);
git_buf_dispose(&buf);
git_config_free(cfg);
}
@@ -346,13 +345,13 @@ void test_config_write__escape_value(void)
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
cl_git_pass(git_config_set_string(cfg, "core.somevar", "this \"has\" quotes and \t"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "core.somevar"));
- cl_assert_equal_s("this \"has\" quotes and \t", git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s("this \"has\" quotes and \t", buf.ptr);
+ git_buf_dispose(&buf);
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "core.somevar"));
- cl_assert_equal_s("this \"has\" quotes and \t", git_buf_cstr(&buf));
+ cl_assert_equal_s("this \"has\" quotes and \t", buf.ptr);
git_buf_dispose(&buf);
git_config_free(cfg);
}
@@ -390,7 +389,7 @@ void test_config_write__add_value_at_specific_level(void)
cl_git_pass(git_config_get_bool(&i, cfg, "core.boolglobal"));
cl_assert_equal_b(true, i);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "core.stringglobal"));
- cl_assert_equal_s("I'm a global config value!", git_buf_cstr(&buf));
+ cl_assert_equal_s("I'm a global config value!", buf.ptr);
git_buf_dispose(&buf);
git_config_free(cfg);
@@ -553,7 +552,7 @@ void test_config_write__preserves_whitespace_and_comments(void)
const char *file_name = "config-duplicate-header";
const char *n;
git_config *cfg;
- git_buf newfile = GIT_BUF_INIT;
+ git_str newfile = GIT_STR_INIT;
/* This config can occur after removing and re-adding the origin remote */
const char *file_content = SECTION_FOO_WITH_COMMENT SECTION_BAR;
@@ -580,7 +579,7 @@ void test_config_write__preserves_whitespace_and_comments(void)
cl_assert_equal_s("[newsection]\n\tnewname = new_value\n", n);
- git_buf_dispose(&newfile);
+ git_str_dispose(&newfile);
git_config_free(cfg);
}
@@ -588,7 +587,7 @@ void test_config_write__preserves_entry_with_name_only(void)
{
const char *file_name = "config-empty-value";
git_config *cfg;
- git_buf newfile = GIT_BUF_INIT;
+ git_str newfile = GIT_STR_INIT;
/* Write the test config and make sure the expected entry exists */
cl_git_mkfile(file_name, "[section \"foo\"]\n\tname\n");
@@ -599,7 +598,7 @@ void test_config_write__preserves_entry_with_name_only(void)
cl_git_pass(git_futils_readbuffer(&newfile, file_name));
cl_assert_equal_s("[section \"foo\"]\n\tname\n\tother = otherval\n[newsection]\n\tnewname = new_value\n", newfile.ptr);
- git_buf_dispose(&newfile);
+ git_str_dispose(&newfile);
git_config_free(cfg);
}
@@ -607,7 +606,7 @@ void test_config_write__to_empty_file(void)
{
git_config *cfg;
const char *filename = "config-file";
- git_buf result = GIT_BUF_INIT;
+ git_str result = GIT_STR_INIT;
cl_git_mkfile(filename, "");
cl_git_pass(git_config_open_ondisk(&cfg, filename));
@@ -617,14 +616,14 @@ void test_config_write__to_empty_file(void)
cl_git_pass(git_futils_readbuffer(&result, "config-file"));
cl_assert_equal_s("[section]\n\tname = value\n", result.ptr);
- git_buf_dispose(&result);
+ git_str_dispose(&result);
}
void test_config_write__to_file_with_only_comment(void)
{
git_config *cfg;
const char *filename = "config-file";
- git_buf result = GIT_BUF_INIT;
+ git_str result = GIT_STR_INIT;
cl_git_mkfile(filename, "\n\n");
cl_git_pass(git_config_open_ondisk(&cfg, filename));
@@ -634,7 +633,7 @@ void test_config_write__to_file_with_only_comment(void)
cl_git_pass(git_futils_readbuffer(&result, "config-file"));
cl_assert_equal_s("\n\n[section]\n\tname = value\n", result.ptr);
- git_buf_dispose(&result);
+ git_str_dispose(&result);
}
void test_config_write__locking(void)
@@ -699,7 +698,7 @@ void test_config_write__repeated(void)
{
const char *filename = "config-repeated";
git_config *cfg;
- git_buf result = GIT_BUF_INIT;
+ git_str result = GIT_STR_INIT;
const char *expected = "[sample \"prefix\"]\n\
\tsetting1 = someValue1\n\
\tsetting2 = someValue2\n\
@@ -717,7 +716,7 @@ void test_config_write__repeated(void)
cl_git_pass(git_futils_readbuffer(&result, filename));
cl_assert_equal_s(expected, result.ptr);
- git_buf_dispose(&result);
+ git_str_dispose(&result);
git_config_free(cfg);
}
@@ -726,7 +725,7 @@ void test_config_write__preserve_case(void)
{
const char *filename = "config-preserve-case";
git_config *cfg;
- git_buf result = GIT_BUF_INIT;
+ git_str result = GIT_STR_INIT;
const char *expected = "[sOMe]\n" \
"\tThInG = foo\n" \
"\tOtheR = thing\n";
@@ -740,7 +739,7 @@ void test_config_write__preserve_case(void)
cl_git_pass(git_futils_readbuffer(&result, filename));
cl_assert_equal_s(expected, result.ptr);
- git_buf_dispose(&result);
+ git_str_dispose(&result);
git_config_free(cfg);
}
diff --git a/tests/core/buf.c b/tests/core/buf.c
new file mode 100644
index 000000000..3959fa883
--- /dev/null
+++ b/tests/core/buf.c
@@ -0,0 +1,54 @@
+#include "clar_libgit2.h"
+#include "buf.h"
+
+void test_core_buf__sanitize(void)
+{
+ git_buf buf = { (char *)0x42, 0, 16 };
+
+ cl_git_pass(git_buf_sanitize(&buf));
+ cl_assert_equal_s(buf.ptr, "");
+ cl_assert_equal_i(buf.reserved, 0);
+ cl_assert_equal_i(buf.size, 0);
+
+ git_buf_dispose(&buf);
+}
+
+void test_core_buf__tostr(void)
+{
+ git_str str = GIT_STR_INIT;
+ git_buf buf = { (char *)0x42, 0, 16 };
+
+ cl_git_pass(git_buf_tostr(&str, &buf));
+
+ cl_assert_equal_s(buf.ptr, "");
+ cl_assert_equal_i(buf.reserved, 0);
+ cl_assert_equal_i(buf.size, 0);
+
+ cl_assert_equal_s(str.ptr, "");
+ cl_assert_equal_i(str.asize, 0);
+ cl_assert_equal_i(str.size, 0);
+
+ git_buf_dispose(&buf);
+ git_str_dispose(&str);
+}
+
+void test_core_buf__fromstr(void)
+{
+ git_str str = GIT_STR_INIT;
+ git_buf buf = { (char *)0x42, 0, 16 };
+
+ cl_git_pass(git_buf_tostr(&str, &buf));
+ cl_git_pass(git_str_puts(&str, "Hello, world."));
+ cl_git_pass(git_buf_fromstr(&buf, &str));
+
+ cl_assert(buf.reserved > 14);
+ cl_assert_equal_i(buf.size, 13);
+ cl_assert_equal_s(buf.ptr, "Hello, world.");
+
+ cl_assert_equal_s(str.ptr, "");
+ cl_assert_equal_i(str.asize, 0);
+ cl_assert_equal_i(str.size, 0);
+
+ git_buf_dispose(&buf);
+ git_str_dispose(&str);
+}
diff --git a/tests/core/dirent.c b/tests/core/dirent.c
index 08e0b11cf..ce93e0358 100644
--- a/tests/core/dirent.c
+++ b/tests/core/dirent.c
@@ -9,7 +9,7 @@ typedef struct name_data {
typedef struct walk_data {
char *sub; /* sub-directory name */
name_data *names; /* name state data */
- git_buf path;
+ git_str path;
} walk_data;
@@ -27,7 +27,7 @@ static void setup(walk_data *d)
if (strcmp(d->sub, ".") != 0)
cl_must_pass(p_mkdir(d->sub, 0777));
- cl_git_pass(git_buf_sets(&d->path, d->sub));
+ cl_git_pass(git_str_sets(&d->path, d->sub));
state_loc = d;
@@ -55,7 +55,7 @@ static void dirent_cleanup__cb(void *_d)
cl_must_pass(p_rmdir(top_dir));
- git_buf_dispose(&d->path);
+ git_str_dispose(&d->path);
}
static void check_counts(walk_data *d)
@@ -81,7 +81,7 @@ static int update_count(name_data *data, const char *name)
return GIT_ERROR;
}
-static int one_entry(void *state, git_buf *path)
+static int one_entry(void *state, git_str *path)
{
walk_data *d = (walk_data *) state;
@@ -104,7 +104,7 @@ static name_data dot_names[] = {
static walk_data dot = {
".",
dot_names,
- GIT_BUF_INIT
+ GIT_STR_INIT
};
/* make sure that the '.' folder is not traversed */
@@ -128,7 +128,7 @@ static name_data sub_names[] = {
static walk_data sub = {
"sub",
sub_names,
- GIT_BUF_INIT
+ GIT_STR_INIT
};
/* traverse a subfolder */
@@ -146,7 +146,7 @@ void test_core_dirent__traverse_subfolder(void)
static walk_data sub_slash = {
"sub/",
sub_names,
- GIT_BUF_INIT
+ GIT_STR_INIT
};
/* traverse a slash-terminated subfolder */
@@ -167,7 +167,7 @@ static name_data empty_names[] = {
static walk_data empty = {
"empty",
empty_names,
- GIT_BUF_INIT
+ GIT_STR_INIT
};
/* make sure that empty folders are not traversed */
@@ -195,7 +195,7 @@ static name_data odd_names[] = {
static walk_data odd = {
"odd",
odd_names,
- GIT_BUF_INIT
+ GIT_STR_INIT
};
/* make sure that strange looking filenames ('..c') are traversed */
diff --git a/tests/core/env.c b/tests/core/env.c
index 3c34b2c4d..9a3f0ae76 100644
--- a/tests/core/env.c
+++ b/tests/core/env.c
@@ -83,7 +83,7 @@ static void setenv_and_check(const char *name, const char *value)
void test_core_env__0(void)
{
- git_buf path = GIT_BUF_INIT, found = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT, found = GIT_STR_INIT;
char testfile[16], tidx = '0';
char **val;
const char *testname = "testfile";
@@ -110,9 +110,9 @@ void test_core_env__0(void)
* accidentally make this test pass...
*/
testfile[testlen] = tidx++;
- cl_git_pass(git_buf_joinpath(&path, path.ptr, testfile));
+ cl_git_pass(git_str_joinpath(&path, path.ptr, testfile));
cl_git_mkfile(path.ptr, "find me");
- git_buf_rtruncate_at_char(&path, '/');
+ git_str_rtruncate_at_char(&path, '/');
cl_assert_equal_i(
GIT_ENOTFOUND, git_sysdir_find_global_file(&found, testfile));
@@ -162,14 +162,14 @@ void test_core_env__0(void)
(void)p_rmdir(*val);
}
- git_buf_dispose(&path);
- git_buf_dispose(&found);
+ git_str_dispose(&path);
+ git_str_dispose(&found);
}
void test_core_env__1(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cl_assert_equal_i(
GIT_ENOTFOUND, git_sysdir_find_global_file(&path, "nonexistentfile"));
@@ -206,21 +206,21 @@ void test_core_env__1(void)
GIT_ENOTFOUND, git_sysdir_find_system_file(&path, "nonexistentfile"));
#endif
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
static void check_global_searchpath(
- const char *path, int position, const char *file, git_buf *temp)
+ const char *path, int position, const char *file, git_str *temp)
{
- git_buf out = GIT_BUF_INIT;
+ git_str out = GIT_STR_INIT;
/* build and set new path */
if (position < 0)
- cl_git_pass(git_buf_join(temp, GIT_PATH_LIST_SEPARATOR, path, "$PATH"));
+ cl_git_pass(git_str_join(temp, GIT_PATH_LIST_SEPARATOR, path, "$PATH"));
else if (position > 0)
- cl_git_pass(git_buf_join(temp, GIT_PATH_LIST_SEPARATOR, "$PATH", path));
+ cl_git_pass(git_str_join(temp, GIT_PATH_LIST_SEPARATOR, "$PATH", path));
else
- cl_git_pass(git_buf_sets(temp, path));
+ cl_git_pass(git_str_sets(temp, path));
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, temp->ptr));
@@ -245,12 +245,12 @@ static void check_global_searchpath(
cl_assert_equal_i(
GIT_ENOTFOUND, git_sysdir_find_global_file(temp, file));
- git_buf_dispose(&out);
+ git_str_dispose(&out);
}
void test_core_env__2(void)
{
- git_buf path = GIT_BUF_INIT, found = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT, found = GIT_STR_INIT;
char testfile[16], tidx = '0';
char **val;
const char *testname = "alternate";
@@ -276,9 +276,9 @@ void test_core_env__2(void)
* deleting files won't accidentally make a test pass.
*/
testfile[testlen] = tidx++;
- cl_git_pass(git_buf_joinpath(&path, path.ptr, testfile));
+ cl_git_pass(git_str_joinpath(&path, path.ptr, testfile));
cl_git_mkfile(path.ptr, "find me");
- git_buf_rtruncate_at_char(&path, '/');
+ git_str_rtruncate_at_char(&path, '/');
/* default should be NOTFOUND */
cl_assert_equal_i(
@@ -290,32 +290,32 @@ void test_core_env__2(void)
check_global_searchpath(path.ptr, 1, testfile, &found);
/* cleanup */
- cl_git_pass(git_buf_joinpath(&path, path.ptr, testfile));
+ cl_git_pass(git_str_joinpath(&path, path.ptr, testfile));
(void)p_unlink(path.ptr);
(void)p_rmdir(*val);
}
- git_buf_dispose(&path);
- git_buf_dispose(&found);
+ git_str_dispose(&path);
+ git_str_dispose(&found);
}
void test_core_env__substitution(void)
{
- git_buf buf = GIT_BUF_INIT, expected = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT, expected = GIT_STR_INIT;
/* Set it to something non-default so we have controllable values */
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, "/tmp/a"));
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &buf));
cl_assert_equal_s("/tmp/a", buf.ptr);
- git_buf_clear(&buf);
- cl_git_pass(git_buf_join(&buf, GIT_PATH_LIST_SEPARATOR, "$PATH", "/tmp/b"));
+ git_str_clear(&buf);
+ cl_git_pass(git_str_join(&buf, GIT_PATH_LIST_SEPARATOR, "$PATH", "/tmp/b"));
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, buf.ptr));
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &buf));
- cl_git_pass(git_buf_join(&expected, GIT_PATH_LIST_SEPARATOR, "/tmp/a", "/tmp/b"));
+ cl_git_pass(git_str_join(&expected, GIT_PATH_LIST_SEPARATOR, "/tmp/a", "/tmp/b"));
cl_assert_equal_s(expected.ptr, buf.ptr);
- git_buf_dispose(&expected);
- git_buf_dispose(&buf);
+ git_str_dispose(&expected);
+ git_str_dispose(&buf);
}
diff --git a/tests/core/filebuf.c b/tests/core/filebuf.c
index e527ce97c..6f654f523 100644
--- a/tests/core/filebuf.c
+++ b/tests/core/filebuf.c
@@ -189,13 +189,13 @@ void test_core_filebuf__symlink_follow(void)
void test_core_filebuf__symlink_follow_absolute_paths(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
- git_buf source = GIT_BUF_INIT, target = GIT_BUF_INIT;
+ git_str source = GIT_STR_INIT, target = GIT_STR_INIT;
if (!git_path_supports_symlinks(clar_sandbox_path()))
cl_skip();
- cl_git_pass(git_buf_joinpath(&source, clar_sandbox_path(), "linkdir/link"));
- cl_git_pass(git_buf_joinpath(&target, clar_sandbox_path(), "linkdir/target"));
+ cl_git_pass(git_str_joinpath(&source, clar_sandbox_path(), "linkdir/link"));
+ cl_git_pass(git_str_joinpath(&target, clar_sandbox_path(), "linkdir/target"));
cl_git_pass(p_mkdir("linkdir", 0777));
cl_git_pass(p_symlink(target.ptr, source.ptr));
@@ -208,8 +208,8 @@ void test_core_filebuf__symlink_follow_absolute_paths(void)
cl_assert_equal_i(true, git_path_exists("linkdir/target"));
git_filebuf_cleanup(&file);
- git_buf_dispose(&source);
- git_buf_dispose(&target);
+ git_str_dispose(&source);
+ git_str_dispose(&target);
cl_git_pass(git_futils_rmdir_r("linkdir", NULL, GIT_RMDIR_REMOVE_FILES));
}
diff --git a/tests/core/futils.c b/tests/core/futils.c
index 2c8294c87..d08043b6e 100644
--- a/tests/core/futils.c
+++ b/tests/core/futils.c
@@ -14,27 +14,27 @@ void test_core_futils__cleanup(void)
void test_core_futils__writebuffer(void)
{
- git_buf out = GIT_BUF_INIT,
- append = GIT_BUF_INIT;
+ git_str out = GIT_STR_INIT,
+ append = GIT_STR_INIT;
/* create a new file */
- git_buf_puts(&out, "hello!\n");
- git_buf_printf(&out, "this is a %s\n", "test");
+ git_str_puts(&out, "hello!\n");
+ git_str_printf(&out, "this is a %s\n", "test");
cl_git_pass(git_futils_writebuffer(&out, "futils/test-file", O_RDWR|O_CREAT, 0666));
cl_assert_equal_file(out.ptr, out.size, "futils/test-file");
/* append some more data */
- git_buf_puts(&append, "And some more!\n");
- git_buf_put(&out, append.ptr, append.size);
+ git_str_puts(&append, "And some more!\n");
+ git_str_put(&out, append.ptr, append.size);
cl_git_pass(git_futils_writebuffer(&append, "futils/test-file", O_RDWR|O_APPEND, 0666));
cl_assert_equal_file(out.ptr, out.size, "futils/test-file");
- git_buf_dispose(&out);
- git_buf_dispose(&append);
+ git_str_dispose(&out);
+ git_str_dispose(&append);
}
void test_core_futils__write_hidden_file(void)
@@ -42,17 +42,17 @@ void test_core_futils__write_hidden_file(void)
#ifndef GIT_WIN32
cl_skip();
#else
- git_buf out = GIT_BUF_INIT, append = GIT_BUF_INIT;
+ git_str out = GIT_STR_INIT, append = GIT_STR_INIT;
bool hidden;
- git_buf_puts(&out, "hidden file.\n");
+ git_str_puts(&out, "hidden file.\n");
git_futils_writebuffer(&out, "futils/test-file", O_RDWR | O_CREAT, 0666);
cl_git_pass(git_win32__set_hidden("futils/test-file", true));
/* append some more data */
- git_buf_puts(&append, "And some more!\n");
- git_buf_put(&out, append.ptr, append.size);
+ git_str_puts(&append, "And some more!\n");
+ git_str_put(&out, append.ptr, append.size);
cl_git_pass(git_futils_writebuffer(&append, "futils/test-file", O_RDWR | O_APPEND, 0666));
@@ -61,8 +61,8 @@ void test_core_futils__write_hidden_file(void)
cl_git_pass(git_win32__hidden(&hidden, "futils/test-file"));
cl_assert(hidden);
- git_buf_dispose(&out);
- git_buf_dispose(&append);
+ git_str_dispose(&out);
+ git_str_dispose(&append);
#endif
}
diff --git a/tests/core/buffer.c b/tests/core/gitstr.c
index 2af4a8712..0a624e28c 100644
--- a/tests/core/buffer.c
+++ b/tests/core/gitstr.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "git2/sys/hashsig.h"
#include "futils.h"
@@ -13,205 +12,205 @@ const char *test_4096 = TESTSTR_4096;
const char *test_8192 = TESTSTR_8192;
/* test basic data concatenation */
-void test_core_buffer__0(void)
+void test_core_gitstr__0(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
cl_assert(buf.size == 0);
- git_buf_puts(&buf, test_string);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(test_string, git_buf_cstr(&buf));
+ git_str_puts(&buf, test_string);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(test_string, git_str_cstr(&buf));
- git_buf_puts(&buf, test_string);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(test_string_x2, git_buf_cstr(&buf));
+ git_str_puts(&buf, test_string);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(test_string_x2, git_str_cstr(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
-/* test git_buf_printf */
-void test_core_buffer__1(void)
+/* test git_str_printf */
+void test_core_gitstr__1(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- git_buf_printf(&buf, "%s %s %d ", "shoop", "da", 23);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s("shoop da 23 ", git_buf_cstr(&buf));
+ git_str_printf(&buf, "%s %s %d ", "shoop", "da", 23);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s("shoop da 23 ", git_str_cstr(&buf));
- git_buf_printf(&buf, "%s %d", "woop", 42);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s("shoop da 23 woop 42", git_buf_cstr(&buf));
+ git_str_printf(&buf, "%s %d", "woop", 42);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s("shoop da 23 woop 42", git_str_cstr(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
/* more thorough test of concatenation options */
-void test_core_buffer__2(void)
+void test_core_gitstr__2(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
int i;
char data[128];
cl_assert(buf.size == 0);
/* this must be safe to do */
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
cl_assert(buf.size == 0);
cl_assert(buf.asize == 0);
/* empty buffer should be empty string */
- cl_assert_equal_s("", git_buf_cstr(&buf));
+ cl_assert_equal_s("", git_str_cstr(&buf));
cl_assert(buf.size == 0);
- /* cl_assert(buf.asize == 0); -- should not assume what git_buf does */
+ /* cl_assert(buf.asize == 0); -- should not assume what git_str does */
/* free should set us back to the beginning */
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
cl_assert(buf.size == 0);
cl_assert(buf.asize == 0);
/* add letter */
- git_buf_putc(&buf, '+');
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s("+", git_buf_cstr(&buf));
+ git_str_putc(&buf, '+');
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s("+", git_str_cstr(&buf));
/* add letter again */
- git_buf_putc(&buf, '+');
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s("++", git_buf_cstr(&buf));
+ git_str_putc(&buf, '+');
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s("++", git_str_cstr(&buf));
/* let's try that a few times */
for (i = 0; i < 16; ++i) {
- git_buf_putc(&buf, '+');
- cl_assert(git_buf_oom(&buf) == 0);
+ git_str_putc(&buf, '+');
+ cl_assert(git_str_oom(&buf) == 0);
}
- cl_assert_equal_s("++++++++++++++++++", git_buf_cstr(&buf));
+ cl_assert_equal_s("++++++++++++++++++", git_str_cstr(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
/* add data */
- git_buf_put(&buf, "xo", 2);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s("xo", git_buf_cstr(&buf));
+ git_str_put(&buf, "xo", 2);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s("xo", git_str_cstr(&buf));
/* add letter again */
- git_buf_put(&buf, "xo", 2);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s("xoxo", git_buf_cstr(&buf));
+ git_str_put(&buf, "xo", 2);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s("xoxo", git_str_cstr(&buf));
/* let's try that a few times */
for (i = 0; i < 16; ++i) {
- git_buf_put(&buf, "xo", 2);
- cl_assert(git_buf_oom(&buf) == 0);
+ git_str_put(&buf, "xo", 2);
+ cl_assert(git_str_oom(&buf) == 0);
}
cl_assert_equal_s("xoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxo",
- git_buf_cstr(&buf));
+ git_str_cstr(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
/* set to string */
- git_buf_sets(&buf, test_string);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(test_string, git_buf_cstr(&buf));
+ git_str_sets(&buf, test_string);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(test_string, git_str_cstr(&buf));
/* append string */
- git_buf_puts(&buf, test_string);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(test_string_x2, git_buf_cstr(&buf));
+ git_str_puts(&buf, test_string);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(test_string_x2, git_str_cstr(&buf));
/* set to string again (should overwrite - not append) */
- git_buf_sets(&buf, test_string);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(test_string, git_buf_cstr(&buf));
+ git_str_sets(&buf, test_string);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(test_string, git_str_cstr(&buf));
/* test clear */
- git_buf_clear(&buf);
- cl_assert_equal_s("", git_buf_cstr(&buf));
+ git_str_clear(&buf);
+ cl_assert_equal_s("", git_str_cstr(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
/* test extracting data into buffer */
- git_buf_puts(&buf, REP4("0123456789"));
- cl_assert(git_buf_oom(&buf) == 0);
+ git_str_puts(&buf, REP4("0123456789"));
+ cl_assert(git_str_oom(&buf) == 0);
- git_buf_copy_cstr(data, sizeof(data), &buf);
+ git_str_copy_cstr(data, sizeof(data), &buf);
cl_assert_equal_s(REP4("0123456789"), data);
- git_buf_copy_cstr(data, 11, &buf);
+ git_str_copy_cstr(data, 11, &buf);
cl_assert_equal_s("0123456789", data);
- git_buf_copy_cstr(data, 3, &buf);
+ git_str_copy_cstr(data, 3, &buf);
cl_assert_equal_s("01", data);
- git_buf_copy_cstr(data, 1, &buf);
+ git_str_copy_cstr(data, 1, &buf);
cl_assert_equal_s("", data);
- git_buf_copy_cstr(data, sizeof(data), &buf);
+ git_str_copy_cstr(data, sizeof(data), &buf);
cl_assert_equal_s(REP4("0123456789"), data);
- git_buf_sets(&buf, REP256("x"));
- git_buf_copy_cstr(data, sizeof(data), &buf);
+ git_str_sets(&buf, REP256("x"));
+ git_str_copy_cstr(data, sizeof(data), &buf);
/* since sizeof(data) == 128, only 127 bytes should be copied */
cl_assert_equal_s(REP4(REP16("x")) REP16("x") REP16("x")
REP16("x") "xxxxxxxxxxxxxxx", data);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
- git_buf_copy_cstr(data, sizeof(data), &buf);
+ git_str_copy_cstr(data, sizeof(data), &buf);
cl_assert_equal_s("", data);
}
/* let's do some tests with larger buffers to push our limits */
-void test_core_buffer__3(void)
+void test_core_gitstr__3(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
/* set to string */
- git_buf_set(&buf, test_4096, 4096);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(test_4096, git_buf_cstr(&buf));
+ git_str_set(&buf, test_4096, 4096);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(test_4096, git_str_cstr(&buf));
/* append string */
- git_buf_puts(&buf, test_4096);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(test_8192, git_buf_cstr(&buf));
+ git_str_puts(&buf, test_4096);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(test_8192, git_str_cstr(&buf));
/* set to string again (should overwrite - not append) */
- git_buf_set(&buf, test_4096, 4096);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(test_4096, git_buf_cstr(&buf));
+ git_str_set(&buf, test_4096, 4096);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(test_4096, git_str_cstr(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
/* let's try some producer/consumer tests */
-void test_core_buffer__4(void)
+void test_core_gitstr__4(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
int i;
for (i = 0; i < 10; ++i) {
- git_buf_puts(&buf, "1234"); /* add 4 */
- cl_assert(git_buf_oom(&buf) == 0);
- git_buf_consume(&buf, buf.ptr + 2); /* eat the first two */
- cl_assert(strlen(git_buf_cstr(&buf)) == (size_t)((i + 1) * 2));
+ git_str_puts(&buf, "1234"); /* add 4 */
+ cl_assert(git_str_oom(&buf) == 0);
+ git_str_consume(&buf, buf.ptr + 2); /* eat the first two */
+ cl_assert(strlen(git_str_cstr(&buf)) == (size_t)((i + 1) * 2));
}
/* we have appended 1234 10x and removed the first 20 letters */
- cl_assert_equal_s("12341234123412341234", git_buf_cstr(&buf));
+ cl_assert_equal_s("12341234123412341234", git_str_cstr(&buf));
- git_buf_consume(&buf, NULL);
- cl_assert_equal_s("12341234123412341234", git_buf_cstr(&buf));
+ git_str_consume(&buf, NULL);
+ cl_assert_equal_s("12341234123412341234", git_str_cstr(&buf));
- git_buf_consume(&buf, "invalid pointer");
- cl_assert_equal_s("12341234123412341234", git_buf_cstr(&buf));
+ git_str_consume(&buf, "invalid pointer");
+ cl_assert_equal_s("12341234123412341234", git_str_cstr(&buf));
- git_buf_consume(&buf, buf.ptr);
- cl_assert_equal_s("12341234123412341234", git_buf_cstr(&buf));
+ git_str_consume(&buf, buf.ptr);
+ cl_assert_equal_s("12341234123412341234", git_str_cstr(&buf));
- git_buf_consume(&buf, buf.ptr + 1);
- cl_assert_equal_s("2341234123412341234", git_buf_cstr(&buf));
+ git_str_consume(&buf, buf.ptr + 1);
+ cl_assert_equal_s("2341234123412341234", git_str_cstr(&buf));
- git_buf_consume(&buf, buf.ptr + buf.size);
- cl_assert_equal_s("", git_buf_cstr(&buf));
+ git_str_consume(&buf, buf.ptr + buf.size);
+ cl_assert_equal_s("", git_str_cstr(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
@@ -223,18 +222,18 @@ check_buf_append(
size_t expected_size,
size_t expected_asize)
{
- git_buf tgt = GIT_BUF_INIT;
+ git_str tgt = GIT_STR_INIT;
- git_buf_sets(&tgt, data_a);
- cl_assert(git_buf_oom(&tgt) == 0);
- git_buf_puts(&tgt, data_b);
- cl_assert(git_buf_oom(&tgt) == 0);
- cl_assert_equal_s(expected_data, git_buf_cstr(&tgt));
+ git_str_sets(&tgt, data_a);
+ cl_assert(git_str_oom(&tgt) == 0);
+ git_str_puts(&tgt, data_b);
+ cl_assert(git_str_oom(&tgt) == 0);
+ cl_assert_equal_s(expected_data, git_str_cstr(&tgt));
cl_assert_equal_i(tgt.size, expected_size);
if (expected_asize > 0)
cl_assert_equal_i(tgt.asize, expected_asize);
- git_buf_dispose(&tgt);
+ git_str_dispose(&tgt);
}
static void
@@ -248,37 +247,37 @@ check_buf_append_abc(
const char* expected_abcab,
const char* expected_abcabc)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- git_buf_sets(&buf, buf_a);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(buf_a, git_buf_cstr(&buf));
+ git_str_sets(&buf, buf_a);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(buf_a, git_str_cstr(&buf));
- git_buf_puts(&buf, buf_b);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(expected_ab, git_buf_cstr(&buf));
+ git_str_puts(&buf, buf_b);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(expected_ab, git_str_cstr(&buf));
- git_buf_puts(&buf, buf_c);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(expected_abc, git_buf_cstr(&buf));
+ git_str_puts(&buf, buf_c);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(expected_abc, git_str_cstr(&buf));
- git_buf_puts(&buf, buf_a);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(expected_abca, git_buf_cstr(&buf));
+ git_str_puts(&buf, buf_a);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(expected_abca, git_str_cstr(&buf));
- git_buf_puts(&buf, buf_b);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(expected_abcab, git_buf_cstr(&buf));
+ git_str_puts(&buf, buf_b);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(expected_abcab, git_str_cstr(&buf));
- git_buf_puts(&buf, buf_c);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(expected_abcabc, git_buf_cstr(&buf));
+ git_str_puts(&buf, buf_c);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(expected_abcabc, git_str_cstr(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
/* more variations on append tests */
-void test_core_buffer__5(void)
+void test_core_gitstr__5(void)
{
check_buf_append("", "", "", 0, 0);
check_buf_append("a", "", "a", 1, 0);
@@ -321,70 +320,70 @@ void test_core_buffer__5(void)
}
/* test swap */
-void test_core_buffer__6(void)
+void test_core_gitstr__6(void)
{
- git_buf a = GIT_BUF_INIT;
- git_buf b = GIT_BUF_INIT;
+ git_str a = GIT_STR_INIT;
+ git_str b = GIT_STR_INIT;
- git_buf_sets(&a, "foo");
- cl_assert(git_buf_oom(&a) == 0);
- git_buf_sets(&b, "bar");
- cl_assert(git_buf_oom(&b) == 0);
+ git_str_sets(&a, "foo");
+ cl_assert(git_str_oom(&a) == 0);
+ git_str_sets(&b, "bar");
+ cl_assert(git_str_oom(&b) == 0);
- cl_assert_equal_s("foo", git_buf_cstr(&a));
- cl_assert_equal_s("bar", git_buf_cstr(&b));
+ cl_assert_equal_s("foo", git_str_cstr(&a));
+ cl_assert_equal_s("bar", git_str_cstr(&b));
- git_buf_swap(&a, &b);
+ git_str_swap(&a, &b);
- cl_assert_equal_s("bar", git_buf_cstr(&a));
- cl_assert_equal_s("foo", git_buf_cstr(&b));
+ cl_assert_equal_s("bar", git_str_cstr(&a));
+ cl_assert_equal_s("foo", git_str_cstr(&b));
- git_buf_dispose(&a);
- git_buf_dispose(&b);
+ git_str_dispose(&a);
+ git_str_dispose(&b);
}
/* test detach/attach data */
-void test_core_buffer__7(void)
+void test_core_gitstr__7(void)
{
const char *fun = "This is fun";
- git_buf a = GIT_BUF_INIT;
+ git_str a = GIT_STR_INIT;
char *b = NULL;
- git_buf_sets(&a, "foo");
- cl_assert(git_buf_oom(&a) == 0);
- cl_assert_equal_s("foo", git_buf_cstr(&a));
+ git_str_sets(&a, "foo");
+ cl_assert(git_str_oom(&a) == 0);
+ cl_assert_equal_s("foo", git_str_cstr(&a));
- b = git_buf_detach(&a);
+ b = git_str_detach(&a);
cl_assert_equal_s("foo", b);
cl_assert_equal_s("", a.ptr);
git__free(b);
- b = git_buf_detach(&a);
+ b = git_str_detach(&a);
cl_assert_equal_s(NULL, b);
cl_assert_equal_s("", a.ptr);
- git_buf_dispose(&a);
+ git_str_dispose(&a);
b = git__strdup(fun);
- git_buf_attach(&a, b, 0);
+ git_str_attach(&a, b, 0);
cl_assert_equal_s(fun, a.ptr);
cl_assert(a.size == strlen(fun));
cl_assert(a.asize == strlen(fun) + 1);
- git_buf_dispose(&a);
+ git_str_dispose(&a);
b = git__strdup(fun);
- git_buf_attach(&a, b, strlen(fun) + 1);
+ git_str_attach(&a, b, strlen(fun) + 1);
cl_assert_equal_s(fun, a.ptr);
cl_assert(a.size == strlen(fun));
cl_assert(a.asize == strlen(fun) + 1);
- git_buf_dispose(&a);
+ git_str_dispose(&a);
}
@@ -395,12 +394,12 @@ check_joinbuf_2(
const char *expected)
{
char sep = '/';
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- git_buf_join(&buf, sep, a, b);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(expected, git_buf_cstr(&buf));
- git_buf_dispose(&buf);
+ git_str_join(&buf, sep, a, b);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(expected, git_str_cstr(&buf));
+ git_str_dispose(&buf);
}
static void
@@ -411,13 +410,13 @@ check_joinbuf_overlapped(
const char *expected)
{
char sep = '/';
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- git_buf_sets(&buf, oldval);
- git_buf_join(&buf, sep, buf.ptr + ofs_a, b);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(expected, git_buf_cstr(&buf));
- git_buf_dispose(&buf);
+ git_str_sets(&buf, oldval);
+ git_str_join(&buf, sep, buf.ptr + ofs_a, b);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(expected, git_str_cstr(&buf));
+ git_str_dispose(&buf);
}
static void
@@ -427,16 +426,16 @@ check_joinbuf_n_2(
const char *expected)
{
char sep = '/';
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- git_buf_sets(&buf, a);
- cl_assert(git_buf_oom(&buf) == 0);
+ git_str_sets(&buf, a);
+ cl_assert(git_str_oom(&buf) == 0);
- git_buf_join_n(&buf, sep, 1, b);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(expected, git_buf_cstr(&buf));
+ git_str_join_n(&buf, sep, 1, b);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(expected, git_str_cstr(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
static void
@@ -448,31 +447,31 @@ check_joinbuf_n_4(
const char *expected)
{
char sep = ';';
- git_buf buf = GIT_BUF_INIT;
- git_buf_join_n(&buf, sep, 4, a, b, c, d);
- cl_assert(git_buf_oom(&buf) == 0);
- cl_assert_equal_s(expected, git_buf_cstr(&buf));
- git_buf_dispose(&buf);
+ git_str buf = GIT_STR_INIT;
+ git_str_join_n(&buf, sep, 4, a, b, c, d);
+ cl_assert(git_str_oom(&buf) == 0);
+ cl_assert_equal_s(expected, git_str_cstr(&buf));
+ git_str_dispose(&buf);
}
/* test join */
-void test_core_buffer__8(void)
+void test_core_gitstr__8(void)
{
- git_buf a = GIT_BUF_INIT;
+ git_str a = GIT_STR_INIT;
- git_buf_join_n(&a, '/', 1, "foo");
- cl_assert(git_buf_oom(&a) == 0);
- cl_assert_equal_s("foo", git_buf_cstr(&a));
+ git_str_join_n(&a, '/', 1, "foo");
+ cl_assert(git_str_oom(&a) == 0);
+ cl_assert_equal_s("foo", git_str_cstr(&a));
- git_buf_join_n(&a, '/', 1, "bar");
- cl_assert(git_buf_oom(&a) == 0);
- cl_assert_equal_s("foo/bar", git_buf_cstr(&a));
+ git_str_join_n(&a, '/', 1, "bar");
+ cl_assert(git_str_oom(&a) == 0);
+ cl_assert_equal_s("foo/bar", git_str_cstr(&a));
- git_buf_join_n(&a, '/', 1, "baz");
- cl_assert(git_buf_oom(&a) == 0);
- cl_assert_equal_s("foo/bar/baz", git_buf_cstr(&a));
+ git_str_join_n(&a, '/', 1, "baz");
+ cl_assert(git_str_oom(&a) == 0);
+ cl_assert_equal_s("foo/bar/baz", git_str_cstr(&a));
- git_buf_dispose(&a);
+ git_str_dispose(&a);
check_joinbuf_2(NULL, "", "");
check_joinbuf_2(NULL, "a", "a");
@@ -537,9 +536,9 @@ void test_core_buffer__8(void)
check_joinbuf_n_4(";abcd;", ";efgh;", ";ijkl;", ";mnop;", ";abcd;efgh;ijkl;mnop;");
}
-void test_core_buffer__9(void)
+void test_core_gitstr__9(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
/* just some exhaustive tests of various separator placement */
char *a[] = { "", "-", "a-", "-a", "-a-" };
@@ -570,68 +569,68 @@ void test_core_buffer__9(void)
for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {
for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {
- git_buf_join(&buf, separator, a[i], b[j]);
+ git_str_join(&buf, separator, a[i], b[j]);
cl_assert_equal_s(*expect, buf.ptr);
expect++;
}
}
}
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
-void test_core_buffer__10(void)
+void test_core_gitstr__10(void)
{
- git_buf a = GIT_BUF_INIT;
+ git_str a = GIT_STR_INIT;
- cl_git_pass(git_buf_join_n(&a, '/', 1, "test"));
+ cl_git_pass(git_str_join_n(&a, '/', 1, "test"));
cl_assert_equal_s(a.ptr, "test");
- cl_git_pass(git_buf_join_n(&a, '/', 1, "string"));
+ cl_git_pass(git_str_join_n(&a, '/', 1, "string"));
cl_assert_equal_s(a.ptr, "test/string");
- git_buf_clear(&a);
- cl_git_pass(git_buf_join_n(&a, '/', 3, "test", "string", "join"));
+ git_str_clear(&a);
+ cl_git_pass(git_str_join_n(&a, '/', 3, "test", "string", "join"));
cl_assert_equal_s(a.ptr, "test/string/join");
- cl_git_pass(git_buf_join_n(&a, '/', 2, a.ptr, "more"));
+ cl_git_pass(git_str_join_n(&a, '/', 2, a.ptr, "more"));
cl_assert_equal_s(a.ptr, "test/string/join/test/string/join/more");
- git_buf_dispose(&a);
+ git_str_dispose(&a);
}
-void test_core_buffer__join3(void)
+void test_core_gitstr__join3(void)
{
- git_buf a = GIT_BUF_INIT;
+ git_str a = GIT_STR_INIT;
- cl_git_pass(git_buf_join3(&a, '/', "test", "string", "join"));
+ cl_git_pass(git_str_join3(&a, '/', "test", "string", "join"));
cl_assert_equal_s("test/string/join", a.ptr);
- cl_git_pass(git_buf_join3(&a, '/', "test/", "string", "join"));
+ cl_git_pass(git_str_join3(&a, '/', "test/", "string", "join"));
cl_assert_equal_s("test/string/join", a.ptr);
- cl_git_pass(git_buf_join3(&a, '/', "test/", "/string", "join"));
+ cl_git_pass(git_str_join3(&a, '/', "test/", "/string", "join"));
cl_assert_equal_s("test/string/join", a.ptr);
- cl_git_pass(git_buf_join3(&a, '/', "test/", "/string/", "join"));
+ cl_git_pass(git_str_join3(&a, '/', "test/", "/string/", "join"));
cl_assert_equal_s("test/string/join", a.ptr);
- cl_git_pass(git_buf_join3(&a, '/', "test/", "/string/", "/join"));
+ cl_git_pass(git_str_join3(&a, '/', "test/", "/string/", "/join"));
cl_assert_equal_s("test/string/join", a.ptr);
- cl_git_pass(git_buf_join3(&a, '/', "", "string", "join"));
+ cl_git_pass(git_str_join3(&a, '/', "", "string", "join"));
cl_assert_equal_s("string/join", a.ptr);
- cl_git_pass(git_buf_join3(&a, '/', "", "string/", "join"));
+ cl_git_pass(git_str_join3(&a, '/', "", "string/", "join"));
cl_assert_equal_s("string/join", a.ptr);
- cl_git_pass(git_buf_join3(&a, '/', "", "string/", "/join"));
+ cl_git_pass(git_str_join3(&a, '/', "", "string/", "/join"));
cl_assert_equal_s("string/join", a.ptr);
- cl_git_pass(git_buf_join3(&a, '/', "string", "", "join"));
+ cl_git_pass(git_str_join3(&a, '/', "string", "", "join"));
cl_assert_equal_s("string/join", a.ptr);
- cl_git_pass(git_buf_join3(&a, '/', "string/", "", "join"));
+ cl_git_pass(git_str_join3(&a, '/', "string/", "", "join"));
cl_assert_equal_s("string/join", a.ptr);
- cl_git_pass(git_buf_join3(&a, '/', "string/", "", "/join"));
+ cl_git_pass(git_str_join3(&a, '/', "string/", "", "/join"));
cl_assert_equal_s("string/join", a.ptr);
- git_buf_dispose(&a);
+ git_str_dispose(&a);
}
-void test_core_buffer__11(void)
+void test_core_gitstr__11(void)
{
- git_buf a = GIT_BUF_INIT;
+ git_str a = GIT_STR_INIT;
char *t1[] = { "nothing", "in", "common" };
char *t2[] = { "something", "something else", "some other" };
char *t3[] = { "something", "some fun", "no fun" };
@@ -640,89 +639,89 @@ void test_core_buffer__11(void)
char *t6[] = { "no", "nope", "" };
char *t7[] = { "", "doesn't matter" };
- cl_git_pass(git_buf_common_prefix(&a, t1, 3));
+ cl_git_pass(git_str_common_prefix(&a, t1, 3));
cl_assert_equal_s(a.ptr, "");
- cl_git_pass(git_buf_common_prefix(&a, t2, 3));
+ cl_git_pass(git_str_common_prefix(&a, t2, 3));
cl_assert_equal_s(a.ptr, "some");
- cl_git_pass(git_buf_common_prefix(&a, t3, 3));
+ cl_git_pass(git_str_common_prefix(&a, t3, 3));
cl_assert_equal_s(a.ptr, "");
- cl_git_pass(git_buf_common_prefix(&a, t4, 3));
+ cl_git_pass(git_str_common_prefix(&a, t4, 3));
cl_assert_equal_s(a.ptr, "happ");
- cl_git_pass(git_buf_common_prefix(&a, t5, 3));
+ cl_git_pass(git_str_common_prefix(&a, t5, 3));
cl_assert_equal_s(a.ptr, "happ");
- cl_git_pass(git_buf_common_prefix(&a, t6, 3));
+ cl_git_pass(git_str_common_prefix(&a, t6, 3));
cl_assert_equal_s(a.ptr, "");
- cl_git_pass(git_buf_common_prefix(&a, t7, 3));
+ cl_git_pass(git_str_common_prefix(&a, t7, 3));
cl_assert_equal_s(a.ptr, "");
- git_buf_dispose(&a);
+ git_str_dispose(&a);
}
-void test_core_buffer__rfind_variants(void)
+void test_core_gitstr__rfind_variants(void)
{
- git_buf a = GIT_BUF_INIT;
+ git_str a = GIT_STR_INIT;
ssize_t len;
- cl_git_pass(git_buf_sets(&a, "/this/is/it/"));
+ cl_git_pass(git_str_sets(&a, "/this/is/it/"));
- len = (ssize_t)git_buf_len(&a);
+ len = (ssize_t)git_str_len(&a);
- cl_assert(git_buf_rfind(&a, '/') == len - 1);
- cl_assert(git_buf_rfind_next(&a, '/') == len - 4);
+ cl_assert(git_str_rfind(&a, '/') == len - 1);
+ cl_assert(git_str_rfind_next(&a, '/') == len - 4);
- cl_assert(git_buf_rfind(&a, 'i') == len - 3);
- cl_assert(git_buf_rfind_next(&a, 'i') == len - 3);
+ cl_assert(git_str_rfind(&a, 'i') == len - 3);
+ cl_assert(git_str_rfind_next(&a, 'i') == len - 3);
- cl_assert(git_buf_rfind(&a, 'h') == 2);
- cl_assert(git_buf_rfind_next(&a, 'h') == 2);
+ cl_assert(git_str_rfind(&a, 'h') == 2);
+ cl_assert(git_str_rfind_next(&a, 'h') == 2);
- cl_assert(git_buf_rfind(&a, 'q') == -1);
- cl_assert(git_buf_rfind_next(&a, 'q') == -1);
+ cl_assert(git_str_rfind(&a, 'q') == -1);
+ cl_assert(git_str_rfind_next(&a, 'q') == -1);
- git_buf_dispose(&a);
+ git_str_dispose(&a);
}
-void test_core_buffer__puts_escaped(void)
+void test_core_gitstr__puts_escaped(void)
{
- git_buf a = GIT_BUF_INIT;
+ git_str a = GIT_STR_INIT;
- git_buf_clear(&a);
- cl_git_pass(git_buf_puts_escaped(&a, "this is a test", "", ""));
+ git_str_clear(&a);
+ cl_git_pass(git_str_puts_escaped(&a, "this is a test", "", ""));
cl_assert_equal_s("this is a test", a.ptr);
- git_buf_clear(&a);
- cl_git_pass(git_buf_puts_escaped(&a, "this is a test", "t", "\\"));
+ git_str_clear(&a);
+ cl_git_pass(git_str_puts_escaped(&a, "this is a test", "t", "\\"));
cl_assert_equal_s("\\this is a \\tes\\t", a.ptr);
- git_buf_clear(&a);
- cl_git_pass(git_buf_puts_escaped(&a, "this is a test", "i ", "__"));
+ git_str_clear(&a);
+ cl_git_pass(git_str_puts_escaped(&a, "this is a test", "i ", "__"));
cl_assert_equal_s("th__is__ __is__ a__ test", a.ptr);
- git_buf_clear(&a);
- cl_git_pass(git_buf_puts_escape_regex(&a, "^match\\s*[A-Z]+.*"));
+ git_str_clear(&a);
+ cl_git_pass(git_str_puts_escape_regex(&a, "^match\\s*[A-Z]+.*"));
cl_assert_equal_s("\\^match\\\\s\\*\\[A-Z\\]\\+\\.\\*", a.ptr);
- git_buf_dispose(&a);
+ git_str_dispose(&a);
}
static void assert_unescape(char *expected, char *to_unescape) {
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_sets(&buf, to_unescape));
- git_buf_unescape(&buf);
+ cl_git_pass(git_str_sets(&buf, to_unescape));
+ git_str_unescape(&buf);
cl_assert_equal_s(expected, buf.ptr);
cl_assert_equal_sz(strlen(expected), buf.size);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
-void test_core_buffer__unescape(void)
+void test_core_gitstr__unescape(void)
{
assert_unescape("Escaped\\", "Es\\ca\\ped\\");
assert_unescape("Es\\caped\\", "Es\\\\ca\\ped\\\\");
@@ -731,9 +730,9 @@ void test_core_buffer__unescape(void)
assert_unescape("", "");
}
-void test_core_buffer__encode_base64(void)
+void test_core_gitstr__encode_base64(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
/* t h i s
* 0x 74 68 69 73
@@ -742,100 +741,100 @@ void test_core_buffer__encode_base64(void)
* 0x 1d 06 21 29 1c 30
* d G h p c w
*/
- cl_git_pass(git_buf_encode_base64(&buf, "this", 4));
+ cl_git_pass(git_str_encode_base64(&buf, "this", 4));
cl_assert_equal_s("dGhpcw==", buf.ptr);
- git_buf_clear(&buf);
- cl_git_pass(git_buf_encode_base64(&buf, "this!", 5));
+ git_str_clear(&buf);
+ cl_git_pass(git_str_encode_base64(&buf, "this!", 5));
cl_assert_equal_s("dGhpcyE=", buf.ptr);
- git_buf_clear(&buf);
- cl_git_pass(git_buf_encode_base64(&buf, "this!\n", 6));
+ git_str_clear(&buf);
+ cl_git_pass(git_str_encode_base64(&buf, "this!\n", 6));
cl_assert_equal_s("dGhpcyEK", buf.ptr);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
-void test_core_buffer__decode_base64(void)
+void test_core_gitstr__decode_base64(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_decode_base64(&buf, "dGhpcw==", 8));
+ cl_git_pass(git_str_decode_base64(&buf, "dGhpcw==", 8));
cl_assert_equal_s("this", buf.ptr);
- git_buf_clear(&buf);
- cl_git_pass(git_buf_decode_base64(&buf, "dGhpcyE=", 8));
+ git_str_clear(&buf);
+ cl_git_pass(git_str_decode_base64(&buf, "dGhpcyE=", 8));
cl_assert_equal_s("this!", buf.ptr);
- git_buf_clear(&buf);
- cl_git_pass(git_buf_decode_base64(&buf, "dGhpcyEK", 8));
+ git_str_clear(&buf);
+ cl_git_pass(git_str_decode_base64(&buf, "dGhpcyEK", 8));
cl_assert_equal_s("this!\n", buf.ptr);
- cl_git_fail(git_buf_decode_base64(&buf, "This is not a valid base64 string!!!", 36));
+ cl_git_fail(git_str_decode_base64(&buf, "This is not a valid base64 string!!!", 36));
cl_assert_equal_s("this!\n", buf.ptr);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
-void test_core_buffer__encode_base85(void)
+void test_core_gitstr__encode_base85(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_encode_base85(&buf, "this", 4));
+ cl_git_pass(git_str_encode_base85(&buf, "this", 4));
cl_assert_equal_s("bZBXF", buf.ptr);
- git_buf_clear(&buf);
+ git_str_clear(&buf);
- cl_git_pass(git_buf_encode_base85(&buf, "two rnds", 8));
+ cl_git_pass(git_str_encode_base85(&buf, "two rnds", 8));
cl_assert_equal_s("ba!tca&BaE", buf.ptr);
- git_buf_clear(&buf);
+ git_str_clear(&buf);
- cl_git_pass(git_buf_encode_base85(&buf, "this is base 85 encoded",
+ cl_git_pass(git_str_encode_base85(&buf, "this is base 85 encoded",
strlen("this is base 85 encoded")));
cl_assert_equal_s("bZBXFAZc?TVqtS-AUHK3Wo~0{WMyOk", buf.ptr);
- git_buf_clear(&buf);
+ git_str_clear(&buf);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
-void test_core_buffer__decode_base85(void)
+void test_core_gitstr__decode_base85(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_decode_base85(&buf, "bZBXF", 5, 4));
+ cl_git_pass(git_str_decode_base85(&buf, "bZBXF", 5, 4));
cl_assert_equal_sz(4, buf.size);
cl_assert_equal_s("this", buf.ptr);
- git_buf_clear(&buf);
+ git_str_clear(&buf);
- cl_git_pass(git_buf_decode_base85(&buf, "ba!tca&BaE", 10, 8));
+ cl_git_pass(git_str_decode_base85(&buf, "ba!tca&BaE", 10, 8));
cl_assert_equal_sz(8, buf.size);
cl_assert_equal_s("two rnds", buf.ptr);
- git_buf_clear(&buf);
+ git_str_clear(&buf);
- cl_git_pass(git_buf_decode_base85(&buf, "bZBXFAZc?TVqtS-AUHK3Wo~0{WMyOk", 30, 23));
+ cl_git_pass(git_str_decode_base85(&buf, "bZBXFAZc?TVqtS-AUHK3Wo~0{WMyOk", 30, 23));
cl_assert_equal_sz(23, buf.size);
cl_assert_equal_s("this is base 85 encoded", buf.ptr);
- git_buf_clear(&buf);
+ git_str_clear(&buf);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
-void test_core_buffer__decode_base85_fails_gracefully(void)
+void test_core_gitstr__decode_base85_fails_gracefully(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- git_buf_puts(&buf, "foobar");
+ git_str_puts(&buf, "foobar");
- cl_git_fail(git_buf_decode_base85(&buf, "invalid charsZZ", 15, 42));
- cl_git_fail(git_buf_decode_base85(&buf, "invalidchars__ ", 15, 42));
- cl_git_fail(git_buf_decode_base85(&buf, "overflowZZ~~~~~", 15, 42));
- cl_git_fail(git_buf_decode_base85(&buf, "truncated", 9, 42));
+ cl_git_fail(git_str_decode_base85(&buf, "invalid charsZZ", 15, 42));
+ cl_git_fail(git_str_decode_base85(&buf, "invalidchars__ ", 15, 42));
+ cl_git_fail(git_str_decode_base85(&buf, "overflowZZ~~~~~", 15, 42));
+ cl_git_fail(git_str_decode_base85(&buf, "truncated", 9, 42));
cl_assert_equal_sz(6, buf.size);
cl_assert_equal_s("foobar", buf.ptr);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
-void test_core_buffer__classify_with_utf8(void)
+void test_core_gitstr__classify_with_utf8(void)
{
char *data0 = "Simple text\n";
size_t data0len = 12;
@@ -845,23 +844,23 @@ void test_core_buffer__classify_with_utf8(void)
size_t data2len = 29;
char *data3 = "\xef\xbb\xbfThis is UTF-8 with a BOM.\n";
size_t data3len = 20;
- git_buf b;
+ git_str b;
b.ptr = data0; b.size = b.asize = data0len;
- cl_assert(!git_buf_is_binary(&b));
- cl_assert(!git_buf_contains_nul(&b));
+ cl_assert(!git_str_is_binary(&b));
+ cl_assert(!git_str_contains_nul(&b));
b.ptr = data1; b.size = b.asize = data1len;
- cl_assert(!git_buf_is_binary(&b));
- cl_assert(!git_buf_contains_nul(&b));
+ cl_assert(!git_str_is_binary(&b));
+ cl_assert(!git_str_contains_nul(&b));
b.ptr = data2; b.size = b.asize = data2len;
- cl_assert(git_buf_is_binary(&b));
- cl_assert(git_buf_contains_nul(&b));
+ cl_assert(git_str_is_binary(&b));
+ cl_assert(git_str_contains_nul(&b));
b.ptr = data3; b.size = b.asize = data3len;
- cl_assert(!git_buf_is_binary(&b));
- cl_assert(!git_buf_contains_nul(&b));
+ cl_assert(!git_str_is_binary(&b));
+ cl_assert(!git_str_contains_nul(&b));
}
#define SIMILARITY_TEST_DATA_1 \
@@ -871,15 +870,15 @@ void test_core_buffer__classify_with_utf8(void)
"030\n031\n032\n033\n034\n035\n036\n037\n038\n039\n" \
"040\n041\n042\n043\n044\n045\n046\n047\n048\n049\n"
-void test_core_buffer__similarity_metric(void)
+void test_core_gitstr__similarity_metric(void)
{
git_hashsig *a, *b;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
int sim;
/* in the first case, we compare data to itself and expect 100% match */
- cl_git_pass(git_buf_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
@@ -890,9 +889,9 @@ void test_core_buffer__similarity_metric(void)
/* if we change just a single byte, how much does that change magnify? */
- cl_git_pass(git_buf_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
- cl_git_pass(git_buf_sets(&buf,
+ cl_git_pass(git_str_sets(&buf,
"000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
"010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
"x020x\n021\n022\n023\n024\n025\n026\n027\n028\n029\n" \
@@ -910,9 +909,9 @@ void test_core_buffer__similarity_metric(void)
/* let's try comparing data to a superset of itself */
- cl_git_pass(git_buf_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
- cl_git_pass(git_buf_sets(&buf, SIMILARITY_TEST_DATA_1
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1
"050\n051\n052\n053\n054\n055\n056\n057\n058\n059\n"));
cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
@@ -926,9 +925,9 @@ void test_core_buffer__similarity_metric(void)
/* what if we keep about half the original data and add half new */
- cl_git_pass(git_buf_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
- cl_git_pass(git_buf_sets(&buf,
+ cl_git_pass(git_str_sets(&buf,
"000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
"010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
"020x\n021\n022\n023\n024\n" \
@@ -948,7 +947,7 @@ void test_core_buffer__similarity_metric(void)
/* lastly, let's check that we can hash file content as well */
- cl_git_pass(git_buf_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
cl_git_pass(git_futils_mkdir("scratch", 0755, GIT_MKDIR_PATH));
@@ -961,15 +960,15 @@ void test_core_buffer__similarity_metric(void)
git_hashsig_free(a);
git_hashsig_free(b);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
git_futils_rmdir_r("scratch", NULL, GIT_RMDIR_REMOVE_FILES);
}
-void test_core_buffer__similarity_metric_whitespace(void)
+void test_core_gitstr__similarity_metric_whitespace(void)
{
git_hashsig *a, *b;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
int sim, i, j;
git_hashsig_option_t opt;
const char *tabbed =
@@ -979,7 +978,7 @@ void test_core_buffer__similarity_metric_whitespace(void)
"\n"
" for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\n"
" for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\n"
- " git_buf_join(&buf, separator, a[i], b[j]);\n"
+ " git_str_join(&buf, separator, a[i], b[j]);\n"
" cl_assert_equal_s(*expect, buf.ptr);\n"
" expect++;\n"
" }\n"
@@ -992,7 +991,7 @@ void test_core_buffer__similarity_metric_whitespace(void)
"\n"
" for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\n"
" for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\n"
- " git_buf_join(&buf, separator, a[i], b[j]);\n"
+ " git_str_join(&buf, separator, a[i], b[j]);\n"
" cl_assert_equal_s(*expect, buf.ptr);\n"
" expect++;\n"
" }\n"
@@ -1005,7 +1004,7 @@ void test_core_buffer__similarity_metric_whitespace(void)
"\r\n"
" for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\r\n"
" for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\r\n"
- " git_buf_join(&buf, separator, a[i], b[j]);\r\n"
+ " git_str_join(&buf, separator, a[i], b[j]);\r\n"
" cl_assert_equal_s(*expect, buf.ptr);\r\n"
" expect++;\r\n"
" }\r\n"
@@ -1018,10 +1017,10 @@ void test_core_buffer__similarity_metric_whitespace(void)
for (opt = GIT_HASHSIG_NORMAL; opt <= GIT_HASHSIG_SMART_WHITESPACE; ++opt) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
- cl_git_pass(git_buf_sets(&buf, text[i]));
+ cl_git_pass(git_str_sets(&buf, text[i]));
cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, opt));
- cl_git_pass(git_buf_sets(&buf, text[j]));
+ cl_git_pass(git_str_sets(&buf, text[j]));
cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, opt));
sim = git_hashsig_compare(a, b);
@@ -1041,7 +1040,7 @@ void test_core_buffer__similarity_metric_whitespace(void)
}
}
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
#include "../filter/crlf.h"
@@ -1050,177 +1049,177 @@ void test_core_buffer__similarity_metric_whitespace(void)
cl_assert_equal_s(expected, buf.ptr); \
cl_assert_equal_sz(strlen(expected), buf.size); } while (0)
-void test_core_buffer__lf_and_crlf_conversions(void)
+void test_core_gitstr__lf_and_crlf_conversions(void)
{
- git_buf src = GIT_BUF_INIT, tgt = GIT_BUF_INIT;
+ git_str src = GIT_STR_INIT, tgt = GIT_STR_INIT;
/* LF source */
- git_buf_sets(&src, "lf\nlf\nlf\nlf\n");
+ git_str_sets(&src, "lf\nlf\nlf\nlf\n");
- cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_str_lf_to_crlf(&tgt, &src));
check_buf("lf\r\nlf\r\nlf\r\nlf\r\n", tgt);
- cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_str_crlf_to_lf(&tgt, &src));
check_buf(src.ptr, tgt);
- git_buf_sets(&src, "\nlf\nlf\nlf\nlf\nlf");
+ git_str_sets(&src, "\nlf\nlf\nlf\nlf\nlf");
- cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_str_lf_to_crlf(&tgt, &src));
check_buf("\r\nlf\r\nlf\r\nlf\r\nlf\r\nlf", tgt);
- cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_str_crlf_to_lf(&tgt, &src));
check_buf(src.ptr, tgt);
/* CRLF source */
- git_buf_sets(&src, "crlf\r\ncrlf\r\ncrlf\r\ncrlf\r\n");
+ git_str_sets(&src, "crlf\r\ncrlf\r\ncrlf\r\ncrlf\r\n");
- cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_str_lf_to_crlf(&tgt, &src));
check_buf("crlf\r\ncrlf\r\ncrlf\r\ncrlf\r\n", tgt);
- git_buf_sets(&src, "crlf\r\ncrlf\r\ncrlf\r\ncrlf\r\n");
+ git_str_sets(&src, "crlf\r\ncrlf\r\ncrlf\r\ncrlf\r\n");
- cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_str_crlf_to_lf(&tgt, &src));
check_buf("crlf\ncrlf\ncrlf\ncrlf\n", tgt);
- git_buf_sets(&src, "\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf");
+ git_str_sets(&src, "\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf");
- cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_str_lf_to_crlf(&tgt, &src));
check_buf("\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf", tgt);
- git_buf_sets(&src, "\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf");
+ git_str_sets(&src, "\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf");
- cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_str_crlf_to_lf(&tgt, &src));
check_buf("\ncrlf\ncrlf\ncrlf\ncrlf\ncrlf", tgt);
/* CRLF in LF text */
- git_buf_sets(&src, "\nlf\nlf\ncrlf\r\nlf\nlf\ncrlf\r\n");
+ git_str_sets(&src, "\nlf\nlf\ncrlf\r\nlf\nlf\ncrlf\r\n");
- cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_str_lf_to_crlf(&tgt, &src));
check_buf("\r\nlf\r\nlf\r\ncrlf\r\nlf\r\nlf\r\ncrlf\r\n", tgt);
- git_buf_sets(&src, "\nlf\nlf\ncrlf\r\nlf\nlf\ncrlf\r\n");
+ git_str_sets(&src, "\nlf\nlf\ncrlf\r\nlf\nlf\ncrlf\r\n");
- cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_str_crlf_to_lf(&tgt, &src));
check_buf("\nlf\nlf\ncrlf\nlf\nlf\ncrlf\n", tgt);
/* LF in CRLF text */
- git_buf_sets(&src, "\ncrlf\r\ncrlf\r\nlf\ncrlf\r\ncrlf");
+ git_str_sets(&src, "\ncrlf\r\ncrlf\r\nlf\ncrlf\r\ncrlf");
- cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_str_lf_to_crlf(&tgt, &src));
check_buf("\r\ncrlf\r\ncrlf\r\nlf\r\ncrlf\r\ncrlf", tgt);
- cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_str_crlf_to_lf(&tgt, &src));
check_buf("\ncrlf\ncrlf\nlf\ncrlf\ncrlf", tgt);
/* bare CR test */
- git_buf_sets(&src, "\rcrlf\r\nlf\nlf\ncr\rcrlf\r\nlf\ncr\r");
+ git_str_sets(&src, "\rcrlf\r\nlf\nlf\ncr\rcrlf\r\nlf\ncr\r");
- cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_str_lf_to_crlf(&tgt, &src));
check_buf("\rcrlf\r\nlf\r\nlf\r\ncr\rcrlf\r\nlf\r\ncr\r", tgt);
- git_buf_sets(&src, "\rcrlf\r\nlf\nlf\ncr\rcrlf\r\nlf\ncr\r");
+ git_str_sets(&src, "\rcrlf\r\nlf\nlf\ncr\rcrlf\r\nlf\ncr\r");
- cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_str_crlf_to_lf(&tgt, &src));
check_buf("\rcrlf\nlf\nlf\ncr\rcrlf\nlf\ncr\r", tgt);
- git_buf_sets(&src, "\rcr\r");
- cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
+ git_str_sets(&src, "\rcr\r");
+ cl_git_pass(git_str_lf_to_crlf(&tgt, &src));
check_buf(src.ptr, tgt);
- cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_str_crlf_to_lf(&tgt, &src));
check_buf("\rcr\r", tgt);
- git_buf_dispose(&src);
- git_buf_dispose(&tgt);
+ git_str_dispose(&src);
+ git_str_dispose(&tgt);
/* blob correspondence tests */
- git_buf_sets(&src, ALL_CRLF_TEXT_RAW);
- cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
+ git_str_sets(&src, ALL_CRLF_TEXT_RAW);
+ cl_git_pass(git_str_lf_to_crlf(&tgt, &src));
check_buf(ALL_CRLF_TEXT_AS_CRLF, tgt);
- git_buf_sets(&src, ALL_CRLF_TEXT_RAW);
- cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
+ git_str_sets(&src, ALL_CRLF_TEXT_RAW);
+ cl_git_pass(git_str_crlf_to_lf(&tgt, &src));
check_buf(ALL_CRLF_TEXT_AS_LF, tgt);
- git_buf_dispose(&src);
- git_buf_dispose(&tgt);
+ git_str_dispose(&src);
+ git_str_dispose(&tgt);
- git_buf_sets(&src, ALL_LF_TEXT_RAW);
- cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
+ git_str_sets(&src, ALL_LF_TEXT_RAW);
+ cl_git_pass(git_str_lf_to_crlf(&tgt, &src));
check_buf(ALL_LF_TEXT_AS_CRLF, tgt);
- git_buf_sets(&src, ALL_LF_TEXT_RAW);
- cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
+ git_str_sets(&src, ALL_LF_TEXT_RAW);
+ cl_git_pass(git_str_crlf_to_lf(&tgt, &src));
check_buf(ALL_LF_TEXT_AS_LF, tgt);
- git_buf_dispose(&src);
- git_buf_dispose(&tgt);
+ git_str_dispose(&src);
+ git_str_dispose(&tgt);
- git_buf_sets(&src, MORE_CRLF_TEXT_RAW);
- cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
+ git_str_sets(&src, MORE_CRLF_TEXT_RAW);
+ cl_git_pass(git_str_lf_to_crlf(&tgt, &src));
check_buf(MORE_CRLF_TEXT_AS_CRLF, tgt);
- git_buf_sets(&src, MORE_CRLF_TEXT_RAW);
- cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
+ git_str_sets(&src, MORE_CRLF_TEXT_RAW);
+ cl_git_pass(git_str_crlf_to_lf(&tgt, &src));
check_buf(MORE_CRLF_TEXT_AS_LF, tgt);
- git_buf_dispose(&src);
- git_buf_dispose(&tgt);
+ git_str_dispose(&src);
+ git_str_dispose(&tgt);
- git_buf_sets(&src, MORE_LF_TEXT_RAW);
- cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
+ git_str_sets(&src, MORE_LF_TEXT_RAW);
+ cl_git_pass(git_str_lf_to_crlf(&tgt, &src));
check_buf(MORE_LF_TEXT_AS_CRLF, tgt);
- git_buf_sets(&src, MORE_LF_TEXT_RAW);
- cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
+ git_str_sets(&src, MORE_LF_TEXT_RAW);
+ cl_git_pass(git_str_crlf_to_lf(&tgt, &src));
check_buf(MORE_LF_TEXT_AS_LF, tgt);
- git_buf_dispose(&src);
- git_buf_dispose(&tgt);
+ git_str_dispose(&src);
+ git_str_dispose(&tgt);
}
-void test_core_buffer__dont_grow_borrowed(void)
+void test_core_gitstr__dont_grow_borrowed(void)
{
const char *somestring = "blah blah";
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- git_buf_attach_notowned(&buf, somestring, strlen(somestring) + 1);
+ git_str_attach_notowned(&buf, somestring, strlen(somestring) + 1);
cl_assert_equal_p(somestring, buf.ptr);
cl_assert_equal_i(0, buf.asize);
cl_assert_equal_i(strlen(somestring) + 1, buf.size);
- cl_git_fail_with(GIT_EINVALID, git_buf_grow(&buf, 1024));
+ cl_git_fail_with(GIT_EINVALID, git_str_grow(&buf, 1024));
}
-void test_core_buffer__dont_hit_infinite_loop_when_resizing(void)
+void test_core_gitstr__dont_hit_infinite_loop_when_resizing(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_puts(&buf, "foobar"));
+ cl_git_pass(git_str_puts(&buf, "foobar"));
/*
* We do not care whether this succeeds or fails, which
* would depend on platform-specific allocation
* semantics. We only want to know that the function
* actually returns.
*/
- (void)git_buf_try_grow(&buf, SIZE_MAX, true);
+ (void)git_str_try_grow(&buf, SIZE_MAX, true);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
-void test_core_buffer__avoid_printing_into_oom_buffer(void)
+void test_core_gitstr__avoid_printing_into_oom_buffer(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
/* Emulate OOM situation with a previous allocation */
buf.asize = 8;
- buf.ptr = git_buf__oom;
+ buf.ptr = git_str__oom;
/*
* Print the same string again. As the buffer still has
* an `asize` of 8 due to the previous print,
* `ENSURE_SIZE` would not try to reallocate the array at
- * all. As it didn't explicitly check for `git_buf__oom`
+ * all. As it didn't explicitly check for `git_str__oom`
* in earlier versions, this would've resulted in it
- * returning successfully and thus `git_buf_puts` would
- * just print into the `git_buf__oom` array.
+ * returning successfully and thus `git_str_puts` would
+ * just print into the `git_str__oom` array.
*/
- cl_git_fail(git_buf_puts(&buf, "foobar"));
+ cl_git_fail(git_str_puts(&buf, "foobar"));
}
diff --git a/tests/core/link.c b/tests/core/link.c
index 0493edf1d..6ab79b2a8 100644
--- a/tests/core/link.c
+++ b/tests/core/link.c
@@ -1,6 +1,5 @@
#include "clar_libgit2.h"
#include "posix.h"
-#include "buffer.h"
#include "path.h"
#ifdef GIT_WIN32
@@ -82,7 +81,7 @@ static void do_junction(const char *old, const char *new)
{
GIT_REPARSE_DATA_BUFFER *reparse_buf;
HANDLE handle;
- git_buf unparsed_buf = GIT_BUF_INIT;
+ git_str unparsed_buf = GIT_STR_INIT;
wchar_t *subst_utf16, *print_utf16;
DWORD ioctl_ret;
int subst_utf16_len, subst_byte_len, print_utf16_len, print_byte_len, ret;
@@ -93,14 +92,14 @@ static void do_junction(const char *old, const char *new)
* backslashes instead of forward, and end in a trailing backslash.
* eg: \??\C:\Foo\
*/
- git_buf_puts(&unparsed_buf, "\\??\\");
+ git_str_puts(&unparsed_buf, "\\??\\");
for (i = 0; i < strlen(old); i++)
- git_buf_putc(&unparsed_buf, old[i] == '/' ? '\\' : old[i]);
+ git_str_putc(&unparsed_buf, old[i] == '/' ? '\\' : old[i]);
- git_buf_putc(&unparsed_buf, '\\');
+ git_str_putc(&unparsed_buf, '\\');
- subst_utf16_len = git__utf8_to_16(NULL, 0, git_buf_cstr(&unparsed_buf));
+ subst_utf16_len = git__utf8_to_16(NULL, 0, git_str_cstr(&unparsed_buf));
subst_byte_len = subst_utf16_len * sizeof(WCHAR);
print_utf16_len = subst_utf16_len - 4;
@@ -127,11 +126,11 @@ static void do_junction(const char *old, const char *new)
print_utf16 = subst_utf16 + subst_utf16_len + 1;
ret = git__utf8_to_16(subst_utf16, subst_utf16_len + 1,
- git_buf_cstr(&unparsed_buf));
+ git_str_cstr(&unparsed_buf));
cl_assert_equal_i(subst_utf16_len, ret);
ret = git__utf8_to_16(print_utf16,
- print_utf16_len + 1, git_buf_cstr(&unparsed_buf) + 4);
+ print_utf16_len + 1, git_str_cstr(&unparsed_buf) + 4);
cl_assert_equal_i(print_utf16_len, ret);
reparse_buf->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
@@ -147,7 +146,7 @@ static void do_junction(const char *old, const char *new)
CloseHandle(handle);
LocalFree(reparse_buf);
- git_buf_dispose(&unparsed_buf);
+ git_str_dispose(&unparsed_buf);
}
static void do_custom_reparse(const char *path)
@@ -300,7 +299,7 @@ void test_core_link__stat_dangling_symlink_directory(void)
void test_core_link__lstat_symlink(void)
{
- git_buf target_path = GIT_BUF_INIT;
+ git_str target_path = GIT_STR_INIT;
struct stat st;
if (!should_run())
@@ -309,10 +308,10 @@ void test_core_link__lstat_symlink(void)
/* Windows always writes the canonical path as the link target, so
* write the full path on all platforms.
*/
- git_buf_join(&target_path, '/', clar_sandbox_path(), "lstat_target");
+ git_str_join(&target_path, '/', clar_sandbox_path(), "lstat_target");
cl_git_rewritefile("lstat_target", "This is the target of a symbolic link.\n");
- do_symlink(git_buf_cstr(&target_path), "lstat_symlink", 0);
+ do_symlink(git_str_cstr(&target_path), "lstat_symlink", 0);
cl_must_pass(p_lstat("lstat_target", &st));
cl_assert(S_ISREG(st.st_mode));
@@ -320,32 +319,32 @@ void test_core_link__lstat_symlink(void)
cl_must_pass(p_lstat("lstat_symlink", &st));
cl_assert(S_ISLNK(st.st_mode));
- cl_assert_equal_i(git_buf_len(&target_path), st.st_size);
+ cl_assert_equal_i(git_str_len(&target_path), st.st_size);
- git_buf_dispose(&target_path);
+ git_str_dispose(&target_path);
}
void test_core_link__lstat_symlink_directory(void)
{
- git_buf target_path = GIT_BUF_INIT;
+ git_str target_path = GIT_STR_INIT;
struct stat st;
if (!should_run())
clar__skip();
- git_buf_join(&target_path, '/', clar_sandbox_path(), "lstat_dirtarget");
+ git_str_join(&target_path, '/', clar_sandbox_path(), "lstat_dirtarget");
p_mkdir("lstat_dirtarget", 0777);
- do_symlink(git_buf_cstr(&target_path), "lstat_dirlink", 1);
+ do_symlink(git_str_cstr(&target_path), "lstat_dirlink", 1);
cl_must_pass(p_lstat("lstat_dirtarget", &st));
cl_assert(S_ISDIR(st.st_mode));
cl_must_pass(p_lstat("lstat_dirlink", &st));
cl_assert(S_ISLNK(st.st_mode));
- cl_assert_equal_i(git_buf_len(&target_path), st.st_size);
+ cl_assert_equal_i(git_str_len(&target_path), st.st_size);
- git_buf_dispose(&target_path);
+ git_str_dispose(&target_path);
}
void test_core_link__lstat_dangling_symlink(void)
@@ -383,13 +382,13 @@ void test_core_link__lstat_dangling_symlink_directory(void)
void test_core_link__stat_junction(void)
{
#ifdef GIT_WIN32
- git_buf target_path = GIT_BUF_INIT;
+ git_str target_path = GIT_STR_INIT;
struct stat st;
- git_buf_join(&target_path, '/', clar_sandbox_path(), "stat_junctarget");
+ git_str_join(&target_path, '/', clar_sandbox_path(), "stat_junctarget");
p_mkdir("stat_junctarget", 0777);
- do_junction(git_buf_cstr(&target_path), "stat_junction");
+ do_junction(git_str_cstr(&target_path), "stat_junction");
cl_must_pass(p_stat("stat_junctarget", &st));
cl_assert(S_ISDIR(st.st_mode));
@@ -397,40 +396,40 @@ void test_core_link__stat_junction(void)
cl_must_pass(p_stat("stat_junction", &st));
cl_assert(S_ISDIR(st.st_mode));
- git_buf_dispose(&target_path);
+ git_str_dispose(&target_path);
#endif
}
void test_core_link__stat_dangling_junction(void)
{
#ifdef GIT_WIN32
- git_buf target_path = GIT_BUF_INIT;
+ git_str target_path = GIT_STR_INIT;
struct stat st;
- git_buf_join(&target_path, '/', clar_sandbox_path(), "stat_nonexistent_junctarget");
+ git_str_join(&target_path, '/', clar_sandbox_path(), "stat_nonexistent_junctarget");
p_mkdir("stat_nonexistent_junctarget", 0777);
- do_junction(git_buf_cstr(&target_path), "stat_dangling_junction");
+ do_junction(git_str_cstr(&target_path), "stat_dangling_junction");
RemoveDirectory("stat_nonexistent_junctarget");
cl_must_fail(p_stat("stat_nonexistent_junctarget", &st));
cl_must_fail(p_stat("stat_dangling_junction", &st));
- git_buf_dispose(&target_path);
+ git_str_dispose(&target_path);
#endif
}
void test_core_link__lstat_junction(void)
{
#ifdef GIT_WIN32
- git_buf target_path = GIT_BUF_INIT;
+ git_str target_path = GIT_STR_INIT;
struct stat st;
- git_buf_join(&target_path, '/', clar_sandbox_path(), "lstat_junctarget");
+ git_str_join(&target_path, '/', clar_sandbox_path(), "lstat_junctarget");
p_mkdir("lstat_junctarget", 0777);
- do_junction(git_buf_cstr(&target_path), "lstat_junction");
+ do_junction(git_str_cstr(&target_path), "lstat_junction");
cl_must_pass(p_lstat("lstat_junctarget", &st));
cl_assert(S_ISDIR(st.st_mode));
@@ -438,20 +437,20 @@ void test_core_link__lstat_junction(void)
cl_must_pass(p_lstat("lstat_junction", &st));
cl_assert(S_ISLNK(st.st_mode));
- git_buf_dispose(&target_path);
+ git_str_dispose(&target_path);
#endif
}
void test_core_link__lstat_dangling_junction(void)
{
#ifdef GIT_WIN32
- git_buf target_path = GIT_BUF_INIT;
+ git_str target_path = GIT_STR_INIT;
struct stat st;
- git_buf_join(&target_path, '/', clar_sandbox_path(), "lstat_nonexistent_junctarget");
+ git_str_join(&target_path, '/', clar_sandbox_path(), "lstat_nonexistent_junctarget");
p_mkdir("lstat_nonexistent_junctarget", 0777);
- do_junction(git_buf_cstr(&target_path), "lstat_dangling_junction");
+ do_junction(git_str_cstr(&target_path), "lstat_dangling_junction");
RemoveDirectory("lstat_nonexistent_junctarget");
@@ -459,9 +458,9 @@ void test_core_link__lstat_dangling_junction(void)
cl_must_pass(p_lstat("lstat_dangling_junction", &st));
cl_assert(S_ISLNK(st.st_mode));
- cl_assert_equal_i(git_buf_len(&target_path), st.st_size);
+ cl_assert_equal_i(git_str_len(&target_path), st.st_size);
- git_buf_dispose(&target_path);
+ git_str_dispose(&target_path);
#endif
}
@@ -554,79 +553,79 @@ void test_core_link__readlink_normal_file(void)
void test_core_link__readlink_symlink(void)
{
- git_buf target_path = GIT_BUF_INIT;
+ git_str target_path = GIT_STR_INIT;
int len;
char buf[2048];
if (!should_run())
clar__skip();
- git_buf_join(&target_path, '/', clar_sandbox_path(), "readlink_target");
+ git_str_join(&target_path, '/', clar_sandbox_path(), "readlink_target");
cl_git_rewritefile("readlink_target", "This is the target of a symlink\n");
- do_symlink(git_buf_cstr(&target_path), "readlink_link", 0);
+ do_symlink(git_str_cstr(&target_path), "readlink_link", 0);
len = p_readlink("readlink_link", buf, 2048);
cl_must_pass(len);
buf[len] = 0;
- cl_assert_equal_s(git_buf_cstr(&target_path), buf);
+ cl_assert_equal_s(git_str_cstr(&target_path), buf);
- git_buf_dispose(&target_path);
+ git_str_dispose(&target_path);
}
void test_core_link__readlink_dangling(void)
{
- git_buf target_path = GIT_BUF_INIT;
+ git_str target_path = GIT_STR_INIT;
int len;
char buf[2048];
if (!should_run())
clar__skip();
- git_buf_join(&target_path, '/', clar_sandbox_path(), "readlink_nonexistent");
+ git_str_join(&target_path, '/', clar_sandbox_path(), "readlink_nonexistent");
- do_symlink(git_buf_cstr(&target_path), "readlink_dangling", 0);
+ do_symlink(git_str_cstr(&target_path), "readlink_dangling", 0);
len = p_readlink("readlink_dangling", buf, 2048);
cl_must_pass(len);
buf[len] = 0;
- cl_assert_equal_s(git_buf_cstr(&target_path), buf);
+ cl_assert_equal_s(git_str_cstr(&target_path), buf);
- git_buf_dispose(&target_path);
+ git_str_dispose(&target_path);
}
void test_core_link__readlink_multiple(void)
{
- git_buf target_path = GIT_BUF_INIT,
- path3 = GIT_BUF_INIT, path2 = GIT_BUF_INIT, path1 = GIT_BUF_INIT;
+ git_str target_path = GIT_STR_INIT,
+ path3 = GIT_STR_INIT, path2 = GIT_STR_INIT, path1 = GIT_STR_INIT;
int len;
char buf[2048];
if (!should_run())
clar__skip();
- git_buf_join(&target_path, '/', clar_sandbox_path(), "readlink_final");
- git_buf_join(&path3, '/', clar_sandbox_path(), "readlink_3");
- git_buf_join(&path2, '/', clar_sandbox_path(), "readlink_2");
- git_buf_join(&path1, '/', clar_sandbox_path(), "readlink_1");
+ git_str_join(&target_path, '/', clar_sandbox_path(), "readlink_final");
+ git_str_join(&path3, '/', clar_sandbox_path(), "readlink_3");
+ git_str_join(&path2, '/', clar_sandbox_path(), "readlink_2");
+ git_str_join(&path1, '/', clar_sandbox_path(), "readlink_1");
- do_symlink(git_buf_cstr(&target_path), git_buf_cstr(&path3), 0);
- do_symlink(git_buf_cstr(&path3), git_buf_cstr(&path2), 0);
- do_symlink(git_buf_cstr(&path2), git_buf_cstr(&path1), 0);
+ do_symlink(git_str_cstr(&target_path), git_str_cstr(&path3), 0);
+ do_symlink(git_str_cstr(&path3), git_str_cstr(&path2), 0);
+ do_symlink(git_str_cstr(&path2), git_str_cstr(&path1), 0);
len = p_readlink("readlink_1", buf, 2048);
cl_must_pass(len);
buf[len] = 0;
- cl_assert_equal_s(git_buf_cstr(&path2), buf);
+ cl_assert_equal_s(git_str_cstr(&path2), buf);
- git_buf_dispose(&path1);
- git_buf_dispose(&path2);
- git_buf_dispose(&path3);
- git_buf_dispose(&target_path);
+ git_str_dispose(&path1);
+ git_str_dispose(&path2);
+ git_str_dispose(&path3);
+ git_str_dispose(&target_path);
}
diff --git a/tests/core/mkdir.c b/tests/core/mkdir.c
index 3f04c2ad3..f0461ac1f 100644
--- a/tests/core/mkdir.c
+++ b/tests/core/mkdir.c
@@ -15,41 +15,41 @@ static void cleanup_basic_dirs(void *ref)
void test_core_mkdir__absolute(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cl_set_cleanup(cleanup_basic_dirs, NULL);
- git_buf_joinpath(&path, clar_sandbox_path(), "d0");
+ git_str_joinpath(&path, clar_sandbox_path(), "d0");
/* make a directory */
cl_assert(!git_path_isdir(path.ptr));
cl_git_pass(git_futils_mkdir(path.ptr, 0755, 0));
cl_assert(git_path_isdir(path.ptr));
- git_buf_joinpath(&path, path.ptr, "subdir");
+ git_str_joinpath(&path, path.ptr, "subdir");
cl_assert(!git_path_isdir(path.ptr));
cl_git_pass(git_futils_mkdir(path.ptr, 0755, 0));
cl_assert(git_path_isdir(path.ptr));
/* ensure mkdir_r works for a single subdir */
- git_buf_joinpath(&path, path.ptr, "another");
+ git_str_joinpath(&path, path.ptr, "another");
cl_assert(!git_path_isdir(path.ptr));
cl_git_pass(git_futils_mkdir_r(path.ptr, 0755));
cl_assert(git_path_isdir(path.ptr));
/* ensure mkdir_r works */
- git_buf_joinpath(&path, clar_sandbox_path(), "d1/foo/bar/asdf");
+ git_str_joinpath(&path, clar_sandbox_path(), "d1/foo/bar/asdf");
cl_assert(!git_path_isdir(path.ptr));
cl_git_pass(git_futils_mkdir_r(path.ptr, 0755));
cl_assert(git_path_isdir(path.ptr));
/* ensure we don't imply recursive */
- git_buf_joinpath(&path, clar_sandbox_path(), "d2/foo/bar/asdf");
+ git_str_joinpath(&path, clar_sandbox_path(), "d2/foo/bar/asdf");
cl_assert(!git_path_isdir(path.ptr));
cl_git_fail(git_futils_mkdir(path.ptr, 0755, 0));
cl_assert(!git_path_isdir(path.ptr));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_core_mkdir__basic(void)
@@ -230,7 +230,7 @@ void test_core_mkdir__chmods(void)
void test_core_mkdir__keeps_parent_symlinks(void)
{
#ifndef GIT_WIN32
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cl_set_cleanup(cleanup_basic_dirs, NULL);
@@ -250,14 +250,14 @@ void test_core_mkdir__keeps_parent_symlinks(void)
cl_must_pass(symlink("d0", "d2"));
cl_assert(git_path_islink("d2"));
- git_buf_joinpath(&path, clar_sandbox_path(), "d2/other/dir");
+ git_str_joinpath(&path, clar_sandbox_path(), "d2/other/dir");
cl_git_pass(git_futils_mkdir(path.ptr, 0755, GIT_MKDIR_PATH|GIT_MKDIR_REMOVE_SYMLINKS));
cl_assert(git_path_islink("d2"));
cl_assert(git_path_isdir("d2/other/dir"));
cl_assert(git_path_isdir("d0/other/dir"));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
#endif
}
diff --git a/tests/core/path.c b/tests/core/path.c
index eac3573fe..6decf23ea 100644
--- a/tests/core/path.c
+++ b/tests/core/path.c
@@ -4,12 +4,12 @@
static void
check_dirname(const char *A, const char *B)
{
- git_buf dir = GIT_BUF_INIT;
+ git_str dir = GIT_STR_INIT;
char *dir2;
cl_assert(git_path_dirname_r(&dir, A) >= 0);
cl_assert_equal_s(B, dir.ptr);
- git_buf_dispose(&dir);
+ git_str_dispose(&dir);
cl_assert((dir2 = git_path_dirname(A)) != NULL);
cl_assert_equal_s(B, dir2);
@@ -19,12 +19,12 @@ check_dirname(const char *A, const char *B)
static void
check_basename(const char *A, const char *B)
{
- git_buf base = GIT_BUF_INIT;
+ git_str base = GIT_STR_INIT;
char *base2;
cl_assert(git_path_basename_r(&base, A) >= 0);
cl_assert_equal_s(B, base.ptr);
- git_buf_dispose(&base);
+ git_str_dispose(&base);
cl_assert((base2 = git_path_basename(A)) != NULL);
cl_assert_equal_s(B, base2);
@@ -34,12 +34,12 @@ check_basename(const char *A, const char *B)
static void
check_joinpath(const char *path_a, const char *path_b, const char *expected_path)
{
- git_buf joined_path = GIT_BUF_INIT;
+ git_str joined_path = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&joined_path, path_a, path_b));
+ cl_git_pass(git_str_joinpath(&joined_path, path_a, path_b));
cl_assert_equal_s(expected_path, joined_path.ptr);
- git_buf_dispose(&joined_path);
+ git_str_dispose(&joined_path);
}
static void
@@ -50,13 +50,13 @@ check_joinpath_n(
const char *path_d,
const char *expected_path)
{
- git_buf joined_path = GIT_BUF_INIT;
+ git_str joined_path = GIT_STR_INIT;
- cl_git_pass(git_buf_join_n(&joined_path, '/', 4,
+ cl_git_pass(git_str_join_n(&joined_path, '/', 4,
path_a, path_b, path_c, path_d));
cl_assert_equal_s(expected_path, joined_path.ptr);
- git_buf_dispose(&joined_path);
+ git_str_dispose(&joined_path);
}
@@ -172,13 +172,13 @@ check_path_to_dir(
const char* path,
const char* expected)
{
- git_buf tgt = GIT_BUF_INIT;
+ git_str tgt = GIT_STR_INIT;
- git_buf_sets(&tgt, path);
+ git_str_sets(&tgt, path);
cl_git_pass(git_path_to_dir(&tgt));
cl_assert_equal_s(expected, tgt.ptr);
- git_buf_dispose(&tgt);
+ git_str_dispose(&tgt);
}
static void
@@ -231,46 +231,46 @@ void test_core_path__07_path_to_dir(void)
/* join path to itself */
void test_core_path__08_self_join(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
size_t asize = 0;
asize = path.asize;
- cl_git_pass(git_buf_sets(&path, "/foo"));
+ cl_git_pass(git_str_sets(&path, "/foo"));
cl_assert_equal_s(path.ptr, "/foo");
cl_assert(asize < path.asize);
asize = path.asize;
- cl_git_pass(git_buf_joinpath(&path, path.ptr, "this is a new string"));
+ cl_git_pass(git_str_joinpath(&path, path.ptr, "this is a new string"));
cl_assert_equal_s(path.ptr, "/foo/this is a new string");
cl_assert(asize < path.asize);
asize = path.asize;
- cl_git_pass(git_buf_joinpath(&path, path.ptr, "/grow the buffer, grow the buffer, grow the buffer"));
+ cl_git_pass(git_str_joinpath(&path, path.ptr, "/grow the buffer, grow the buffer, grow the buffer"));
cl_assert_equal_s(path.ptr, "/foo/this is a new string/grow the buffer, grow the buffer, grow the buffer");
cl_assert(asize < path.asize);
- git_buf_dispose(&path);
- cl_git_pass(git_buf_sets(&path, "/foo/bar"));
+ git_str_dispose(&path);
+ cl_git_pass(git_str_sets(&path, "/foo/bar"));
- cl_git_pass(git_buf_joinpath(&path, path.ptr + 4, "baz"));
+ cl_git_pass(git_str_joinpath(&path, path.ptr + 4, "baz"));
cl_assert_equal_s(path.ptr, "/bar/baz");
asize = path.asize;
- cl_git_pass(git_buf_joinpath(&path, path.ptr + 4, "somethinglongenoughtorealloc"));
+ cl_git_pass(git_str_joinpath(&path, path.ptr + 4, "somethinglongenoughtorealloc"));
cl_assert_equal_s(path.ptr, "/baz/somethinglongenoughtorealloc");
cl_assert(asize < path.asize);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
static void check_percent_decoding(const char *expected_result, const char *input)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
cl_git_pass(git__percent_decode(&buf, input));
- cl_assert_equal_s(expected_result, git_buf_cstr(&buf));
+ cl_assert_equal_s(expected_result, git_str_cstr(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
void test_core_path__09_percent_decode(void)
@@ -289,17 +289,17 @@ void test_core_path__09_percent_decode(void)
static void check_fromurl(const char *expected_result, const char *input, int should_fail)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
assert(should_fail || expected_result);
if (!should_fail) {
cl_git_pass(git_path_fromurl(&buf, input));
- cl_assert_equal_s(expected_result, git_buf_cstr(&buf));
+ cl_assert_equal_s(expected_result, git_str_cstr(&buf));
} else
cl_git_fail(git_path_fromurl(&buf, input));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
#ifdef GIT_WIN32
@@ -353,7 +353,7 @@ static int check_one_walkup_step(void *ref, const char *path)
void test_core_path__11_walkup(void)
{
- git_buf p = GIT_BUF_INIT;
+ git_str p = GIT_STR_INIT;
char *expect[] = {
/* 1 */ "/a/b/c/d/e/", "/a/b/c/d/", "/a/b/c/", "/a/b/", "/a/", "/", NULL,
@@ -398,7 +398,7 @@ void test_core_path__11_walkup(void)
for (i = 0, j = 0; expect[i] != NULL; i++, j++) {
- git_buf_sets(&p, expect[i]);
+ git_str_sets(&p, expect[i]);
info.expect_idx = i;
cl_git_pass(
@@ -410,12 +410,12 @@ void test_core_path__11_walkup(void)
i = info.expect_idx;
}
- git_buf_dispose(&p);
+ git_str_dispose(&p);
}
void test_core_path__11a_walkup_cancel(void)
{
- git_buf p = GIT_BUF_INIT;
+ git_str p = GIT_STR_INIT;
int cancel[] = { 3, 2, 1, 0 };
char *expect[] = {
"/a/b/c/d/e/", "/a/b/c/d/", "/a/b/c/", "[CANCEL]", NULL,
@@ -432,7 +432,7 @@ void test_core_path__11a_walkup_cancel(void)
for (i = 0, j = 0; expect[i] != NULL; i++, j++) {
- git_buf_sets(&p, expect[i]);
+ git_str_sets(&p, expect[i]);
info.cancel_after = cancel[j];
info.expect_idx = i;
@@ -446,7 +446,7 @@ void test_core_path__11a_walkup_cancel(void)
while (expect[i] != NULL) i++;
}
- git_buf_dispose(&p);
+ git_str_dispose(&p);
}
void test_core_path__12_offset_to_path_root(void)
@@ -468,20 +468,20 @@ void test_core_path__12_offset_to_path_root(void)
void test_core_path__13_cannot_prettify_a_non_existing_file(void)
{
- git_buf p = GIT_BUF_INIT;
+ git_str p = GIT_STR_INIT;
cl_assert_equal_b(git_path_exists(NON_EXISTING_FILEPATH), false);
cl_assert_equal_i(GIT_ENOTFOUND, git_path_prettify(&p, NON_EXISTING_FILEPATH, NULL));
cl_assert_equal_i(GIT_ENOTFOUND, git_path_prettify(&p, NON_EXISTING_FILEPATH "/so-do-i", NULL));
- git_buf_dispose(&p);
+ git_str_dispose(&p);
}
void test_core_path__14_apply_relative(void)
{
- git_buf p = GIT_BUF_INIT;
+ git_str p = GIT_STR_INIT;
- cl_git_pass(git_buf_sets(&p, "/this/is/a/base"));
+ cl_git_pass(git_str_sets(&p, "/this/is/a/base"));
cl_git_pass(git_path_apply_relative(&p, "../test"));
cl_assert_equal_s("/this/is/a/test", p.ptr);
@@ -501,7 +501,7 @@ void test_core_path__14_apply_relative(void)
cl_git_fail(git_path_apply_relative(&p, "../../.."));
- cl_git_pass(git_buf_sets(&p, "d:/another/test"));
+ cl_git_pass(git_str_sets(&p, "d:/another/test"));
cl_git_pass(git_path_apply_relative(&p, "../.."));
cl_assert_equal_s("d:/", p.ptr);
@@ -510,7 +510,7 @@ void test_core_path__14_apply_relative(void)
cl_assert_equal_s("d:/from/here/and/back/", p.ptr);
- cl_git_pass(git_buf_sets(&p, "https://my.url.com/test.git"));
+ cl_git_pass(git_str_sets(&p, "https://my.url.com/test.git"));
cl_git_pass(git_path_apply_relative(&p, "../another.git"));
cl_assert_equal_s("https://my.url.com/another.git", p.ptr);
@@ -525,7 +525,7 @@ void test_core_path__14_apply_relative(void)
cl_assert_equal_s("https://", p.ptr);
- cl_git_pass(git_buf_sets(&p, "../../this/is/relative"));
+ cl_git_pass(git_str_sets(&p, "../../this/is/relative"));
cl_git_pass(git_path_apply_relative(&p, "../../preserves/the/prefix"));
cl_assert_equal_s("../../this/preserves/the/prefix", p.ptr);
@@ -535,20 +535,20 @@ void test_core_path__14_apply_relative(void)
cl_git_pass(git_path_apply_relative(&p, "../there"));
cl_assert_equal_s("../../there", p.ptr);
- git_buf_dispose(&p);
+ git_str_dispose(&p);
}
static void assert_resolve_relative(
- git_buf *buf, const char *expected, const char *path)
+ git_str *buf, const char *expected, const char *path)
{
- cl_git_pass(git_buf_sets(buf, path));
+ cl_git_pass(git_str_sets(buf, path));
cl_git_pass(git_path_resolve_relative(buf, 0));
cl_assert_equal_s(expected, buf->ptr);
}
void test_core_path__15_resolve_relative(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
assert_resolve_relative(&buf, "", "");
assert_resolve_relative(&buf, "", ".");
@@ -595,22 +595,22 @@ void test_core_path__15_resolve_relative(void)
assert_resolve_relative(&buf, "../../path", "../../test//../././path");
assert_resolve_relative(&buf, "../d", "a/b/../../../c/../d");
- cl_git_pass(git_buf_sets(&buf, "/.."));
+ cl_git_pass(git_str_sets(&buf, "/.."));
cl_git_fail(git_path_resolve_relative(&buf, 0));
- cl_git_pass(git_buf_sets(&buf, "/./.."));
+ cl_git_pass(git_str_sets(&buf, "/./.."));
cl_git_fail(git_path_resolve_relative(&buf, 0));
- cl_git_pass(git_buf_sets(&buf, "/.//.."));
+ cl_git_pass(git_str_sets(&buf, "/.//.."));
cl_git_fail(git_path_resolve_relative(&buf, 0));
- cl_git_pass(git_buf_sets(&buf, "/../."));
+ cl_git_pass(git_str_sets(&buf, "/../."));
cl_git_fail(git_path_resolve_relative(&buf, 0));
- cl_git_pass(git_buf_sets(&buf, "/../.././../a"));
+ cl_git_pass(git_str_sets(&buf, "/../.././../a"));
cl_git_fail(git_path_resolve_relative(&buf, 0));
- cl_git_pass(git_buf_sets(&buf, "////.."));
+ cl_git_pass(git_str_sets(&buf, "////.."));
cl_git_fail(git_path_resolve_relative(&buf, 0));
/* things that start with Windows network paths */
@@ -619,7 +619,7 @@ void test_core_path__15_resolve_relative(void)
assert_resolve_relative(&buf, "//a/", "//a/b/..");
assert_resolve_relative(&buf, "//a/b/c", "//a/Q/../b/x/y/../../c");
- cl_git_pass(git_buf_sets(&buf, "//a/b/../.."));
+ cl_git_pass(git_str_sets(&buf, "//a/b/../.."));
cl_git_fail(git_path_resolve_relative(&buf, 0));
#else
assert_resolve_relative(&buf, "/a/b/c", "//a/b/c");
@@ -628,7 +628,7 @@ void test_core_path__15_resolve_relative(void)
assert_resolve_relative(&buf, "/", "//a/b/../..");
#endif
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
#define assert_common_dirlen(i, p, q) \
diff --git a/tests/core/posix.c b/tests/core/posix.c
index 1bb1e9c6b..247bd43f5 100644
--- a/tests/core/posix.c
+++ b/tests/core/posix.c
@@ -168,7 +168,7 @@ void test_core_posix__unlink_removes_symlink(void)
void test_core_posix__symlink_resolves_to_correct_type(void)
{
- git_buf contents = GIT_BUF_INIT;
+ git_str contents = GIT_STR_INIT;
if (!git_path_supports_symlinks(clar_sandbox_path()))
clar__skip();
@@ -187,12 +187,12 @@ void test_core_posix__symlink_resolves_to_correct_type(void)
cl_must_pass(p_rmdir("dir"));
cl_must_pass(p_rmdir("file"));
- git_buf_dispose(&contents);
+ git_str_dispose(&contents);
}
void test_core_posix__relative_symlink(void)
{
- git_buf contents = GIT_BUF_INIT;
+ git_str contents = GIT_STR_INIT;
if (!git_path_supports_symlinks(clar_sandbox_path()))
clar__skip();
@@ -207,12 +207,12 @@ void test_core_posix__relative_symlink(void)
cl_must_pass(p_unlink("dir/link"));
cl_must_pass(p_rmdir("dir"));
- git_buf_dispose(&contents);
+ git_str_dispose(&contents);
}
void test_core_posix__symlink_to_file_across_dirs(void)
{
- git_buf contents = GIT_BUF_INIT;
+ git_str contents = GIT_STR_INIT;
if (!git_path_supports_symlinks(clar_sandbox_path()))
clar__skip();
@@ -234,5 +234,5 @@ void test_core_posix__symlink_to_file_across_dirs(void)
cl_must_pass(p_unlink("link"));
cl_must_pass(p_rmdir("dir"));
- git_buf_dispose(&contents);
+ git_str_dispose(&contents);
}
diff --git a/tests/core/rmdir.c b/tests/core/rmdir.c
index b436b97e0..56ea320be 100644
--- a/tests/core/rmdir.c
+++ b/tests/core/rmdir.c
@@ -5,26 +5,26 @@ static const char *empty_tmp_dir = "test_gitfo_rmdir_recurs_test";
void test_core_rmdir__initialize(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cl_must_pass(p_mkdir(empty_tmp_dir, 0777));
- cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/one"));
+ cl_git_pass(git_str_joinpath(&path, empty_tmp_dir, "/one"));
cl_must_pass(p_mkdir(path.ptr, 0777));
- cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/one/two_one"));
+ cl_git_pass(git_str_joinpath(&path, empty_tmp_dir, "/one/two_one"));
cl_must_pass(p_mkdir(path.ptr, 0777));
- cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/one/two_two"));
+ cl_git_pass(git_str_joinpath(&path, empty_tmp_dir, "/one/two_two"));
cl_must_pass(p_mkdir(path.ptr, 0777));
- cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/one/two_two/three"));
+ cl_git_pass(git_str_joinpath(&path, empty_tmp_dir, "/one/two_two/three"));
cl_must_pass(p_mkdir(path.ptr, 0777));
- cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/two"));
+ cl_git_pass(git_str_joinpath(&path, empty_tmp_dir, "/two"));
cl_must_pass(p_mkdir(path.ptr, 0777));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_core_rmdir__cleanup(void)
@@ -36,25 +36,25 @@ void test_core_rmdir__cleanup(void)
/* make sure empty dir can be deleted recusively */
void test_core_rmdir__delete_recursive(void)
{
- git_buf path = GIT_BUF_INIT;
- cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/one"));
- cl_assert(git_path_exists(git_buf_cstr(&path)));
+ git_str path = GIT_STR_INIT;
+ cl_git_pass(git_str_joinpath(&path, empty_tmp_dir, "/one"));
+ cl_assert(git_path_exists(git_str_cstr(&path)));
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY));
- cl_assert(!git_path_exists(git_buf_cstr(&path)));
+ cl_assert(!git_path_exists(git_str_cstr(&path)));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
/* make sure non-empty dir cannot be deleted recusively */
void test_core_rmdir__fail_to_delete_non_empty_dir(void)
{
- git_buf file = GIT_BUF_INIT;
+ git_str file = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&file, empty_tmp_dir, "/two/file.txt"));
+ cl_git_pass(git_str_joinpath(&file, empty_tmp_dir, "/two/file.txt"));
- cl_git_mkfile(git_buf_cstr(&file), "dummy");
+ cl_git_mkfile(git_str_cstr(&file), "dummy");
cl_git_fail(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY));
@@ -63,7 +63,7 @@ void test_core_rmdir__fail_to_delete_non_empty_dir(void)
cl_assert(!git_path_exists(empty_tmp_dir));
- git_buf_dispose(&file);
+ git_str_dispose(&file);
}
void test_core_rmdir__keep_base(void)
@@ -74,47 +74,47 @@ void test_core_rmdir__keep_base(void)
void test_core_rmdir__can_skip_non_empty_dir(void)
{
- git_buf file = GIT_BUF_INIT;
+ git_str file = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&file, empty_tmp_dir, "/two/file.txt"));
+ cl_git_pass(git_str_joinpath(&file, empty_tmp_dir, "/two/file.txt"));
- cl_git_mkfile(git_buf_cstr(&file), "dummy");
+ cl_git_mkfile(git_str_cstr(&file), "dummy");
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_SKIP_NONEMPTY));
- cl_assert(git_path_exists(git_buf_cstr(&file)) == true);
+ cl_assert(git_path_exists(git_str_cstr(&file)) == true);
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_REMOVE_FILES));
cl_assert(git_path_exists(empty_tmp_dir) == false);
- git_buf_dispose(&file);
+ git_str_dispose(&file);
}
void test_core_rmdir__can_remove_empty_parents(void)
{
- git_buf file = GIT_BUF_INIT;
+ git_str file = GIT_STR_INIT;
cl_git_pass(
- git_buf_joinpath(&file, empty_tmp_dir, "/one/two_two/three/file.txt"));
- cl_git_mkfile(git_buf_cstr(&file), "dummy");
- cl_assert(git_path_isfile(git_buf_cstr(&file)));
+ git_str_joinpath(&file, empty_tmp_dir, "/one/two_two/three/file.txt"));
+ cl_git_mkfile(git_str_cstr(&file), "dummy");
+ cl_assert(git_path_isfile(git_str_cstr(&file)));
cl_git_pass(git_futils_rmdir_r("one/two_two/three/file.txt", empty_tmp_dir,
GIT_RMDIR_REMOVE_FILES | GIT_RMDIR_EMPTY_PARENTS));
- cl_assert(!git_path_exists(git_buf_cstr(&file)));
+ cl_assert(!git_path_exists(git_str_cstr(&file)));
- git_buf_rtruncate_at_char(&file, '/'); /* three (only contained file.txt) */
- cl_assert(!git_path_exists(git_buf_cstr(&file)));
+ git_str_rtruncate_at_char(&file, '/'); /* three (only contained file.txt) */
+ cl_assert(!git_path_exists(git_str_cstr(&file)));
- git_buf_rtruncate_at_char(&file, '/'); /* two_two (only contained three) */
- cl_assert(!git_path_exists(git_buf_cstr(&file)));
+ git_str_rtruncate_at_char(&file, '/'); /* two_two (only contained three) */
+ cl_assert(!git_path_exists(git_str_cstr(&file)));
- git_buf_rtruncate_at_char(&file, '/'); /* one (contained two_one also) */
- cl_assert(git_path_exists(git_buf_cstr(&file)));
+ git_str_rtruncate_at_char(&file, '/'); /* one (contained two_one also) */
+ cl_assert(git_path_exists(git_str_cstr(&file)));
cl_assert(git_path_exists(empty_tmp_dir) == true);
- git_buf_dispose(&file);
+ git_str_dispose(&file);
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY));
}
diff --git a/tests/core/sortedcache.c b/tests/core/sortedcache.c
index d5bbcea19..cb4e34efa 100644
--- a/tests/core/sortedcache.c
+++ b/tests/core/sortedcache.c
@@ -241,7 +241,7 @@ void test_core_sortedcache__in_memory(void)
static void sortedcache_test_reload(git_sortedcache *sc)
{
int count = 0;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
char *scan, *after;
sortedcache_test_struct *item;
@@ -266,7 +266,7 @@ static void sortedcache_test_reload(git_sortedcache *sc)
git_sortedcache_wunlock(sc);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
void test_core_sortedcache__on_disk(void)
diff --git a/tests/core/stat.c b/tests/core/stat.c
index 7f5d66753..56d141e98 100644
--- a/tests/core/stat.c
+++ b/tests/core/stat.c
@@ -98,17 +98,17 @@ void test_core_stat__0(void)
void test_core_stat__root(void)
{
const char *sandbox = clar_sandbox_path();
- git_buf root = GIT_BUF_INIT;
+ git_str root = GIT_STR_INIT;
int root_len;
struct stat st;
root_len = git_path_root(sandbox);
cl_assert(root_len >= 0);
- git_buf_set(&root, sandbox, root_len+1);
+ git_str_set(&root, sandbox, root_len+1);
cl_must_pass(p_stat(root.ptr, &st));
cl_assert(S_ISDIR(st.st_mode));
- git_buf_dispose(&root);
+ git_str_dispose(&root);
}
diff --git a/tests/core/useragent.c b/tests/core/useragent.c
index 2ce935bf5..a4ece902f 100644
--- a/tests/core/useragent.c
+++ b/tests/core/useragent.c
@@ -4,7 +4,7 @@
void test_core_useragent__get(void)
{
const char *custom_name = "super duper git";
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
cl_assert_equal_p(NULL, git_libgit2__user_agent());
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_USER_AGENT, custom_name));
@@ -13,5 +13,5 @@ void test_core_useragent__get(void)
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_USER_AGENT, &buf));
cl_assert_equal_s(custom_name, buf.ptr);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
diff --git a/tests/core/zstream.c b/tests/core/zstream.c
index 3cbcea168..c22e81008 100644
--- a/tests/core/zstream.c
+++ b/tests/core/zstream.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "zstream.h"
static const char *data = "This is a test test test of This is a test";
@@ -60,7 +59,7 @@ void test_core_zstream__basic(void)
void test_core_zstream__fails_on_trailing_garbage(void)
{
- git_buf deflated = GIT_BUF_INIT, inflated = GIT_BUF_INIT;
+ git_str deflated = GIT_STR_INIT, inflated = GIT_STR_INIT;
char i = 0;
/* compress a simple string */
@@ -68,29 +67,29 @@ void test_core_zstream__fails_on_trailing_garbage(void)
/* append some garbage */
for (i = 0; i < 10; i++) {
- git_buf_putc(&deflated, i);
+ git_str_putc(&deflated, i);
}
cl_git_fail(git_zstream_inflatebuf(&inflated, deflated.ptr, deflated.size));
- git_buf_dispose(&deflated);
- git_buf_dispose(&inflated);
+ git_str_dispose(&deflated);
+ git_str_dispose(&inflated);
}
void test_core_zstream__buffer(void)
{
- git_buf out = GIT_BUF_INIT;
+ git_str out = GIT_STR_INIT;
cl_git_pass(git_zstream_deflatebuf(&out, data, strlen(data) + 1));
assert_zlib_equal(data, strlen(data) + 1, out.ptr, out.size);
- git_buf_dispose(&out);
+ git_str_dispose(&out);
}
#define BIG_STRING_PART "Big Data IS Big - Long Data IS Long - We need a buffer larger than 1024 x 1024 to make sure we trigger chunked compression - Big Big Data IS Bigger than Big - Long Long Data IS Longer than Long"
-static void compress_and_decompress_input_various_ways(git_buf *input)
+static void compress_and_decompress_input_various_ways(git_str *input)
{
- git_buf out1 = GIT_BUF_INIT, out2 = GIT_BUF_INIT;
- git_buf inflated = GIT_BUF_INIT;
+ git_str out1 = GIT_STR_INIT, out2 = GIT_STR_INIT;
+ git_str inflated = GIT_STR_INIT;
size_t i, fixed_size = max(input->size / 2, 256);
char *fixed = git__malloc(fixed_size);
cl_assert(fixed);
@@ -119,7 +118,7 @@ static void compress_and_decompress_input_various_ways(git_buf *input)
while (!git_zstream_done(&zs)) {
size_t written = use_fixed_size;
cl_git_pass(git_zstream_get_output(fixed, &written, &zs));
- cl_git_pass(git_buf_put(&out2, fixed, written));
+ cl_git_pass(git_str_put(&out2, fixed, written));
}
git_zstream_free(&zs);
@@ -129,30 +128,30 @@ static void compress_and_decompress_input_various_ways(git_buf *input)
cl_assert_equal_sz(out1.size, out2.size);
cl_assert(!memcmp(out1.ptr, out2.ptr, out1.size));
- git_buf_dispose(&out2);
+ git_str_dispose(&out2);
}
cl_git_pass(git_zstream_inflatebuf(&inflated, out1.ptr, out1.size));
cl_assert_equal_i(input->size, inflated.size);
cl_assert(memcmp(input->ptr, inflated.ptr, inflated.size) == 0);
- git_buf_dispose(&out1);
- git_buf_dispose(&inflated);
+ git_str_dispose(&out1);
+ git_str_dispose(&inflated);
git__free(fixed);
}
void test_core_zstream__big_data(void)
{
- git_buf in = GIT_BUF_INIT;
+ git_str in = GIT_STR_INIT;
size_t scan, target;
for (target = 1024; target <= 1024 * 1024 * 4; target *= 8) {
/* make a big string that's easy to compress */
- git_buf_clear(&in);
+ git_str_clear(&in);
while (in.size < target)
cl_git_pass(
- git_buf_put(&in, BIG_STRING_PART, strlen(BIG_STRING_PART)));
+ git_str_put(&in, BIG_STRING_PART, strlen(BIG_STRING_PART)));
compress_and_decompress_input_various_ways(&in);
@@ -164,5 +163,5 @@ void test_core_zstream__big_data(void)
compress_and_decompress_input_various_ways(&in);
}
- git_buf_dispose(&in);
+ git_str_dispose(&in);
}
diff --git a/tests/describe/describe.c b/tests/describe/describe.c
index 26ca4efd8..ba67ca46b 100644
--- a/tests/describe/describe.c
+++ b/tests/describe/describe.c
@@ -32,7 +32,7 @@ void test_describe_describe__describe_a_repo_with_no_refs(void)
{
git_repository *repo;
git_describe_options opts = GIT_DESCRIBE_OPTIONS_INIT;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
git_object *object;
git_describe_result *result = NULL;
@@ -50,6 +50,6 @@ void test_describe_describe__describe_a_repo_with_no_refs(void)
git_describe_result_free(result);
git_object_free(object);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
cl_git_sandbox_cleanup();
}
diff --git a/tests/describe/describe_helpers.c b/tests/describe/describe_helpers.c
index 80217dcf0..3df3b7c59 100644
--- a/tests/describe/describe_helpers.c
+++ b/tests/describe/describe_helpers.c
@@ -18,7 +18,7 @@ void assert_describe(
cl_git_pass(git_describe_commit(&result, object, opts));
cl_git_pass(git_describe_format(&label, result, fmt_opts));
- cl_must_pass(wildmatch(expected_output, git_buf_cstr(&label), 0));
+ cl_must_pass(wildmatch(expected_output, label.ptr, 0));
git_describe_result_free(result);
git_object_free(object);
@@ -37,7 +37,7 @@ void assert_describe_workdir(
cl_git_pass(git_describe_workdir(&result, repo, opts));
cl_git_pass(git_describe_format(&label, result, fmt_opts));
- cl_must_pass(wildmatch(expected_output, git_buf_cstr(&label), 0));
+ cl_must_pass(wildmatch(expected_output, label.ptr, 0));
git_describe_result_free(result);
git_buf_dispose(&label);
diff --git a/tests/describe/describe_helpers.h b/tests/describe/describe_helpers.h
index 16a0638e3..43e8c5e19 100644
--- a/tests/describe/describe_helpers.h
+++ b/tests/describe/describe_helpers.h
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
extern void assert_describe(
const char *expected_output,
diff --git a/tests/diff/binary.c b/tests/diff/binary.c
index 7edf37b51..24d2b22ef 100644
--- a/tests/diff/binary.c
+++ b/tests/diff/binary.c
@@ -2,7 +2,6 @@
#include "git2/sys/diff.h"
-#include "buffer.h"
#include "delta.h"
#include "filebuf.h"
#include "repository.h"
@@ -53,7 +52,7 @@ void test_patch(
cl_assert_equal_s(expected, actual.ptr);
- git_buf_clear(&actual);
+ git_buf_dispose(&actual);
cl_git_pass(git_diff_print(diff, GIT_DIFF_FORMAT_PATCH, git_diff_print_callback__to_buf, &actual));
cl_assert_equal_s(expected, actual.ptr);
@@ -197,7 +196,7 @@ void test_diff_binary__delete(void)
void test_diff_binary__delta(void)
{
git_index *index;
- git_buf contents = GIT_BUF_INIT;
+ git_str contents = GIT_STR_INIT;
size_t i;
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
const char *expected =
@@ -239,7 +238,7 @@ void test_diff_binary__delta(void)
expected);
git_index_free(index);
- git_buf_dispose(&contents);
+ git_str_dispose(&contents);
}
void test_diff_binary__delta_append(void)
@@ -283,7 +282,7 @@ void test_diff_binary__empty_for_no_diff(void)
git_commit *commit;
git_tree *tree;
git_diff *diff;
- git_buf actual = GIT_BUF_INIT;
+ git_str actual = GIT_STR_INIT;
opts.flags = GIT_DIFF_SHOW_BINARY | GIT_DIFF_FORCE_BINARY;
opts.id_abbrev = GIT_OID_HEXSZ;
@@ -299,7 +298,7 @@ void test_diff_binary__empty_for_no_diff(void)
cl_assert_equal_s("", actual.ptr);
- git_buf_dispose(&actual);
+ git_str_dispose(&actual);
git_diff_free(diff);
git_commit_free(commit);
git_tree_free(tree);
@@ -359,24 +358,24 @@ static int print_cb(
const git_diff_line *line,
void *payload)
{
- git_buf *buf = (git_buf *)payload;
+ git_str *buf = (git_str *)payload;
GIT_UNUSED(delta);
if (hunk)
- git_buf_put(buf, hunk->header, hunk->header_len);
+ git_str_put(buf, hunk->header, hunk->header_len);
if (line)
- git_buf_put(buf, line->content, line->content_len);
+ git_str_put(buf, line->content, line->content_len);
- return git_buf_oom(buf) ? -1 : 0;
+ return git_str_oom(buf) ? -1 : 0;
}
void test_diff_binary__print_patch_from_diff(void)
{
git_index *index;
git_diff *diff;
- git_buf actual = GIT_BUF_INIT;
+ git_str actual = GIT_STR_INIT;
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
const char *expected =
"diff --git a/untimely.txt b/untimely.txt\n" \
@@ -403,7 +402,7 @@ void test_diff_binary__print_patch_from_diff(void)
cl_assert_equal_s(expected, actual.ptr);
- git_buf_dispose(&actual);
+ git_str_dispose(&actual);
git_diff_free(diff);
git_index_free(index);
}
@@ -411,13 +410,13 @@ void test_diff_binary__print_patch_from_diff(void)
struct diff_data {
char *old_path;
git_oid old_id;
- git_buf old_binary_base85;
+ git_str old_binary_base85;
size_t old_binary_inflatedlen;
git_diff_binary_t old_binary_type;
char *new_path;
git_oid new_id;
- git_buf new_binary_base85;
+ git_str new_binary_base85;
size_t new_binary_inflatedlen;
git_diff_binary_t new_binary_type;
};
@@ -452,12 +451,12 @@ static int binary_cb(
GIT_UNUSED(delta);
- git_buf_encode_base85(&diff_data->old_binary_base85,
+ git_str_encode_base85(&diff_data->old_binary_base85,
binary->old_file.data, binary->old_file.datalen);
diff_data->old_binary_inflatedlen = binary->old_file.inflatedlen;
diff_data->old_binary_type = binary->old_file.type;
- git_buf_encode_base85(&diff_data->new_binary_base85,
+ git_str_encode_base85(&diff_data->new_binary_base85,
binary->new_file.data, binary->new_file.datalen);
diff_data->new_binary_inflatedlen = binary->new_file.inflatedlen;
diff_data->new_binary_type = binary->new_file.type;
@@ -541,6 +540,6 @@ void test_diff_binary__blob_to_blob(void)
git__free(diff_data.old_path);
git__free(diff_data.new_path);
- git_buf_dispose(&diff_data.old_binary_base85);
- git_buf_dispose(&diff_data.new_binary_base85);
+ git_str_dispose(&diff_data.old_binary_base85);
+ git_str_dispose(&diff_data.new_binary_base85);
}
diff --git a/tests/diff/blob.c b/tests/diff/blob.c
index 50edf6bc0..9f71e4ea6 100644
--- a/tests/diff/blob.c
+++ b/tests/diff/blob.c
@@ -915,7 +915,7 @@ void test_diff_blob__using_path_and_attributes(void)
"+More lines\n"
"+And more\n"
"+Go here\n", buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
git_patch_free(p);
cl_git_pass(git_patch_from_blob_and_buffer(
@@ -925,7 +925,7 @@ void test_diff_blob__using_path_and_attributes(void)
"diff --git a/zzz.binary b/zzz.binary\n"
"index 45141a7..75b0dbb 100644\n"
"Binary files a/zzz.binary and b/zzz.binary differ\n", buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
git_patch_free(p);
cl_git_pass(git_patch_from_blob_and_buffer(
@@ -940,7 +940,7 @@ void test_diff_blob__using_path_and_attributes(void)
"+More lines\n"
"+And more\n"
"+Go here\n", buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
git_patch_free(p);
cl_git_pass(git_patch_from_blob_and_buffer(
@@ -955,7 +955,7 @@ void test_diff_blob__using_path_and_attributes(void)
"+More lines\n"
"+And more\n"
"+Go here\n", buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
git_patch_free(p);
/* "0123456789\n\x01\x02\x03\x04\x05\x06\x07\x08\x09\x00\n0123456789\n"
@@ -971,7 +971,7 @@ void test_diff_blob__using_path_and_attributes(void)
"diff --git a/zzz.normal b/zzz.normal\n"
"index b435cd5..1604519 100644\n"
"Binary files a/zzz.normal and b/zzz.normal differ\n", buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
git_patch_free(p);
cl_git_pass(git_patch_from_blob_and_buffer(
@@ -985,7 +985,7 @@ void test_diff_blob__using_path_and_attributes(void)
"@@ -3 +3 @@\n"
"-0123456789\n"
"+replace a line\n", buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
git_patch_free(p);
cl_git_pass(git_patch_from_blob_and_buffer(
@@ -999,7 +999,7 @@ void test_diff_blob__using_path_and_attributes(void)
"@@ -3 +3 @@\n"
"-0123456789\n"
"+replace a line\n", buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
git_patch_free(p);
cl_git_pass(git_patch_from_blob_and_buffer(
@@ -1013,7 +1013,7 @@ void test_diff_blob__using_path_and_attributes(void)
"@@ -3 +3 @@ 0123456789\n"
"-0123456789\n"
"+replace a line\n", buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
git_patch_free(p);
git_buf_dispose(&buf);
diff --git a/tests/diff/drivers.c b/tests/diff/drivers.c
index cace40967..ce24e9bc0 100644
--- a/tests/diff/drivers.c
+++ b/tests/diff/drivers.c
@@ -178,7 +178,8 @@ void test_diff_drivers__builtins(void)
{
git_diff *diff;
git_patch *patch;
- git_buf file = GIT_BUF_INIT, actual = GIT_BUF_INIT, expected = GIT_BUF_INIT;
+ git_str file = GIT_STR_INIT, expected = GIT_STR_INIT;
+ git_buf actual = GIT_BUF_INIT;
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
git_vector files = GIT_VECTOR_INIT;
size_t i;
@@ -205,15 +206,15 @@ void test_diff_drivers__builtins(void)
cl_git_pass(git_patch_from_diff(&patch, diff, 0));
cl_git_pass(git_patch_to_buf(&actual, patch));
- git_buf_sets(&expected, "userdiff/expected/nodriver/diff.");
- git_buf_puts(&expected, extension);
+ git_str_sets(&expected, "userdiff/expected/nodriver/diff.");
+ git_str_puts(&expected, extension);
cl_git_pass(git_futils_readbuffer(&expected, expected.ptr));
overwrite_filemode(expected.ptr, &actual);
cl_assert_equal_s(expected.ptr, actual.ptr);
- git_buf_clear(&actual);
+ git_buf_dispose(&actual);
git_patch_free(patch);
git_diff_free(diff);
@@ -230,24 +231,24 @@ void test_diff_drivers__builtins(void)
cl_git_pass(git_patch_from_diff(&patch, diff, 0));
cl_git_pass(git_patch_to_buf(&actual, patch));
- git_buf_sets(&expected, "userdiff/expected/driver/diff.");
- git_buf_puts(&expected, extension);
+ git_str_sets(&expected, "userdiff/expected/driver/diff.");
+ git_str_puts(&expected, extension);
cl_git_pass(git_futils_readbuffer(&expected, expected.ptr));
overwrite_filemode(expected.ptr, &actual);
cl_assert_equal_s(expected.ptr, actual.ptr);
- git_buf_clear(&actual);
+ git_buf_dispose(&actual);
git_patch_free(patch);
git_diff_free(diff);
git__free(path);
}
- git_buf_dispose(&file);
git_buf_dispose(&actual);
- git_buf_dispose(&expected);
+ git_str_dispose(&file);
+ git_str_dispose(&expected);
git_vector_free(&files);
}
diff --git a/tests/diff/format_email.c b/tests/diff/format_email.c
index ea7aa070f..612804c42 100644
--- a/tests/diff/format_email.c
+++ b/tests/diff/format_email.c
@@ -1,7 +1,6 @@
#include "clar.h"
#include "clar_libgit2.h"
-#include "buffer.h"
#include "commit.h"
#include "diff.h"
#include "diff_generate.h"
@@ -41,12 +40,12 @@ static void assert_email_match(
cl_git_pass(git_diff__commit(&diff, repo, commit, NULL));
cl_git_pass(git_diff_format_email(&buf, diff, opts));
- cl_assert_equal_s(expected, git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s(expected, buf.ptr);
+ git_buf_dispose(&buf);
cl_git_pass(git_diff_commit_as_email(
&buf, repo, commit, 1, 1, opts->flags, NULL));
- cl_assert_equal_s(expected, git_buf_cstr(&buf));
+ cl_assert_equal_s(expected, buf.ptr);
git_diff_free(diff);
git_commit_free(commit);
@@ -258,7 +257,7 @@ void test_diff_format_email__multiple(void)
cl_git_pass(git_diff__commit(&diff, repo, commit, NULL));
cl_git_pass(git_diff_format_email(&buf, diff, &opts));
- cl_assert_equal_s(email, git_buf_cstr(&buf));
+ cl_assert_equal_s(email, buf.ptr);
git_diff_free(diff);
git_commit_free(commit);
diff --git a/tests/diff/parse.c b/tests/diff/parse.c
index 6b6e6645e..d3a0c8de6 100644
--- a/tests/diff/parse.c
+++ b/tests/diff/parse.c
@@ -39,21 +39,21 @@ void test_diff_parse__nonpatches_fail_with_notfound(void)
static void test_parse_invalid_diff(const char *invalid_diff)
{
git_diff *diff;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
/* throw some random (legitimate) diffs in with the given invalid
* one.
*/
- git_buf_puts(&buf, PATCH_ORIGINAL_TO_CHANGE_FIRSTLINE);
- git_buf_puts(&buf, PATCH_BINARY_DELTA);
- git_buf_puts(&buf, invalid_diff);
- git_buf_puts(&buf, PATCH_ORIGINAL_TO_CHANGE_MIDDLE);
- git_buf_puts(&buf, PATCH_BINARY_LITERAL);
+ git_str_puts(&buf, PATCH_ORIGINAL_TO_CHANGE_FIRSTLINE);
+ git_str_puts(&buf, PATCH_BINARY_DELTA);
+ git_str_puts(&buf, invalid_diff);
+ git_str_puts(&buf, PATCH_ORIGINAL_TO_CHANGE_MIDDLE);
+ git_str_puts(&buf, PATCH_BINARY_LITERAL);
cl_git_fail_with(GIT_ERROR,
git_diff_from_buffer(&diff, buf.ptr, buf.size));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
void test_diff_parse__exact_rename(void)
diff --git a/tests/diff/patch.c b/tests/diff/patch.c
index d288bba58..8945afc26 100644
--- a/tests/diff/patch.c
+++ b/tests/diff/patch.c
@@ -208,7 +208,7 @@ void test_diff_patch__config_options(void)
cl_git_pass(git_patch_to_buf(&buf, patch));
cl_assert_equal_s(expected1, buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
git_patch_free(patch);
git_diff_free(diff);
@@ -219,7 +219,7 @@ void test_diff_patch__config_options(void)
cl_git_pass(git_patch_to_buf(&buf, patch));
cl_assert_equal_s(expected2, buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
git_patch_free(patch);
git_diff_free(diff);
@@ -233,7 +233,7 @@ void test_diff_patch__config_options(void)
cl_git_pass(git_patch_to_buf(&buf, patch));
cl_assert_equal_s(expected3, buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
git_patch_free(patch);
git_diff_free(diff);
@@ -247,7 +247,7 @@ void test_diff_patch__config_options(void)
cl_git_pass(git_patch_to_buf(&buf, patch));
cl_assert_equal_s(expected4, buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
git_patch_free(patch);
git_diff_free(diff);
@@ -267,7 +267,7 @@ void test_diff_patch__hunks_have_correct_line_numbers(void)
const git_diff_hunk *hunk;
const git_diff_line *line;
size_t hunklen;
- git_buf old_content = GIT_BUF_INIT, actual = GIT_BUF_INIT;
+ git_str old_content = GIT_STR_INIT, actual = GIT_STR_INIT;
const char *new_content = "The Song of Seven Cities\n------------------------\n\nI WAS Lord of Cities very sumptuously builded.\nSeven roaring Cities paid me tribute from afar.\nIvory their outposts were--the guardrooms of them gilded,\nAnd garrisoned with Amazons invincible in war.\n\nThis is some new text;\nNot as good as the old text;\nBut here it is.\n\nSo they warred and trafficked only yesterday, my Cities.\nTo-day there is no mark or mound of where my Cities stood.\nFor the River rose at midnight and it washed away my Cities.\nThey are evened with Atlantis and the towns before the Flood.\n\nRain on rain-gorged channels raised the water-levels round them,\nFreshet backed on freshet swelled and swept their world from sight,\nTill the emboldened floods linked arms and, flashing forward, drowned them--\nDrowned my Seven Cities and their peoples in one night!\n\nLow among the alders lie their derelict foundations,\nThe beams wherein they trusted and the plinths whereon they built--\nMy rulers and their treasure and their unborn populations,\nDead, destroyed, aborted, and defiled with mud and silt!\n\nAnother replacement;\nBreaking up the poem;\nGenerating some hunks.\n\nTo the sound of trumpets shall their seed restore my Cities\nWealthy and well-weaponed, that once more may I behold\nAll the world go softly when it walks before my Cities,\nAnd the horses and the chariots fleeing from them as of old!\n\n -- Rudyard Kipling\n";
g_repo = cl_git_sandbox_init("renames");
@@ -311,7 +311,7 @@ void test_diff_patch__hunks_have_correct_line_numbers(void)
cl_git_pass(git_patch_get_line_in_hunk(&line, patch, 0, 0));
cl_assert_equal_i(GIT_DIFF_LINE_CONTEXT, (int)line->origin);
- cl_git_pass(git_buf_set(&actual, line->content, line->content_len));
+ cl_git_pass(git_str_set(&actual, line->content, line->content_len));
cl_assert_equal_s("Ivory their outposts were--the guardrooms of them gilded,\n", actual.ptr);
cl_assert_equal_i(6, line->old_lineno);
cl_assert_equal_i(6, line->new_lineno);
@@ -319,7 +319,7 @@ void test_diff_patch__hunks_have_correct_line_numbers(void)
cl_git_pass(git_patch_get_line_in_hunk(&line, patch, 0, 3));
cl_assert_equal_i(GIT_DIFF_LINE_DELETION, (int)line->origin);
- cl_git_pass(git_buf_set(&actual, line->content, line->content_len));
+ cl_git_pass(git_str_set(&actual, line->content, line->content_len));
cl_assert_equal_s("All the world went softly when it walked before my Cities--\n", actual.ptr);
cl_assert_equal_i(9, line->old_lineno);
cl_assert_equal_i(-1, line->new_lineno);
@@ -327,7 +327,7 @@ void test_diff_patch__hunks_have_correct_line_numbers(void)
cl_git_pass(git_patch_get_line_in_hunk(&line, patch, 0, 12));
cl_assert_equal_i(GIT_DIFF_LINE_ADDITION, (int)line->origin);
- cl_git_pass(git_buf_set(&actual, line->content, line->content_len));
+ cl_git_pass(git_str_set(&actual, line->content, line->content_len));
cl_assert_equal_s("This is some new text;\n", actual.ptr);
cl_assert_equal_i(-1, line->old_lineno);
cl_assert_equal_i(9, line->new_lineno);
@@ -348,7 +348,7 @@ void test_diff_patch__hunks_have_correct_line_numbers(void)
cl_git_pass(git_patch_get_line_in_hunk(&line, patch, 1, 0));
cl_assert_equal_i(GIT_DIFF_LINE_CONTEXT, (int)line->origin);
- cl_git_pass(git_buf_set(&actual, line->content, line->content_len));
+ cl_git_pass(git_str_set(&actual, line->content, line->content_len));
cl_assert_equal_s("My rulers and their treasure and their unborn populations,\n", actual.ptr);
cl_assert_equal_i(31, line->old_lineno);
cl_assert_equal_i(25, line->new_lineno);
@@ -356,7 +356,7 @@ void test_diff_patch__hunks_have_correct_line_numbers(void)
cl_git_pass(git_patch_get_line_in_hunk(&line, patch, 1, 3));
cl_assert_equal_i(GIT_DIFF_LINE_DELETION, (int)line->origin);
- cl_git_pass(git_buf_set(&actual, line->content, line->content_len));
+ cl_git_pass(git_str_set(&actual, line->content, line->content_len));
cl_assert_equal_s("The Daughters of the Palace whom they cherished in my Cities,\n", actual.ptr);
cl_assert_equal_i(34, line->old_lineno);
cl_assert_equal_i(-1, line->new_lineno);
@@ -364,7 +364,7 @@ void test_diff_patch__hunks_have_correct_line_numbers(void)
cl_git_pass(git_patch_get_line_in_hunk(&line, patch, 1, 12));
cl_assert_equal_i(GIT_DIFF_LINE_ADDITION, (int)line->origin);
- cl_git_pass(git_buf_set(&actual, line->content, line->content_len));
+ cl_git_pass(git_str_set(&actual, line->content, line->content_len));
cl_assert_equal_s("Another replacement;\n", actual.ptr);
cl_assert_equal_i(-1, line->old_lineno);
cl_assert_equal_i(28, line->new_lineno);
@@ -375,7 +375,7 @@ void test_diff_patch__hunks_have_correct_line_numbers(void)
/* Let's check line numbers when there is no newline */
- git_buf_rtrim(&old_content);
+ git_str_rtrim(&old_content);
cl_git_rewritefile("renames/songof7cities.txt", old_content.ptr);
cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, head, &opt));
@@ -403,35 +403,35 @@ void test_diff_patch__hunks_have_correct_line_numbers(void)
cl_git_pass(git_patch_get_line_in_hunk(&line, patch, 0, 1));
cl_assert_equal_i(GIT_DIFF_LINE_CONTEXT, (int)line->origin);
- cl_git_pass(git_buf_set(&actual, line->content, line->content_len));
+ cl_git_pass(git_str_set(&actual, line->content, line->content_len));
cl_assert_equal_s("And the horses and the chariots fleeing from them as of old!\n", actual.ptr);
cl_assert_equal_i(47, line->old_lineno);
cl_assert_equal_i(47, line->new_lineno);
cl_git_pass(git_patch_get_line_in_hunk(&line, patch, 0, 2));
cl_assert_equal_i(GIT_DIFF_LINE_CONTEXT, (int)line->origin);
- cl_git_pass(git_buf_set(&actual, line->content, line->content_len));
+ cl_git_pass(git_str_set(&actual, line->content, line->content_len));
cl_assert_equal_s("\n", actual.ptr);
cl_assert_equal_i(48, line->old_lineno);
cl_assert_equal_i(48, line->new_lineno);
cl_git_pass(git_patch_get_line_in_hunk(&line, patch, 0, 3));
cl_assert_equal_i(GIT_DIFF_LINE_DELETION, (int)line->origin);
- cl_git_pass(git_buf_set(&actual, line->content, line->content_len));
+ cl_git_pass(git_str_set(&actual, line->content, line->content_len));
cl_assert_equal_s(" -- Rudyard Kipling\n", actual.ptr);
cl_assert_equal_i(49, line->old_lineno);
cl_assert_equal_i(-1, line->new_lineno);
cl_git_pass(git_patch_get_line_in_hunk(&line, patch, 0, 4));
cl_assert_equal_i(GIT_DIFF_LINE_ADDITION, (int)line->origin);
- cl_git_pass(git_buf_set(&actual, line->content, line->content_len));
+ cl_git_pass(git_str_set(&actual, line->content, line->content_len));
cl_assert_equal_s(" -- Rudyard Kipling", actual.ptr);
cl_assert_equal_i(-1, line->old_lineno);
cl_assert_equal_i(49, line->new_lineno);
cl_git_pass(git_patch_get_line_in_hunk(&line, patch, 0, 5));
cl_assert_equal_i(GIT_DIFF_LINE_DEL_EOFNL, (int)line->origin);
- cl_git_pass(git_buf_set(&actual, line->content, line->content_len));
+ cl_git_pass(git_str_set(&actual, line->content, line->content_len));
cl_assert_equal_s("\n\\ No newline at end of file\n", actual.ptr);
cl_assert_equal_i(-1, line->old_lineno);
cl_assert_equal_i(49, line->new_lineno);
@@ -439,8 +439,8 @@ void test_diff_patch__hunks_have_correct_line_numbers(void)
git_patch_free(patch);
git_diff_free(diff);
- git_buf_dispose(&actual);
- git_buf_dispose(&old_content);
+ git_str_dispose(&actual);
+ git_str_dispose(&old_content);
git_tree_free(head);
}
@@ -532,7 +532,7 @@ static void check_single_patch_stats(
void test_diff_patch__line_counts_with_eofnl(void)
{
git_config *cfg;
- git_buf content = GIT_BUF_INIT;
+ git_str content = GIT_STR_INIT;
const char *end;
git_index *index;
const char *expected =
@@ -565,15 +565,15 @@ void test_diff_patch__line_counts_with_eofnl(void)
/* remove first line */
- end = git_buf_cstr(&content) + git_buf_find(&content, '\n') + 1;
- git_buf_consume(&content, end);
+ end = git_str_cstr(&content) + git_str_find(&content, '\n') + 1;
+ git_str_consume(&content, end);
cl_git_rewritefile("renames/songof7cities.txt", content.ptr);
check_single_patch_stats(g_repo, 1, 0, 1, 3, NULL, NULL);
/* remove trailing whitespace */
- git_buf_rtrim(&content);
+ git_str_rtrim(&content);
cl_git_rewritefile("renames/songof7cities.txt", content.ptr);
check_single_patch_stats(g_repo, 2, 1, 2, 6, NULL, NULL);
@@ -585,7 +585,7 @@ void test_diff_patch__line_counts_with_eofnl(void)
cl_git_pass(git_index_write(index));
git_index_free(index);
- cl_git_pass(git_buf_putc(&content, '\n'));
+ cl_git_pass(git_str_putc(&content, '\n'));
cl_git_rewritefile("renames/songof7cities.txt", content.ptr);
check_single_patch_stats(g_repo, 1, 1, 1, 3, NULL, NULL);
@@ -613,7 +613,7 @@ void test_diff_patch__line_counts_with_eofnl(void)
check_single_patch_stats(
g_repo, 1, 1, 1, 6, expected_sizes, expected);
- git_buf_dispose(&content);
+ git_str_dispose(&content);
}
void test_diff_patch__can_strip_bad_utf8(void)
diff --git a/tests/diff/rename.c b/tests/diff/rename.c
index bd25d29aa..d28a4d989 100644
--- a/tests/diff/rename.c
+++ b/tests/diff/rename.c
@@ -460,7 +460,7 @@ void test_diff_rename__working_directory_changes(void)
git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT;
git_diff_find_options opts = GIT_DIFF_FIND_OPTIONS_INIT;
diff_expects exp;
- git_buf old_content = GIT_BUF_INIT, content = GIT_BUF_INIT;;
+ git_str old_content = GIT_STR_INIT, content = GIT_STR_INIT;;
tree = resolve_commit_oid_to_tree(g_repo, sha0);
diffopts.flags |= GIT_DIFF_INCLUDE_UNMODIFIED | GIT_DIFF_INCLUDE_UNTRACKED;
@@ -514,7 +514,7 @@ void test_diff_rename__working_directory_changes(void)
cl_git_pass(
git_futils_readbuffer(&old_content, "renames/songof7cities.txt"));
cl_git_pass(
- git_buf_lf_to_crlf(&content, &old_content));
+ git_str_lf_to_crlf(&content, &old_content));
cl_git_pass(
git_futils_writebuffer(&content, "renames/songof7cities.txt", 0, 0));
@@ -576,7 +576,7 @@ void test_diff_rename__working_directory_changes(void)
cl_git_pass(git_oid_fromstr(&id, blobsha));
cl_git_pass(git_blob_lookup(&blob, g_repo, &id));
- cl_git_pass(git_buf_set(
+ cl_git_pass(git_str_set(
&content, git_blob_rawcontent(blob), (size_t)git_blob_rawsize(blob)));
cl_git_rewritefile("renames/songof7cities.txt", content.ptr);
git_blob_free(blob);
@@ -604,8 +604,8 @@ void test_diff_rename__working_directory_changes(void)
git_diff_free(diff);
git_tree_free(tree);
- git_buf_dispose(&content);
- git_buf_dispose(&old_content);
+ git_str_dispose(&content);
+ git_str_dispose(&old_content);
}
void test_diff_rename__patch(void)
@@ -666,7 +666,7 @@ void test_diff_rename__patch(void)
void test_diff_rename__file_exchange(void)
{
- git_buf c1 = GIT_BUF_INIT, c2 = GIT_BUF_INIT;
+ git_str c1 = GIT_STR_INIT, c2 = GIT_STR_INIT;
git_index *index;
git_tree *tree;
git_diff *diff;
@@ -708,13 +708,13 @@ void test_diff_rename__file_exchange(void)
git_tree_free(tree);
git_index_free(index);
- git_buf_dispose(&c1);
- git_buf_dispose(&c2);
+ git_str_dispose(&c1);
+ git_str_dispose(&c2);
}
void test_diff_rename__file_exchange_three(void)
{
- git_buf c1 = GIT_BUF_INIT, c2 = GIT_BUF_INIT, c3 = GIT_BUF_INIT;
+ git_str c1 = GIT_STR_INIT, c2 = GIT_STR_INIT, c3 = GIT_STR_INIT;
git_index *index;
git_tree *tree;
git_diff *diff;
@@ -760,14 +760,14 @@ void test_diff_rename__file_exchange_three(void)
git_tree_free(tree);
git_index_free(index);
- git_buf_dispose(&c1);
- git_buf_dispose(&c2);
- git_buf_dispose(&c3);
+ git_str_dispose(&c1);
+ git_str_dispose(&c2);
+ git_str_dispose(&c3);
}
void test_diff_rename__file_partial_exchange(void)
{
- git_buf c1 = GIT_BUF_INIT, c2 = GIT_BUF_INIT;
+ git_str c1 = GIT_STR_INIT, c2 = GIT_STR_INIT;
git_index *index;
git_tree *tree;
git_diff *diff;
@@ -779,7 +779,7 @@ void test_diff_rename__file_partial_exchange(void)
cl_git_pass(git_futils_readbuffer(&c1, "renames/untimely.txt"));
cl_git_pass(git_futils_writebuffer(&c1, "renames/songof7cities.txt", 0, 0));
for (i = 0; i < 100; ++i)
- cl_git_pass(git_buf_puts(&c2, "this is not the content you are looking for\n"));
+ cl_git_pass(git_str_puts(&c2, "this is not the content you are looking for\n"));
cl_git_pass(git_futils_writebuffer(&c2, "renames/untimely.txt", 0, 0));
cl_git_pass(
@@ -813,13 +813,13 @@ void test_diff_rename__file_partial_exchange(void)
git_tree_free(tree);
git_index_free(index);
- git_buf_dispose(&c1);
- git_buf_dispose(&c2);
+ git_str_dispose(&c1);
+ git_str_dispose(&c2);
}
void test_diff_rename__rename_and_copy_from_same_source(void)
{
- git_buf c1 = GIT_BUF_INIT, c2 = GIT_BUF_INIT;
+ git_str c1 = GIT_STR_INIT, c2 = GIT_STR_INIT;
git_index *index;
git_tree *tree;
git_diff *diff;
@@ -831,9 +831,9 @@ void test_diff_rename__rename_and_copy_from_same_source(void)
* and the second 2/3 of file into another new place
*/
cl_git_pass(git_futils_readbuffer(&c1, "renames/songof7cities.txt"));
- cl_git_pass(git_buf_set(&c2, c1.ptr, c1.size));
- git_buf_truncate(&c1, c1.size * 2 / 3);
- git_buf_consume(&c2, ((char *)c2.ptr) + (c2.size / 3));
+ cl_git_pass(git_str_set(&c2, c1.ptr, c1.size));
+ git_str_truncate(&c1, c1.size * 2 / 3);
+ git_str_consume(&c2, ((char *)c2.ptr) + (c2.size / 3));
cl_git_pass(git_futils_writebuffer(&c1, "renames/song_a.txt", 0, 0));
cl_git_pass(git_futils_writebuffer(&c2, "renames/song_b.txt", 0, 0));
@@ -870,13 +870,13 @@ void test_diff_rename__rename_and_copy_from_same_source(void)
git_tree_free(tree);
git_index_free(index);
- git_buf_dispose(&c1);
- git_buf_dispose(&c2);
+ git_str_dispose(&c1);
+ git_str_dispose(&c2);
}
void test_diff_rename__from_deleted_to_split(void)
{
- git_buf c1 = GIT_BUF_INIT;
+ git_str c1 = GIT_STR_INIT;
git_index *index;
git_tree *tree;
git_diff *diff;
@@ -924,7 +924,7 @@ void test_diff_rename__from_deleted_to_split(void)
git_tree_free(tree);
git_index_free(index);
- git_buf_dispose(&c1);
+ git_str_dispose(&c1);
}
struct rename_expected
@@ -967,7 +967,7 @@ void test_diff_rename__rejected_match_can_match_others(void)
git_diff *diff;
git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT;
git_diff_find_options findopts = GIT_DIFF_FIND_OPTIONS_INIT;
- git_buf one = GIT_BUF_INIT, two = GIT_BUF_INIT;
+ git_str one = GIT_STR_INIT, two = GIT_STR_INIT;
unsigned int status[] = { GIT_DELTA_RENAMED, GIT_DELTA_RENAMED };
const char *sources[] = { "Class1.cs", "Class2.cs" };
const char *targets[] = { "ClassA.cs", "ClassB.cs" };
@@ -1024,25 +1024,25 @@ void test_diff_rename__rejected_match_can_match_others(void)
git_index_free(index);
git_reference_free(head);
git_reference_free(selfsimilar);
- git_buf_dispose(&one);
- git_buf_dispose(&two);
+ git_str_dispose(&one);
+ git_str_dispose(&two);
}
static void write_similarity_file_two(const char *filename, size_t b_lines)
{
- git_buf contents = GIT_BUF_INIT;
+ git_str contents = GIT_STR_INIT;
size_t i;
for (i = 0; i < b_lines; i++)
- git_buf_printf(&contents, "%02d - bbbbb\r\n", (int)(i+1));
+ git_str_printf(&contents, "%02d - bbbbb\r\n", (int)(i+1));
for (i = b_lines; i < 50; i++)
- git_buf_printf(&contents, "%02d - aaaaa%s", (int)(i+1), (i == 49 ? "" : "\r\n"));
+ git_str_printf(&contents, "%02d - aaaaa%s", (int)(i+1), (i == 49 ? "" : "\r\n"));
cl_git_pass(
git_futils_writebuffer(&contents, filename, O_RDWR|O_CREAT, 0777));
- git_buf_dispose(&contents);
+ git_str_dispose(&contents);
}
void test_diff_rename__rejected_match_can_match_others_two(void)
@@ -1346,7 +1346,7 @@ void test_diff_rename__rewrite_on_single_file(void)
void test_diff_rename__can_find_copy_to_split(void)
{
- git_buf c1 = GIT_BUF_INIT;
+ git_str c1 = GIT_STR_INIT;
git_index *index;
git_tree *tree;
git_diff *diff;
@@ -1390,12 +1390,12 @@ void test_diff_rename__can_find_copy_to_split(void)
git_tree_free(tree);
git_index_free(index);
- git_buf_dispose(&c1);
+ git_str_dispose(&c1);
}
void test_diff_rename__can_delete_unmodified_deltas(void)
{
- git_buf c1 = GIT_BUF_INIT;
+ git_str c1 = GIT_STR_INIT;
git_index *index;
git_tree *tree;
git_diff *diff;
@@ -1438,7 +1438,7 @@ void test_diff_rename__can_delete_unmodified_deltas(void)
git_tree_free(tree);
git_index_free(index);
- git_buf_dispose(&c1);
+ git_str_dispose(&c1);
}
void test_diff_rename__matches_config_behavior(void)
diff --git a/tests/diff/stats.c b/tests/diff/stats.c
index 54572672c..f69dba9b3 100644
--- a/tests/diff/stats.c
+++ b/tests/diff/stats.c
@@ -1,7 +1,6 @@
#include "clar.h"
#include "clar_libgit2.h"
-#include "buffer.h"
#include "commit.h"
#include "diff.h"
#include "diff_generate.h"
@@ -53,11 +52,11 @@ void test_diff_stats__stat(void)
cl_assert_equal_sz(3, git_diff_stats_deletions(_stats));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 0));
- cl_assert(strcmp(git_buf_cstr(&buf), stat) == 0);
+ cl_assert(strcmp(buf.ptr, stat) == 0);
git_buf_dispose(&buf);
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 80));
- cl_assert(strcmp(git_buf_cstr(&buf), stat) == 0);
+ cl_assert(strcmp(buf.ptr, stat) == 0);
git_buf_dispose(&buf);
}
@@ -77,7 +76,7 @@ void test_diff_stats__multiple_hunks(void)
cl_assert_equal_sz(4, git_diff_stats_deletions(_stats));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -92,7 +91,7 @@ void test_diff_stats__numstat(void)
&_stats, "cd471f0d8770371e1bc78bcbb38db4c7e4106bd2", false);
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_NUMBER, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -110,7 +109,7 @@ void test_diff_stats__shortstat(void)
cl_assert_equal_sz(3, git_diff_stats_deletions(_stats));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_SHORT, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -128,7 +127,7 @@ void test_diff_stats__shortstat_noinsertions(void)
cl_assert_equal_sz(2, git_diff_stats_deletions(_stats));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_SHORT, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -146,7 +145,7 @@ void test_diff_stats__shortstat_nodeletions(void)
cl_assert_equal_sz(0, git_diff_stats_deletions(_stats));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_SHORT, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -166,7 +165,7 @@ void test_diff_stats__rename(void)
cl_assert_equal_sz(1, git_diff_stats_deletions(_stats));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -186,7 +185,7 @@ void test_diff_stats__rename_nochanges(void)
cl_assert_equal_sz(0, git_diff_stats_deletions(_stats));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -206,7 +205,7 @@ void test_diff_stats__rename_and_modifiy(void)
cl_assert_equal_sz(1, git_diff_stats_deletions(_stats));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -225,7 +224,7 @@ void test_diff_stats__rename_in_subdirectory(void)
cl_assert_equal_sz(0, git_diff_stats_deletions(_stats));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -247,7 +246,7 @@ void test_diff_stats__rename_no_find(void)
cl_assert_equal_sz(10, git_diff_stats_deletions(_stats));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -269,7 +268,7 @@ void test_diff_stats__rename_nochanges_no_find(void)
cl_assert_equal_sz(13, git_diff_stats_deletions(_stats));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -290,7 +289,7 @@ void test_diff_stats__rename_and_modify_no_find(void)
cl_assert_equal_sz(8, git_diff_stats_deletions(_stats));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -309,7 +308,7 @@ void test_diff_stats__binary(void)
cl_assert_equal_sz(0, git_diff_stats_deletions(_stats));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -323,7 +322,7 @@ void test_diff_stats__binary_numstat(void)
&_stats, "8d7523f6fcb2404257889abe0d96f093d9f524f9", false);
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_NUMBER, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -339,7 +338,7 @@ void test_diff_stats__mode_change(void)
&_stats, "7ade76dd34bba4733cf9878079f9fd4a456a9189", false);
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL | GIT_DIFF_STATS_INCLUDE_SUMMARY, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
}
@@ -372,7 +371,7 @@ void test_diff_stats__new_file(void)
cl_git_pass(git_diff_from_buffer(&diff, input, strlen(input)));
cl_git_pass(git_diff_get_stats(&_stats, diff));
cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL | GIT_DIFF_STATS_INCLUDE_SUMMARY, 0));
- cl_assert_equal_s(stat, git_buf_cstr(&buf));
+ cl_assert_equal_s(stat, buf.ptr);
git_buf_dispose(&buf);
git_diff_free(diff);
diff --git a/tests/diff/submodules.c b/tests/diff/submodules.c
index 93223ef7d..0436ca5c8 100644
--- a/tests/diff/submodules.c
+++ b/tests/diff/submodules.c
@@ -15,7 +15,7 @@ void test_diff_submodules__cleanup(void)
cl_git_sandbox_cleanup();
}
-#define get_buf_ptr(buf) ((buf)->asize ? (buf)->ptr : NULL)
+#define get_buf_ptr(buf) ((buf)->size ? (buf)->ptr : NULL)
static void check_diff_patches_at_line(
git_diff *diff, const char **expected,
diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c
index 00c52ff1b..f7c74a294 100644
--- a/tests/diff/workdir.c
+++ b/tests/diff/workdir.c
@@ -1663,7 +1663,7 @@ void test_diff_workdir__patience_diff(void)
cl_git_pass(git_patch_to_buf(&buf, patch));
cl_assert_equal_s(expected_normal, buf.ptr);
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
git_patch_free(patch);
git_diff_free(diff);
@@ -1675,9 +1675,8 @@ void test_diff_workdir__patience_diff(void)
cl_git_pass(git_patch_to_buf(&buf, patch));
cl_assert_equal_s(expected_patience, buf.ptr);
- git_buf_clear(&buf);
-
git_buf_dispose(&buf);
+
git_patch_free(patch);
git_diff_free(diff);
}
@@ -1754,7 +1753,7 @@ void test_diff_workdir__with_stale_index(void)
git_index_free(idx);
}
-static int touch_file(void *payload, git_buf *path)
+static int touch_file(void *payload, git_str *path)
{
struct stat st;
struct p_timeval times[2];
@@ -1804,10 +1803,10 @@ void test_diff_workdir__can_update_index(void)
/* touch all the files so stat times are different */
{
- git_buf path = GIT_BUF_INIT;
- cl_git_pass(git_buf_sets(&path, "status"));
+ git_str path = GIT_STR_INIT;
+ cl_git_pass(git_str_sets(&path, "status"));
cl_git_pass(git_path_direach(&path, 0, touch_file, NULL));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
@@ -1873,9 +1872,9 @@ void test_diff_workdir__binary_detection(void)
{
git_index *idx;
git_diff *diff = NULL;
- git_buf b = GIT_BUF_INIT;
+ git_str b = GIT_STR_INIT;
int i;
- git_buf data[10] = {
+ git_str data[10] = {
{ "1234567890", 0, 10 }, /* 0 - all ascii text control */
{ "\xC3\x85\xC3\xBC\xE2\x80\xA0\x48\xC3\xB8\xCF\x80\xCE\xA9", 0, 14 }, /* 1 - UTF-8 multibyte text */
{ "\xEF\xBB\xBF\xC3\x9C\xE2\xA4\x92\xC6\x92\x38\xC2\xA3\xE2\x82\xAC", 0, 16 }, /* 2 - UTF-8 with BOM */
@@ -1899,7 +1898,7 @@ void test_diff_workdir__binary_detection(void)
* then we will try with test data in index and ASCII in workdir.
*/
- cl_git_pass(git_buf_sets(&b, "empty_standard_repo/0"));
+ cl_git_pass(git_str_sets(&b, "empty_standard_repo/0"));
for (i = 0; i < 10; ++i) {
b.ptr[b.size - 1] = '0' + i;
cl_git_mkfile(b.ptr, "baseline");
@@ -1931,7 +1930,7 @@ void test_diff_workdir__binary_detection(void)
git_diff_free(diff);
- cl_git_pass(git_buf_sets(&b, "empty_standard_repo/0"));
+ cl_git_pass(git_str_sets(&b, "empty_standard_repo/0"));
for (i = 0; i < 10; ++i) {
b.ptr[b.size - 1] = '0' + i;
cl_git_pass(git_index_add_bypath(idx, &b.ptr[b.size - 1]));
@@ -1959,7 +1958,7 @@ void test_diff_workdir__binary_detection(void)
git_diff_free(diff);
git_index_free(idx);
- git_buf_dispose(&b);
+ git_str_dispose(&b);
}
void test_diff_workdir__to_index_conflicted(void) {
@@ -2006,7 +2005,7 @@ void test_diff_workdir__only_writes_index_when_necessary(void)
git_reference *head;
git_object *head_object;
git_oid initial, first, second;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
struct stat st;
struct p_timeval times[2];
@@ -2040,7 +2039,7 @@ void test_diff_workdir__only_writes_index_when_necessary(void)
cl_assert(!git_oid_equal(&initial, &first));
/* touch all the files so stat times are different */
- cl_git_pass(git_buf_sets(&path, "status"));
+ cl_git_pass(git_str_sets(&path, "status"));
cl_git_pass(git_path_direach(&path, 0, touch_file, NULL));
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
@@ -2050,7 +2049,7 @@ void test_diff_workdir__only_writes_index_when_necessary(void)
git_oid_cpy(&second, git_index_checksum(index));
cl_assert(!git_oid_equal(&first, &second));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
git_object_free(head_object);
git_reference_free(head);
git_index_free(index);
diff --git a/tests/email/create.c b/tests/email/create.c
index ccf79c2aa..27a665582 100644
--- a/tests/email/create.c
+++ b/tests/email/create.c
@@ -1,7 +1,6 @@
#include "clar.h"
#include "clar_libgit2.h"
-#include "buffer.h"
#include "diff_generate.h"
static git_repository *repo;
@@ -43,7 +42,7 @@ static void assert_email_match(
git_buf buf = GIT_BUF_INIT;
email_for_commit(&buf, commit_id, opts);
- cl_assert_equal_s(expected, git_buf_cstr(&buf));
+ cl_assert_equal_s(expected, buf.ptr);
git_buf_dispose(&buf);
}
@@ -54,15 +53,17 @@ static void assert_subject_match(
git_email_create_options *opts)
{
git_buf buf = GIT_BUF_INIT;
- const char *loc;
+ char *subject, *nl;
email_for_commit(&buf, commit_id, opts);
- cl_assert((loc = strstr(buf.ptr, "\nSubject: ")) != NULL);
- git_buf_consume(&buf, (loc + 10));
- git_buf_truncate_at_char(&buf, '\n');
+ cl_assert((subject = strstr(buf.ptr, "\nSubject: ")) != NULL);
+ subject += 10;
- cl_assert_equal_s(expected, git_buf_cstr(&buf));
+ if ((nl = strchr(subject, '\n')) != NULL)
+ *nl = '\0';
+
+ cl_assert_equal_s(expected, subject);
git_buf_dispose(&buf);
}
@@ -327,7 +328,7 @@ void test_email_create__custom_summary_and_body(void)
cl_git_pass(git_diff__commit(&diff, repo, commit, NULL));
cl_git_pass(git_email_create_from_diff(&buf, diff, 2, 4, &oid, summary, body, git_commit_author(commit), &opts));
- cl_assert_equal_s(expected, git_buf_cstr(&buf));
+ cl_assert_equal_s(expected, buf.ptr);
git_diff_free(diff);
git_commit_free(commit);
diff --git a/tests/fetchhead/nonetwork.c b/tests/fetchhead/nonetwork.c
index 6881af40a..0de712be8 100644
--- a/tests/fetchhead/nonetwork.c
+++ b/tests/fetchhead/nonetwork.c
@@ -78,7 +78,7 @@ void test_fetchhead_nonetwork__write(void)
{
git_vector fetchhead_vector = GIT_VECTOR_INIT;
git_fetchhead_ref *fetchhead_ref;
- git_buf fetchhead_buf = GIT_BUF_INIT;
+ git_str fetchhead_buf = GIT_STR_INIT;
int equals = 0;
size_t i;
@@ -94,7 +94,7 @@ void test_fetchhead_nonetwork__write(void)
equals = (strcmp(fetchhead_buf.ptr, FETCH_HEAD_WILDCARD_DATA_LOCAL) == 0);
- git_buf_dispose(&fetchhead_buf);
+ git_str_dispose(&fetchhead_buf);
git_vector_foreach(&fetchhead_vector, i, fetchhead_ref) {
git_fetchhead_ref_free(fetchhead_ref);
@@ -431,7 +431,7 @@ int find_master_haacked(const char *ref_name, const char *remote_url, const git_
void test_fetchhead_nonetwork__create_when_refpecs_given(void)
{
git_remote *remote;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
char *refspec1 = "refs/heads/master";
char *refspec2 = "refs/heads/haacked";
char *refspecs[] = { refspec1, refspec2 };
@@ -443,7 +443,7 @@ void test_fetchhead_nonetwork__create_when_refpecs_given(void)
cl_set_cleanup(&cleanup_repository, "./test1");
cl_git_pass(git_repository_init(&g_repo, "./test1", 0));
- cl_git_pass(git_buf_joinpath(&path, git_repository_path(g_repo), "FETCH_HEAD"));
+ cl_git_pass(git_str_joinpath(&path, git_repository_path(g_repo), "FETCH_HEAD"));
cl_git_pass(git_remote_create(&remote, g_repo, "origin", cl_fixture("testrepo.git")));
cl_assert(!git_path_exists(path.ptr));
@@ -456,7 +456,7 @@ void test_fetchhead_nonetwork__create_when_refpecs_given(void)
cl_assert(found_haacked);
git_remote_free(remote);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
static bool count_refs_called;
@@ -488,7 +488,7 @@ int count_refs(const char *ref_name, const char *remote_url, const git_oid *oid,
void test_fetchhead_nonetwork__create_with_multiple_refspecs(void)
{
git_remote *remote;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cl_set_cleanup(&cleanup_repository, "./test1");
cl_git_pass(git_repository_init(&g_repo, "./test1", 0));
@@ -499,7 +499,7 @@ void test_fetchhead_nonetwork__create_with_multiple_refspecs(void)
/* Pick up the new refspec */
cl_git_pass(git_remote_lookup(&remote, g_repo, "origin"));
- cl_git_pass(git_buf_joinpath(&path, git_repository_path(g_repo), "FETCH_HEAD"));
+ cl_git_pass(git_str_joinpath(&path, git_repository_path(g_repo), "FETCH_HEAD"));
cl_assert(!git_path_exists(path.ptr));
cl_git_pass(git_remote_fetch(remote, NULL, NULL, NULL));
cl_assert(git_path_exists(path.ptr));
@@ -520,7 +520,7 @@ void test_fetchhead_nonetwork__create_with_multiple_refspecs(void)
}
git_remote_free(remote);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_fetchhead_nonetwork__credentials_are_stripped(void)
diff --git a/tests/filter/crlf.c b/tests/filter/crlf.c
index bc9c7f289..925ea58d2 100644
--- a/tests/filter/crlf.c
+++ b/tests/filter/crlf.c
@@ -1,6 +1,5 @@
#include "clar_libgit2.h"
#include "git2/sys/filter.h"
-#include "buffer.h"
static git_repository *g_repo = NULL;
diff --git a/tests/filter/custom_helpers.c b/tests/filter/custom_helpers.c
index ee3b6353b..7aa3777e6 100644
--- a/tests/filter/custom_helpers.c
+++ b/tests/filter/custom_helpers.c
@@ -8,8 +8,8 @@
int bitflip_filter_apply(
git_filter *self,
void **payload,
- git_buf *to,
- const git_buf *from,
+ git_str *to,
+ const git_str *from,
const git_filter_source *source)
{
const unsigned char *src = (const unsigned char *)from->ptr;
@@ -25,7 +25,7 @@ int bitflip_filter_apply(
if (!from->size)
return 0;
- cl_git_pass(git_buf_grow(to, from->size));
+ cl_git_pass(git_str_grow(to, from->size));
dst = (unsigned char *)to->ptr;
@@ -70,8 +70,8 @@ git_filter *create_bitflip_filter(void)
int reverse_filter_apply(
git_filter *self,
void **payload,
- git_buf *to,
- const git_buf *from,
+ git_str *to,
+ const git_str *from,
const git_filter_source *source)
{
const unsigned char *src = (const unsigned char *)from->ptr;
@@ -87,7 +87,7 @@ int reverse_filter_apply(
if (!from->size)
return 0;
- cl_git_pass(git_buf_grow(to, from->size));
+ cl_git_pass(git_str_grow(to, from->size));
dst = (unsigned char *)to->ptr + from->size - 1;
diff --git a/tests/filter/custom_helpers.h b/tests/filter/custom_helpers.h
index 537a51da2..0936c581b 100644
--- a/tests/filter/custom_helpers.h
+++ b/tests/filter/custom_helpers.h
@@ -7,13 +7,13 @@ extern git_filter *create_erroneous_filter(const char *attr);
extern int bitflip_filter_apply(
git_filter *self,
void **payload,
- git_buf *to,
- const git_buf *from,
+ git_str *to,
+ const git_str *from,
const git_filter_source *source);
extern int reverse_filter_apply(
git_filter *self,
void **payload,
- git_buf *to,
- const git_buf *from,
+ git_str *to,
+ const git_str *from,
const git_filter_source *source);
diff --git a/tests/filter/file.c b/tests/filter/file.c
index 521c01c02..3b7ab19e2 100644
--- a/tests/filter/file.c
+++ b/tests/filter/file.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "git2/sys/filter.h"
#include "crlf.h"
-#include "buffer.h"
static git_repository *g_repo = NULL;
@@ -53,13 +52,13 @@ void test_filter_file__apply(void)
struct buf_writestream {
git_writestream base;
- git_buf buf;
+ git_str buf;
};
int buf_writestream_write(git_writestream *s, const char *buf, size_t len)
{
struct buf_writestream *stream = (struct buf_writestream *)s;
- return git_buf_put(&stream->buf, buf, len);
+ return git_str_put(&stream->buf, buf, len);
}
int buf_writestream_close(git_writestream *s)
@@ -71,7 +70,7 @@ int buf_writestream_close(git_writestream *s)
void buf_writestream_free(git_writestream *s)
{
struct buf_writestream *stream = (struct buf_writestream *)s;
- git_buf_dispose(&stream->buf);
+ git_str_dispose(&stream->buf);
}
void test_filter_file__apply_stream(void)
diff --git a/tests/filter/query.c b/tests/filter/query.c
index 6889d715b..429c10443 100644
--- a/tests/filter/query.c
+++ b/tests/filter/query.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "git2/sys/filter.h"
#include "crlf.h"
-#include "buffer.h"
static git_repository *g_repo = NULL;
diff --git a/tests/filter/stream.c b/tests/filter/stream.c
index b6a4c3ca1..0f85f9c47 100644
--- a/tests/filter/stream.c
+++ b/tests/filter/stream.c
@@ -137,12 +137,12 @@ git_filter *create_compress_filter(void)
static void writefile(const char *filename, size_t numchunks)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
char buf[CHUNKSIZE];
size_t i = 0, j = 0;
int fd;
- cl_git_pass(git_buf_joinpath(&path, "empty_standard_repo", filename));
+ cl_git_pass(git_str_joinpath(&path, "empty_standard_repo", filename));
fd = p_open(path.ptr, O_RDWR|O_CREAT, 0666);
cl_assert(fd >= 0);
@@ -156,7 +156,7 @@ static void writefile(const char *filename, size_t numchunks)
}
p_close(fd);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
static void test_stream(size_t numchunks)
diff --git a/tests/filter/systemattrs.c b/tests/filter/systemattrs.c
index 4996b3b1e..b687b4b44 100644
--- a/tests/filter/systemattrs.c
+++ b/tests/filter/systemattrs.c
@@ -3,29 +3,33 @@
#include "path.h"
static git_repository *g_repo = NULL;
-static git_buf system_attr_path = GIT_BUF_INIT;
+static git_str system_attr_path = GIT_STR_INIT;
void test_filter_systemattrs__initialize(void)
{
+ git_buf system_path = GIT_BUF_INIT;
+
g_repo = cl_git_sandbox_init("crlf");
cl_must_pass(p_unlink("crlf/.gitattributes"));
cl_git_pass(git_libgit2_opts(
- GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, &system_attr_path));
- cl_git_pass(git_buf_joinpath(&system_attr_path,
- system_attr_path.ptr, "gitattributes"));
+ GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, &system_path));
+ cl_git_pass(git_str_joinpath(&system_attr_path,
+ system_path.ptr, "gitattributes"));
cl_git_mkfile(system_attr_path.ptr,
"*.txt text\n"
"*.bin binary\n"
"*.crlf text eol=crlf\n"
"*.lf text eol=lf\n");
+
+ git_buf_dispose(&system_path);
}
void test_filter_systemattrs__cleanup(void)
{
cl_must_pass(p_unlink(system_attr_path.ptr));
- git_buf_dispose(&system_attr_path);
+ git_str_dispose(&system_attr_path);
cl_git_sandbox_cleanup();
}
diff --git a/tests/filter/wildcard.c b/tests/filter/wildcard.c
index 0c9c13b1e..ee61a8dba 100644
--- a/tests/filter/wildcard.c
+++ b/tests/filter/wildcard.c
@@ -78,8 +78,8 @@ static int wildcard_filter_check(
static int wildcard_filter_apply(
git_filter *self,
void **payload,
- git_buf *to,
- const git_buf *from,
+ git_str *to,
+ const git_str *from,
const git_filter_source *source)
{
const char *filtername = *payload;
diff --git a/tests/graph/commit_graph.c b/tests/graph/commit_graph.c
index 5926dca6f..83f53f1d4 100644
--- a/tests/graph/commit_graph.c
+++ b/tests/graph/commit_graph.c
@@ -12,12 +12,12 @@ void test_graph_commit_graph__parse(void)
struct git_commit_graph_file *file;
struct git_commit_graph_entry e, parent;
git_oid id;
- git_buf commit_graph_path = GIT_BUF_INIT;
+ git_str commit_graph_path = GIT_STR_INIT;
cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
- cl_git_pass(git_buf_joinpath(&commit_graph_path, git_repository_path(repo), "objects/info/commit-graph"));
- cl_git_pass(git_commit_graph_file_open(&file, git_buf_cstr(&commit_graph_path)));
- cl_assert_equal_i(git_commit_graph_file_needs_refresh(file, git_buf_cstr(&commit_graph_path)), 0);
+ cl_git_pass(git_str_joinpath(&commit_graph_path, git_repository_path(repo), "objects/info/commit-graph"));
+ cl_git_pass(git_commit_graph_file_open(&file, git_str_cstr(&commit_graph_path)));
+ cl_assert_equal_i(git_commit_graph_file_needs_refresh(file, git_str_cstr(&commit_graph_path)), 0);
cl_git_pass(git_oid_fromstr(&id, "5001298e0c09ad9c34e4249bc5801c75e9754fa5"));
cl_git_pass(git_commit_graph_entry_find(&e, file, &id, GIT_OID_HEXSZ));
@@ -47,7 +47,7 @@ void test_graph_commit_graph__parse(void)
git_commit_graph_file_free(file);
git_repository_free(repo);
- git_buf_dispose(&commit_graph_path);
+ git_str_dispose(&commit_graph_path);
}
void test_graph_commit_graph__parse_octopus_merge(void)
@@ -56,11 +56,11 @@ void test_graph_commit_graph__parse_octopus_merge(void)
struct git_commit_graph_file *file;
struct git_commit_graph_entry e, parent;
git_oid id;
- git_buf commit_graph_path = GIT_BUF_INIT;
+ git_str commit_graph_path = GIT_STR_INIT;
cl_git_pass(git_repository_open(&repo, cl_fixture("merge-recursive/.gitted")));
- cl_git_pass(git_buf_joinpath(&commit_graph_path, git_repository_path(repo), "objects/info/commit-graph"));
- cl_git_pass(git_commit_graph_file_open(&file, git_buf_cstr(&commit_graph_path)));
+ cl_git_pass(git_str_joinpath(&commit_graph_path, git_repository_path(repo), "objects/info/commit-graph"));
+ cl_git_pass(git_commit_graph_file_open(&file, git_str_cstr(&commit_graph_path)));
cl_git_pass(git_oid_fromstr(&id, "d71c24b3b113fd1d1909998c5bfe33b86a65ee03"));
cl_git_pass(git_commit_graph_entry_find(&e, file, &id, GIT_OID_HEXSZ));
@@ -88,7 +88,7 @@ void test_graph_commit_graph__parse_octopus_merge(void)
git_commit_graph_file_free(file);
git_repository_free(repo);
- git_buf_dispose(&commit_graph_path);
+ git_str_dispose(&commit_graph_path);
}
void test_graph_commit_graph__writer(void)
@@ -97,12 +97,13 @@ void test_graph_commit_graph__writer(void)
git_commit_graph_writer *w = NULL;
git_revwalk *walk;
git_commit_graph_writer_options opts = GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT;
- git_buf cgraph = GIT_BUF_INIT, expected_cgraph = GIT_BUF_INIT, path = GIT_BUF_INIT;
+ git_buf cgraph = GIT_BUF_INIT;
+ git_str expected_cgraph = GIT_STR_INIT, path = GIT_STR_INIT;
cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
- cl_git_pass(git_buf_joinpath(&path, git_repository_path(repo), "objects/info"));
- cl_git_pass(git_commit_graph_writer_new(&w, git_buf_cstr(&path)));
+ cl_git_pass(git_str_joinpath(&path, git_repository_path(repo), "objects/info"));
+ cl_git_pass(git_commit_graph_writer_new(&w, git_str_cstr(&path)));
/* This is equivalent to `git commit-graph write --reachable`. */
cl_git_pass(git_revwalk_new(&walk, repo));
@@ -111,15 +112,15 @@ void test_graph_commit_graph__writer(void)
git_revwalk_free(walk);
cl_git_pass(git_commit_graph_writer_dump(&cgraph, w, &opts));
- cl_git_pass(git_buf_joinpath(&path, git_repository_path(repo), "objects/info/commit-graph"));
- cl_git_pass(git_futils_readbuffer(&expected_cgraph, git_buf_cstr(&path)));
+ cl_git_pass(git_str_joinpath(&path, git_repository_path(repo), "objects/info/commit-graph"));
+ cl_git_pass(git_futils_readbuffer(&expected_cgraph, git_str_cstr(&path)));
- cl_assert_equal_i(git_buf_len(&cgraph), git_buf_len(&expected_cgraph));
- cl_assert_equal_i(memcmp(git_buf_cstr(&cgraph), git_buf_cstr(&expected_cgraph), git_buf_len(&cgraph)), 0);
+ cl_assert_equal_i(cgraph.size, git_str_len(&expected_cgraph));
+ cl_assert_equal_i(memcmp(cgraph.ptr, git_str_cstr(&expected_cgraph), cgraph.size), 0);
git_buf_dispose(&cgraph);
- git_buf_dispose(&expected_cgraph);
- git_buf_dispose(&path);
+ git_str_dispose(&expected_cgraph);
+ git_str_dispose(&path);
git_commit_graph_writer_free(w);
git_repository_free(repo);
}
diff --git a/tests/graph/reachable_from_any.c b/tests/graph/reachable_from_any.c
index 5c8416499..9693d7d67 100644
--- a/tests/graph/reachable_from_any.c
+++ b/tests/graph/reachable_from_any.c
@@ -200,12 +200,12 @@ void test_graph_reachable_from_any__exhaustive(void)
descendants,
n_descendants);
if (actual_reachable != expected_reachable) {
- git_buf error_message_buf = GIT_BUF_INIT;
+ git_str error_message_buf = GIT_STR_INIT;
char parent_oidbuf[9] = {0}, child_oidbuf[9] = {0};
cl_git_pass(git_oid_nfmt(
parent_oidbuf, 8, git_commit_id(parent_commit)));
- git_buf_printf(&error_message_buf,
+ git_str_printf(&error_message_buf,
"git_graph_reachable_from_any(\"%s\", %zu, "
"{",
parent_oidbuf,
@@ -216,14 +216,14 @@ void test_graph_reachable_from_any__exhaustive(void)
git_oid_nfmt(child_oidbuf,
8,
&descendants[descendant_i]));
- git_buf_printf(&error_message_buf, " \"%s\"", child_oidbuf);
+ git_str_printf(&error_message_buf, " \"%s\"", child_oidbuf);
}
- git_buf_printf(&error_message_buf,
+ git_str_printf(&error_message_buf,
" }) = %d, expected = %d",
actual_reachable,
expected_reachable);
cl_check_(actual_reachable == expected_reachable,
- git_buf_cstr(&error_message_buf));
+ git_str_cstr(&error_message_buf));
}
}
}
diff --git a/tests/ignore/status.c b/tests/ignore/status.c
index 83e821bdd..deb717590 100644
--- a/tests/ignore/status.c
+++ b/tests/ignore/status.c
@@ -610,12 +610,12 @@ void test_ignore_status__filenames_with_special_prefixes_do_not_interfere_with_s
int i;
for (i = 0; *(test_cases + i) != NULL; i++) {
- git_buf file = GIT_BUF_INIT;
+ git_str file = GIT_STR_INIT;
char *file_name = *(test_cases + i);
git_repository *repo = cl_git_sandbox_init("empty_standard_repo");
- cl_git_pass(git_buf_joinpath(&file, "empty_standard_repo", file_name));
- cl_git_mkfile(git_buf_cstr(&file), "Please don't ignore me!");
+ cl_git_pass(git_str_joinpath(&file, "empty_standard_repo", file_name));
+ cl_git_mkfile(git_str_cstr(&file), "Please don't ignore me!");
memset(&st, 0, sizeof(st));
cl_git_pass(git_status_foreach(repo, cb_status__single, &st));
@@ -626,7 +626,7 @@ void test_ignore_status__filenames_with_special_prefixes_do_not_interfere_with_s
cl_assert(st.status == GIT_STATUS_WT_NEW);
cl_git_sandbox_cleanup();
- git_buf_dispose(&file);
+ git_str_dispose(&file);
}
}
diff --git a/tests/index/crlf.c b/tests/index/crlf.c
index 26c19d76d..8d2a5fcce 100644
--- a/tests/index/crlf.c
+++ b/tests/index/crlf.c
@@ -14,7 +14,7 @@
static git_repository *g_repo;
static git_index *g_index;
-static git_buf expected_fixture = GIT_BUF_INIT;
+static git_str expected_fixture = GIT_STR_INIT;
void test_index_crlf__initialize(void)
{
@@ -29,7 +29,7 @@ void test_index_crlf__cleanup(void)
if (expected_fixture.size) {
cl_fixture_cleanup(expected_fixture.ptr);
- git_buf_dispose(&expected_fixture);
+ git_str_dispose(&expected_fixture);
}
}
@@ -42,11 +42,11 @@ struct compare_data
const char *attrs;
};
-static int add_and_check_file(void *payload, git_buf *actual_path)
+static int add_and_check_file(void *payload, git_str *actual_path)
{
- git_buf expected_path = GIT_BUF_INIT;
- git_buf expected_path_fail = GIT_BUF_INIT;
- git_buf expected_contents = GIT_BUF_INIT;
+ git_str expected_path = GIT_STR_INIT;
+ git_str expected_path_fail = GIT_STR_INIT;
+ git_str expected_contents = GIT_STR_INIT;
struct compare_data *cd = payload;
char *basename;
const git_index_entry *entry;
@@ -60,10 +60,10 @@ static int add_and_check_file(void *payload, git_buf *actual_path)
goto done;
}
- cl_git_pass(git_buf_joinpath(&expected_path, cd->dirname, basename));
+ cl_git_pass(git_str_joinpath(&expected_path, cd->dirname, basename));
- cl_git_pass(git_buf_puts(&expected_path_fail, expected_path.ptr));
- cl_git_pass(git_buf_puts(&expected_path_fail, ".fail"));
+ cl_git_pass(git_str_puts(&expected_path_fail, expected_path.ptr));
+ cl_git_pass(git_str_puts(&expected_path_fail, ".fail"));
if (git_path_isfile(expected_path.ptr)) {
cl_git_pass(git_index_add_bypath(g_index, basename));
@@ -79,7 +79,7 @@ static int add_and_check_file(void *payload, git_buf *actual_path)
git_blob_free(blob);
} else if (git_path_isfile(expected_path_fail.ptr)) {
cl_git_pass(git_futils_readbuffer(&expected_contents, expected_path_fail.ptr));
- git_buf_rtrim(&expected_contents);
+ git_str_rtrim(&expected_contents);
if (git_index_add_bypath(g_index, basename) == 0 ||
git_error_last()->klass != GIT_ERROR_FILTER ||
@@ -93,18 +93,18 @@ static int add_and_check_file(void *payload, git_buf *actual_path)
done:
if (failed) {
- git_buf details = GIT_BUF_INIT;
- git_buf_printf(&details, "filename=%s, system=%s, autocrlf=%s, safecrlf=%s, attrs={%s}",
+ git_str details = GIT_STR_INIT;
+ git_str_printf(&details, "filename=%s, system=%s, autocrlf=%s, safecrlf=%s, attrs={%s}",
basename, cd->systype, cd->autocrlf, cd->safecrlf, cd->attrs);
clar__fail(__FILE__, __func__, __LINE__,
"index contents did not match expected", details.ptr, 0);
- git_buf_dispose(&details);
+ git_str_dispose(&details);
}
git__free(basename);
- git_buf_dispose(&expected_contents);
- git_buf_dispose(&expected_path);
- git_buf_dispose(&expected_path_fail);
+ git_str_dispose(&expected_contents);
+ git_str_dispose(&expected_path);
+ git_str_dispose(&expected_path_fail);
return 0;
}
@@ -118,34 +118,34 @@ static const char *system_type(void)
static void test_add_index(const char *safecrlf, const char *autocrlf, const char *attrs)
{
- git_buf attrbuf = GIT_BUF_INIT;
- git_buf expected_dirname = GIT_BUF_INIT;
- git_buf sandboxname = GIT_BUF_INIT;
- git_buf reponame = GIT_BUF_INIT;
+ git_str attrbuf = GIT_STR_INIT;
+ git_str expected_dirname = GIT_STR_INIT;
+ git_str sandboxname = GIT_STR_INIT;
+ git_str reponame = GIT_STR_INIT;
struct compare_data compare_data = { system_type(), NULL, safecrlf, autocrlf, attrs };
const char *c;
- git_buf_puts(&reponame, "crlf");
+ git_str_puts(&reponame, "crlf");
- git_buf_puts(&sandboxname, "autocrlf_");
- git_buf_puts(&sandboxname, autocrlf);
+ git_str_puts(&sandboxname, "autocrlf_");
+ git_str_puts(&sandboxname, autocrlf);
- git_buf_puts(&sandboxname, ",safecrlf_");
- git_buf_puts(&sandboxname, safecrlf);
+ git_str_puts(&sandboxname, ",safecrlf_");
+ git_str_puts(&sandboxname, safecrlf);
if (*attrs) {
- git_buf_puts(&sandboxname, ",");
+ git_str_puts(&sandboxname, ",");
for (c = attrs; *c; c++) {
if (*c == ' ')
- git_buf_putc(&sandboxname, ',');
+ git_str_putc(&sandboxname, ',');
else if (*c == '=')
- git_buf_putc(&sandboxname, '_');
+ git_str_putc(&sandboxname, '_');
else
- git_buf_putc(&sandboxname, *c);
+ git_str_putc(&sandboxname, *c);
}
- git_buf_printf(&attrbuf, "* %s\n", attrs);
+ git_str_printf(&attrbuf, "* %s\n", attrs);
cl_git_mkfile("crlf/.gitattributes", attrbuf.ptr);
}
@@ -154,23 +154,23 @@ static void test_add_index(const char *safecrlf, const char *autocrlf, const cha
cl_git_pass(git_index_clear(g_index));
- git_buf_joinpath(&expected_dirname, "crlf_data", system_type());
- git_buf_puts(&expected_dirname, "_to_odb");
+ git_str_joinpath(&expected_dirname, "crlf_data", system_type());
+ git_str_puts(&expected_dirname, "_to_odb");
- git_buf_joinpath(&expected_fixture, expected_dirname.ptr, sandboxname.ptr);
+ git_str_joinpath(&expected_fixture, expected_dirname.ptr, sandboxname.ptr);
cl_fixture_sandbox(expected_fixture.ptr);
compare_data.dirname = sandboxname.ptr;
cl_git_pass(git_path_direach(&reponame, 0, add_and_check_file, &compare_data));
cl_fixture_cleanup(expected_fixture.ptr);
- git_buf_dispose(&expected_fixture);
+ git_str_dispose(&expected_fixture);
- git_buf_dispose(&attrbuf);
- git_buf_dispose(&expected_fixture);
- git_buf_dispose(&expected_dirname);
- git_buf_dispose(&sandboxname);
- git_buf_dispose(&reponame);
+ git_str_dispose(&attrbuf);
+ git_str_dispose(&expected_fixture);
+ git_str_dispose(&expected_dirname);
+ git_str_dispose(&sandboxname);
+ git_str_dispose(&reponame);
}
static void set_up_workingdir(const char *name)
@@ -196,16 +196,16 @@ static void set_up_workingdir(const char *name)
git_path_dirload(&contents, cl_fixture("crlf"), 0, 0);
git_vector_foreach(&contents, i, fn) {
char *basename = git_path_basename(fn);
- git_buf dest_filename = GIT_BUF_INIT;
+ git_str dest_filename = GIT_STR_INIT;
if (strcmp(basename, ".gitted") &&
strcmp(basename, ".gitattributes")) {
- git_buf_joinpath(&dest_filename, name, basename);
+ git_str_joinpath(&dest_filename, name, basename);
cl_git_pass(git_futils_cp(fn, dest_filename.ptr, 0644));
}
git__free(basename);
- git_buf_dispose(&dest_filename);
+ git_str_dispose(&dest_filename);
}
git_vector_free_deep(&contents);
}
diff --git a/tests/index/filemodes.c b/tests/index/filemodes.c
index 3d2bb4a03..1ab8a9a7f 100644
--- a/tests/index/filemodes.c
+++ b/tests/index/filemodes.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "posix.h"
#include "index.h"
@@ -36,10 +35,10 @@ void test_index_filemodes__read(void)
static void replace_file_with_mode(
const char *filename, const char *backup, unsigned int create_mode)
{
- git_buf path = GIT_BUF_INIT, content = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT, content = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&path, "filemodes", filename));
- cl_git_pass(git_buf_printf(&content, "%s as %08u (%d)",
+ cl_git_pass(git_str_joinpath(&path, "filemodes", filename));
+ cl_git_pass(git_str_printf(&content, "%s as %08u (%d)",
filename, create_mode, rand()));
cl_git_pass(p_rename(path.ptr, backup));
@@ -47,8 +46,8 @@ static void replace_file_with_mode(
path.ptr, content.ptr, content.size,
O_WRONLY|O_CREAT|O_TRUNC, create_mode);
- git_buf_dispose(&path);
- git_buf_dispose(&content);
+ git_str_dispose(&path);
+ git_str_dispose(&content);
}
#define add_and_check_mode(I,F,X) add_and_check_mode_(I,F,X,__FILE__,__func__,__LINE__)
diff --git a/tests/index/nsec.c b/tests/index/nsec.c
index 6edcf030a..3efd855a7 100644
--- a/tests/index/nsec.c
+++ b/tests/index/nsec.c
@@ -47,16 +47,16 @@ static bool try_create_file_with_nsec_timestamp(const char *path)
*/
static bool should_expect_nsecs(void)
{
- git_buf nsec_path = GIT_BUF_INIT;
+ git_str nsec_path = GIT_STR_INIT;
bool expect;
- git_buf_joinpath(&nsec_path, clar_sandbox_path(), "nsec_test");
+ git_str_joinpath(&nsec_path, clar_sandbox_path(), "nsec_test");
expect = try_create_file_with_nsec_timestamp(nsec_path.ptr);
cl_must_pass(p_unlink(nsec_path.ptr));
- git_buf_dispose(&nsec_path);
+ git_str_dispose(&nsec_path);
return expect;
}
diff --git a/tests/index/racy.c b/tests/index/racy.c
index b06f55de4..07b3b73d4 100644
--- a/tests/index/racy.c
+++ b/tests/index/racy.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "../checkout/checkout_helpers.h"
-#include "buffer.h"
#include "index.h"
#include "repository.h"
@@ -24,9 +23,9 @@ void test_index_racy__diff(void)
{
git_index *index;
git_diff *diff;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "A"));
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_repo), "A"));
cl_git_mkfile(path.ptr, "A");
/* Put 'A' into the index */
@@ -46,21 +45,21 @@ void test_index_racy__diff(void)
git_index_free(index);
git_diff_free(diff);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_index_racy__write_index_just_after_file(void)
{
git_index *index;
git_diff *diff;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
struct p_timeval times[2];
/* Make sure we do have a timestamp */
cl_git_pass(git_repository_index(&index, g_repo));
cl_git_pass(git_index_write(index));
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "A"));
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_repo), "A"));
cl_git_mkfile(path.ptr, "A");
/* Force the file's timestamp to be a second after we wrote the index */
times[0].tv_sec = index->stamp.mtime.tv_sec + 1;
@@ -95,7 +94,7 @@ void test_index_racy__write_index_just_after_file(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, index, NULL));
cl_assert_equal_i(1, git_diff_num_deltas(diff));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
git_diff_free(diff);
git_index_free(index);
}
@@ -103,7 +102,7 @@ void test_index_racy__write_index_just_after_file(void)
static void setup_race(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_index *index;
git_index_entry *entry;
struct stat st;
@@ -112,7 +111,7 @@ static void setup_race(void)
cl_git_pass(git_repository_index__weakptr(&index, g_repo));
cl_git_pass(git_index_write(index));
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "A"));
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_repo), "A"));
cl_git_mkfile(path.ptr, "A");
cl_git_pass(git_index_add_bypath(index, "A"));
@@ -129,7 +128,7 @@ static void setup_race(void)
entry->mtime.seconds = (int32_t)st.st_mtime;
entry->mtime.nanoseconds = (int32_t)st.st_mtime_nsec;
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_index_racy__smudges_index_entry_on_save(void)
@@ -169,14 +168,14 @@ void test_index_racy__detects_diff_of_change_in_identical_timestamp(void)
static void setup_uptodate_files(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_index *index;
const git_index_entry *a_entry;
git_index_entry new_entry = {{0}};
cl_git_pass(git_repository_index(&index, g_repo));
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "A"));
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_repo), "A"));
cl_git_mkfile(path.ptr, "A");
/* Put 'A' into the index */
@@ -196,7 +195,7 @@ static void setup_uptodate_files(void)
cl_git_pass(git_index_add_from_buffer(index, &new_entry, "hello!\n", 7));
git_index_free(index);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_index_racy__adding_to_index_is_uptodate(void)
diff --git a/tests/index/tests.c b/tests/index/tests.c
index d9d8371dd..9b28028e6 100644
--- a/tests/index/tests.c
+++ b/tests/index/tests.c
@@ -28,7 +28,7 @@ static struct test_entry test_entries[] = {
/* Helpers */
static void copy_file(const char *src, const char *dst)
{
- git_buf source_buf = GIT_BUF_INIT;
+ git_str source_buf = GIT_STR_INIT;
git_file dst_fd;
cl_git_pass(git_futils_readbuffer(&source_buf, src));
@@ -40,28 +40,28 @@ static void copy_file(const char *src, const char *dst)
cl_git_pass(p_write(dst_fd, source_buf.ptr, source_buf.size));
cleanup:
- git_buf_dispose(&source_buf);
+ git_str_dispose(&source_buf);
p_close(dst_fd);
}
static void files_are_equal(const char *a, const char *b)
{
- git_buf buf_a = GIT_BUF_INIT;
- git_buf buf_b = GIT_BUF_INIT;
+ git_str buf_a = GIT_STR_INIT;
+ git_str buf_b = GIT_STR_INIT;
int pass;
if (git_futils_readbuffer(&buf_a, a) < 0)
cl_assert(0);
if (git_futils_readbuffer(&buf_b, b) < 0) {
- git_buf_dispose(&buf_a);
+ git_str_dispose(&buf_a);
cl_assert(0);
}
pass = (buf_a.size == buf_b.size && !memcmp(buf_a.ptr, buf_b.ptr, buf_a.size));
- git_buf_dispose(&buf_a);
- git_buf_dispose(&buf_b);
+ git_str_dispose(&buf_a);
+ git_str_dispose(&buf_b);
cl_assert(pass);
}
@@ -544,12 +544,12 @@ void test_index_tests__add_bypath_to_a_bare_repository_returns_EBAREPO(void)
static void assert_add_bypath_fails(git_repository *repo, const char *fn)
{
git_index *index;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cl_git_pass(git_repository_index(&index, repo));
cl_assert(git_index_entrycount(index) == 0);
- git_buf_joinpath(&path, "./invalid", fn);
+ git_str_joinpath(&path, "./invalid", fn);
cl_git_mkfile(path.ptr, NULL);
cl_git_fail(git_index_add_bypath(index, fn));
@@ -557,7 +557,7 @@ static void assert_add_bypath_fails(git_repository *repo, const char *fn)
cl_assert(git_index_entrycount(index) == 0);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
git_index_free(index);
}
@@ -592,7 +592,7 @@ void test_index_tests__cannot_add_invalid_filename(void)
static void assert_add_fails(git_repository *repo, const char *fn)
{
git_index *index;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_index_entry entry = {{0}};
cl_git_pass(git_repository_index(&index, repo));
@@ -606,7 +606,7 @@ static void assert_add_fails(git_repository *repo, const char *fn)
cl_assert(git_index_entrycount(index) == 0);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
git_index_free(index);
}
@@ -659,7 +659,7 @@ static void assert_write_fails(git_repository *repo, const char *fn_orig)
git_index *index;
git_oid expected;
const git_index_entry *entry;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
char *fn;
cl_git_pass(git_repository_index(&index, repo));
@@ -673,7 +673,7 @@ static void assert_write_fails(git_repository *repo, const char *fn_orig)
replace_char(fn, '/', '_');
replace_char(fn, ':', '!');
- git_buf_joinpath(&path, "./invalid", fn);
+ git_str_joinpath(&path, "./invalid", fn);
cl_git_mkfile(path.ptr, NULL);
@@ -691,7 +691,7 @@ static void assert_write_fails(git_repository *repo, const char *fn_orig)
p_unlink(path.ptr);
cl_git_pass(git_index_remove_all(index, NULL, NULL, NULL));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
git_index_free(index);
git__free(fn);
}
diff --git a/tests/iterator/index.c b/tests/iterator/index.c
index 25d8c2990..69b795f5c 100644
--- a/tests/iterator/index.c
+++ b/tests/iterator/index.c
@@ -279,12 +279,12 @@ static const char *expected_index_ci[] = {
void test_iterator_index__case_folding(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
int fs_is_ci = 0;
- cl_git_pass(git_buf_joinpath(&path, cl_fixture("icase"), ".gitted/CoNfIg"));
+ cl_git_pass(git_str_joinpath(&path, cl_fixture("icase"), ".gitted/CoNfIg"));
fs_is_ci = git_path_exists(path.ptr);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
index_iterator_test(
"icase", NULL, NULL, 0, ARRAY_SIZE(expected_index_cs),
@@ -978,22 +978,22 @@ void test_iterator_index__pathlist_with_directory(void)
static void create_paths(git_index *index, const char *root, int depth)
{
- git_buf fullpath = GIT_BUF_INIT;
+ git_str fullpath = GIT_STR_INIT;
git_index_entry entry;
size_t root_len;
int i;
if (root) {
- cl_git_pass(git_buf_puts(&fullpath, root));
- cl_git_pass(git_buf_putc(&fullpath, '/'));
+ cl_git_pass(git_str_puts(&fullpath, root));
+ cl_git_pass(git_str_putc(&fullpath, '/'));
}
root_len = fullpath.size;
for (i = 0; i < 8; i++) {
bool file = (depth == 0 || (i % 2) == 0);
- git_buf_truncate(&fullpath, root_len);
- cl_git_pass(git_buf_printf(&fullpath, "item%d", i));
+ git_str_truncate(&fullpath, root_len);
+ cl_git_pass(git_str_printf(&fullpath, "item%d", i));
if (file) {
memset(&entry, 0, sizeof(git_index_entry));
@@ -1007,7 +1007,7 @@ static void create_paths(git_index *index, const char *root, int depth)
}
}
- git_buf_dispose(&fullpath);
+ git_str_dispose(&fullpath);
}
void test_iterator_index__pathlist_for_deeply_nested_item(void)
diff --git a/tests/iterator/tree.c b/tests/iterator/tree.c
index f7fb9a7ee..4145c8dea 100644
--- a/tests/iterator/tree.c
+++ b/tests/iterator/tree.c
@@ -623,7 +623,7 @@ static void build_test_tree(
const char *scan = fmt, *next;
char type, delimiter;
git_filemode_t mode = GIT_FILEMODE_BLOB;
- git_buf name = GIT_BUF_INIT;
+ git_str name = GIT_STR_INIT;
va_list arglist;
cl_git_pass(git_treebuilder_new(&builder, repo, NULL)); /* start builder */
@@ -640,7 +640,7 @@ static void build_test_tree(
delimiter = *scan++; /* read and skip delimiter */
for (next = scan; *next && *next != delimiter; ++next)
/* seek end */;
- cl_git_pass(git_buf_set(&name, scan, (size_t)(next - scan)));
+ cl_git_pass(git_str_set(&name, scan, (size_t)(next - scan)));
for (scan = next; *scan && (*scan == delimiter || *scan == ','); ++scan)
/* skip delimiter and optional comma */;
@@ -653,7 +653,7 @@ static void build_test_tree(
cl_git_pass(git_treebuilder_write(out, builder));
git_treebuilder_free(builder);
- git_buf_dispose(&name);
+ git_str_dispose(&name);
}
void test_iterator_tree__case_conflicts_0(void)
diff --git a/tests/iterator/workdir.c b/tests/iterator/workdir.c
index 82ee363f9..7ca726c24 100644
--- a/tests/iterator/workdir.c
+++ b/tests/iterator/workdir.c
@@ -643,7 +643,7 @@ void test_iterator_workdir__filesystem2(void)
*/
void test_iterator_workdir__filesystem_gunk(void)
{
- git_buf parent = GIT_BUF_INIT;
+ git_str parent = GIT_STR_INIT;
git_iterator *i;
int n;
@@ -653,8 +653,8 @@ void test_iterator_workdir__filesystem_gunk(void)
g_repo = cl_git_sandbox_init("testrepo");
for (n = 0; n < 100000; n++) {
- git_buf_clear(&parent);
- cl_git_pass(git_buf_printf(&parent, "%s/refs/heads/foo/%d/subdir", git_repository_path(g_repo), n));
+ git_str_clear(&parent);
+ cl_git_pass(git_str_printf(&parent, "%s/refs/heads/foo/%d/subdir", git_repository_path(g_repo), n));
cl_git_pass(git_futils_mkdir(parent.ptr, 0775, GIT_MKDIR_PATH));
}
@@ -667,7 +667,7 @@ void test_iterator_workdir__filesystem_gunk(void)
expect_iterator_items(i, 17, NULL, 16, NULL);
git_iterator_free(i);
- git_buf_dispose(&parent);
+ git_str_dispose(&parent);
}
void test_iterator_workdir__skips_unreadable_dirs(void)
@@ -1019,19 +1019,19 @@ void test_iterator_workdir__pathlist_with_dirs(void)
static void create_paths(const char *root, int depth)
{
- git_buf fullpath = GIT_BUF_INIT;
+ git_str fullpath = GIT_STR_INIT;
size_t root_len;
int i;
- cl_git_pass(git_buf_puts(&fullpath, root));
+ cl_git_pass(git_str_puts(&fullpath, root));
cl_git_pass(git_path_to_dir(&fullpath));
root_len = fullpath.size;
for (i = 0; i < 8; i++) {
bool file = (depth == 0 || (i % 2) == 0);
- git_buf_truncate(&fullpath, root_len);
- cl_git_pass(git_buf_printf(&fullpath, "item%d", i));
+ git_str_truncate(&fullpath, root_len);
+ cl_git_pass(git_str_printf(&fullpath, "item%d", i));
if (file) {
cl_git_rewritefile(fullpath.ptr, "This is a file!\n");
@@ -1043,7 +1043,7 @@ static void create_paths(const char *root, int depth)
}
}
- git_buf_dispose(&fullpath);
+ git_str_dispose(&fullpath);
}
void test_iterator_workdir__pathlist_for_deeply_nested_item(void)
diff --git a/tests/mailmap/parsing.c b/tests/mailmap/parsing.c
index ba3b3a2f6..5ea470f34 100644
--- a/tests/mailmap/parsing.c
+++ b/tests/mailmap/parsing.c
@@ -103,15 +103,15 @@ void test_mailmap_parsing__string(void)
void test_mailmap_parsing__windows_string(void)
{
- git_buf unixbuf = GIT_BUF_INIT;
- git_buf winbuf = GIT_BUF_INIT;
+ git_str unixbuf = GIT_STR_INIT;
+ git_str winbuf = GIT_STR_INIT;
/* Parse with windows-style line endings */
- git_buf_attach_notowned(&unixbuf, string_mailmap, strlen(string_mailmap));
- cl_git_pass(git_buf_lf_to_crlf(&winbuf, &unixbuf));
+ git_str_attach_notowned(&unixbuf, string_mailmap, strlen(string_mailmap));
+ cl_git_pass(git_str_lf_to_crlf(&winbuf, &unixbuf));
cl_git_pass(git_mailmap_from_buffer(&g_mailmap, winbuf.ptr, winbuf.size));
- git_buf_dispose(&winbuf);
+ git_str_dispose(&winbuf);
/* We should have parsed all of the entries */
check_mailmap_entries(g_mailmap, entries, ARRAY_SIZE(entries));
diff --git a/tests/merge/analysis.c b/tests/merge/analysis.c
index 1432a7d11..8c61303e3 100644
--- a/tests/merge/analysis.c
+++ b/tests/merge/analysis.c
@@ -53,28 +53,28 @@ static void analysis_from_branch(
const char *our_branchname,
const char *their_branchname)
{
- git_buf our_refname = GIT_BUF_INIT;
- git_buf their_refname = GIT_BUF_INIT;
+ git_str our_refname = GIT_STR_INIT;
+ git_str their_refname = GIT_STR_INIT;
git_reference *our_ref;
git_reference *their_ref;
git_annotated_commit *their_head;
if (our_branchname != NULL) {
- cl_git_pass(git_buf_printf(&our_refname, "%s%s", GIT_REFS_HEADS_DIR, our_branchname));
- cl_git_pass(git_reference_lookup(&our_ref, repo, git_buf_cstr(&our_refname)));
+ cl_git_pass(git_str_printf(&our_refname, "%s%s", GIT_REFS_HEADS_DIR, our_branchname));
+ cl_git_pass(git_reference_lookup(&our_ref, repo, git_str_cstr(&our_refname)));
} else {
cl_git_pass(git_reference_lookup(&our_ref, repo, GIT_HEAD_FILE));
}
- cl_git_pass(git_buf_printf(&their_refname, "%s%s", GIT_REFS_HEADS_DIR, their_branchname));
+ cl_git_pass(git_str_printf(&their_refname, "%s%s", GIT_REFS_HEADS_DIR, their_branchname));
- cl_git_pass(git_reference_lookup(&their_ref, repo, git_buf_cstr(&their_refname)));
+ cl_git_pass(git_reference_lookup(&their_ref, repo, git_str_cstr(&their_refname)));
cl_git_pass(git_annotated_commit_from_ref(&their_head, repo, their_ref));
cl_git_pass(git_merge_analysis_for_ref(merge_analysis, merge_pref, repo, our_ref, (const git_annotated_commit **)&their_head, 1));
- git_buf_dispose(&our_refname);
- git_buf_dispose(&their_refname);
+ git_str_dispose(&our_refname);
+ git_str_dispose(&their_refname);
git_annotated_commit_free(their_head);
git_reference_free(our_ref);
git_reference_free(their_ref);
@@ -120,15 +120,15 @@ void test_merge_analysis__unborn(void)
{
git_merge_analysis_t merge_analysis;
git_merge_preference_t merge_pref;
- git_buf master = GIT_BUF_INIT;
+ git_str master = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&master, git_repository_path(repo), "refs/heads/master"));
- cl_must_pass(p_unlink(git_buf_cstr(&master)));
+ cl_git_pass(git_str_joinpath(&master, git_repository_path(repo), "refs/heads/master"));
+ cl_must_pass(p_unlink(git_str_cstr(&master)));
analysis_from_branch(&merge_analysis, &merge_pref, NULL, NOFASTFORWARD_BRANCH);
cl_assert_equal_i(GIT_MERGE_ANALYSIS_FASTFORWARD|GIT_MERGE_ANALYSIS_UNBORN, merge_analysis);
- git_buf_dispose(&master);
+ git_str_dispose(&master);
}
void test_merge_analysis__fastforward_with_config_noff(void)
diff --git a/tests/merge/driver.c b/tests/merge/driver.c
index a3fececb4..b7d320cbb 100644
--- a/tests/merge/driver.c
+++ b/tests/merge/driver.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "git2/repository.h"
#include "git2/merge.h"
-#include "buffer.h"
#include "merge.h"
#define TEST_REPO_PATH "merge-resolve"
@@ -71,14 +70,23 @@ static int test_driver_apply(
const char *filter_name,
const git_merge_driver_source *src)
{
+ git_str str = GIT_STR_INIT;
+ int error;
+
GIT_UNUSED(s);
GIT_UNUSED(src);
*path_out = "applied.txt";
*mode_out = GIT_FILEMODE_BLOB;
- return git_buf_printf(merged_out, "This is the `%s` driver.\n",
+ error = git_str_printf(&str, "This is the `%s` driver.\n",
filter_name);
+
+ merged_out->ptr = str.ptr;
+ merged_out->size = str.size;
+ merged_out->reserved = 0;
+
+ return error;
}
static struct test_merge_driver test_driver_custom = {
@@ -117,19 +125,19 @@ static void test_drivers_unregister(void)
static void set_gitattributes_to(const char *driver)
{
- git_buf line = GIT_BUF_INIT;
+ git_str line = GIT_STR_INIT;
if (driver && strcmp(driver, ""))
- git_buf_printf(&line, "automergeable.txt merge=%s\n", driver);
+ git_str_printf(&line, "automergeable.txt merge=%s\n", driver);
else if (driver)
- git_buf_printf(&line, "automergeable.txt merge\n");
+ git_str_printf(&line, "automergeable.txt merge\n");
else
- git_buf_printf(&line, "automergeable.txt -merge\n");
+ git_str_printf(&line, "automergeable.txt -merge\n");
- cl_assert(!git_buf_oom(&line));
+ cl_assert(!git_str_oom(&line));
cl_git_mkfile(TEST_REPO_PATH "/.gitattributes", line.ptr);
- git_buf_dispose(&line);
+ git_str_dispose(&line);
}
static void merge_branch(void)
@@ -172,11 +180,11 @@ void test_merge_driver__shutdown_is_called(void)
test_driver_custom.shutdown = 0;
test_driver_wildcard.initialized = 0;
test_driver_wildcard.shutdown = 0;
-
+
/* run the merge with the custom driver */
set_gitattributes_to("custom");
merge_branch();
-
+
/* unregister the drivers, ensure their shutdown function is called */
test_drivers_unregister();
diff --git a/tests/merge/files.c b/tests/merge/files.c
index 6877f9848..fbc54e11e 100644
--- a/tests/merge/files.c
+++ b/tests/merge/files.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "git2/repository.h"
#include "git2/merge.h"
-#include "buffer.h"
#include "merge.h"
#include "merge_helpers.h"
#include "conflict_data.h"
diff --git a/tests/merge/merge_helpers.c b/tests/merge/merge_helpers.c
index 27f355f35..1eb423ef7 100644
--- a/tests/merge/merge_helpers.c
+++ b/tests/merge/merge_helpers.c
@@ -17,15 +17,15 @@ int merge_trees_from_branches(
git_commit *our_commit, *their_commit, *ancestor_commit = NULL;
git_tree *our_tree, *their_tree, *ancestor_tree = NULL;
git_oid our_oid, their_oid, ancestor_oid;
- git_buf branch_buf = GIT_BUF_INIT;
+ git_str branch_buf = GIT_STR_INIT;
int error;
- git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours_name);
+ git_str_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours_name);
cl_git_pass(git_reference_name_to_id(&our_oid, repo, branch_buf.ptr));
cl_git_pass(git_commit_lookup(&our_commit, repo, &our_oid));
- git_buf_clear(&branch_buf);
- git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs_name);
+ git_str_clear(&branch_buf);
+ git_str_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs_name);
cl_git_pass(git_reference_name_to_id(&their_oid, repo, branch_buf.ptr));
cl_git_pass(git_commit_lookup(&their_commit, repo, &their_oid));
@@ -43,7 +43,7 @@ int merge_trees_from_branches(
error = git_merge_trees(index, repo, ancestor_tree, our_tree, their_tree, opts);
- git_buf_dispose(&branch_buf);
+ git_str_dispose(&branch_buf);
git_tree_free(our_tree);
git_tree_free(their_tree);
git_tree_free(ancestor_tree);
@@ -61,21 +61,21 @@ int merge_commits_from_branches(
{
git_commit *our_commit, *their_commit;
git_oid our_oid, their_oid;
- git_buf branch_buf = GIT_BUF_INIT;
+ git_str branch_buf = GIT_STR_INIT;
int error;
- git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours_name);
+ git_str_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours_name);
cl_git_pass(git_reference_name_to_id(&our_oid, repo, branch_buf.ptr));
cl_git_pass(git_commit_lookup(&our_commit, repo, &our_oid));
- git_buf_clear(&branch_buf);
- git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs_name);
+ git_str_clear(&branch_buf);
+ git_str_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs_name);
cl_git_pass(git_reference_name_to_id(&their_oid, repo, branch_buf.ptr));
cl_git_pass(git_commit_lookup(&their_commit, repo, &their_oid));
error = git_merge_commits(index, repo, our_commit, their_commit, opts);
- git_buf_dispose(&branch_buf);
+ git_str_dispose(&branch_buf);
git_commit_free(our_commit);
git_commit_free(their_commit);
@@ -328,12 +328,12 @@ int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[],
return 1;
}
-int dircount(void *payload, git_buf *pathbuf)
+int dircount(void *payload, git_str *pathbuf)
{
size_t *entries = payload;
- size_t len = git_buf_len(pathbuf);
+ size_t len = git_str_len(pathbuf);
- if (len < 5 || strcmp(pathbuf->ptr + (git_buf_len(pathbuf) - 5), "/.git") != 0)
+ if (len < 5 || strcmp(pathbuf->ptr + (git_str_len(pathbuf) - 5), "/.git") != 0)
(*entries)++;
return 0;
@@ -343,9 +343,9 @@ int merge_test_workdir(git_repository *repo, const struct merge_index_entry expe
{
size_t actual_len = 0, i;
git_oid actual_oid, expected_oid;
- git_buf wd = GIT_BUF_INIT;
+ git_str wd = GIT_STR_INIT;
- git_buf_puts(&wd, repo->workdir);
+ git_str_puts(&wd, repo->workdir);
git_path_direach(&wd, 0, dircount, &actual_len);
if (actual_len != expected_len)
@@ -359,7 +359,7 @@ int merge_test_workdir(git_repository *repo, const struct merge_index_entry expe
return 0;
}
- git_buf_dispose(&wd);
+ git_str_dispose(&wd);
return 1;
}
diff --git a/tests/merge/trees/automerge.c b/tests/merge/trees/automerge.c
index dd26464fb..3bf6c5208 100644
--- a/tests/merge/trees/automerge.c
+++ b/tests/merge/trees/automerge.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "git2/repository.h"
#include "git2/merge.h"
-#include "buffer.h"
#include "merge.h"
#include "futils.h"
#include "../merge_helpers.h"
diff --git a/tests/merge/trees/modeconflict.c b/tests/merge/trees/modeconflict.c
index 32866ea6d..a0521c4e8 100644
--- a/tests/merge/trees/modeconflict.c
+++ b/tests/merge/trees/modeconflict.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "git2/repository.h"
#include "git2/merge.h"
-#include "buffer.h"
#include "merge.h"
#include "../merge_helpers.h"
#include "futils.h"
diff --git a/tests/merge/trees/renames.c b/tests/merge/trees/renames.c
index eef7bc96b..26f6d3306 100644
--- a/tests/merge/trees/renames.c
+++ b/tests/merge/trees/renames.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "git2/repository.h"
#include "git2/merge.h"
-#include "buffer.h"
#include "merge.h"
#include "../merge_helpers.h"
#include "futils.h"
@@ -279,7 +278,7 @@ void test_merge_trees_renames__cache_recomputation(void)
{
git_oid blob, binary, ancestor_oid, theirs_oid, ours_oid;
git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_treebuilder *builder;
git_tree *ancestor_tree, *their_tree, *our_tree;
git_index *index;
@@ -307,9 +306,9 @@ void test_merge_trees_renames__cache_recomputation(void)
*/
cl_git_pass(git_treebuilder_new(&builder, repo, NULL));
for (i = 0; i < 1000; i++) {
- cl_git_pass(git_buf_printf(&path, "%"PRIuZ".txt", i));
+ cl_git_pass(git_str_printf(&path, "%"PRIuZ".txt", i));
cl_git_pass(git_treebuilder_insert(NULL, builder, path.ptr, &blob, GIT_FILEMODE_BLOB));
- git_buf_clear(&path);
+ git_str_clear(&path);
}
cl_git_pass(git_treebuilder_insert(NULL, builder, "original.bin", &binary, GIT_FILEMODE_BLOB));
cl_git_pass(git_treebuilder_write(&ancestor_oid, builder));
@@ -344,7 +343,7 @@ void test_merge_trees_renames__cache_recomputation(void)
cl_git_pass(git_merge_trees(&index, repo, ancestor_tree, our_tree, their_tree, &opts));
git_treebuilder_free(builder);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
git_index_free(index);
git_tree_free(ancestor_tree);
git_tree_free(their_tree);
diff --git a/tests/merge/trees/trivial.c b/tests/merge/trees/trivial.c
index ac4f09f80..dce392c86 100644
--- a/tests/merge/trees/trivial.c
+++ b/tests/merge/trees/trivial.c
@@ -30,15 +30,15 @@ static int merge_trivial(git_index **index, const char *ours, const char *theirs
git_commit *our_commit, *their_commit, *ancestor_commit;
git_tree *our_tree, *their_tree, *ancestor_tree;
git_oid our_oid, their_oid, ancestor_oid;
- git_buf branch_buf = GIT_BUF_INIT;
+ git_str branch_buf = GIT_STR_INIT;
git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
- git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours);
+ git_str_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours);
cl_git_pass(git_reference_name_to_id(&our_oid, repo, branch_buf.ptr));
cl_git_pass(git_commit_lookup(&our_commit, repo, &our_oid));
- git_buf_clear(&branch_buf);
- git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs);
+ git_str_clear(&branch_buf);
+ git_str_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs);
cl_git_pass(git_reference_name_to_id(&their_oid, repo, branch_buf.ptr));
cl_git_pass(git_commit_lookup(&their_commit, repo, &their_oid));
@@ -51,7 +51,7 @@ static int merge_trivial(git_index **index, const char *ours, const char *theirs
cl_git_pass(git_merge_trees(index, repo, ancestor_tree, our_tree, their_tree, &opts));
- git_buf_dispose(&branch_buf);
+ git_str_dispose(&branch_buf);
git_tree_free(our_tree);
git_tree_free(their_tree);
git_tree_free(ancestor_tree);
diff --git a/tests/merge/trees/whitespace.c b/tests/merge/trees/whitespace.c
index ce7703496..9917df506 100644
--- a/tests/merge/trees/whitespace.c
+++ b/tests/merge/trees/whitespace.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "git2/repository.h"
#include "git2/merge.h"
-#include "buffer.h"
#include "merge.h"
#include "../merge_helpers.h"
#include "futils.h"
diff --git a/tests/merge/workdir/dirty.c b/tests/merge/workdir/dirty.c
index 6044bca43..b9c2ad033 100644
--- a/tests/merge/workdir/dirty.c
+++ b/tests/merge/workdir/dirty.c
@@ -1,6 +1,5 @@
#include "clar_libgit2.h"
#include "git2/merge.h"
-#include "buffer.h"
#include "merge.h"
#include "index.h"
#include "../merge_helpers.h"
@@ -109,29 +108,29 @@ static int merge_branch(void)
static void write_files(char *files[])
{
char *filename;
- git_buf path = GIT_BUF_INIT, content = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT, content = GIT_STR_INIT;
size_t i;
for (i = 0, filename = files[i]; filename; filename = files[++i]) {
- git_buf_clear(&path);
- git_buf_clear(&content);
+ git_str_clear(&path);
+ git_str_clear(&content);
- git_buf_printf(&path, "%s/%s", TEST_REPO_PATH, filename);
- git_buf_printf(&content, "This is a dirty file in the working directory!\n\n"
+ git_str_printf(&path, "%s/%s", TEST_REPO_PATH, filename);
+ git_str_printf(&content, "This is a dirty file in the working directory!\n\n"
"It will not be staged! Its filename is %s.\n", filename);
cl_git_mkfile(path.ptr, content.ptr);
}
- git_buf_dispose(&path);
- git_buf_dispose(&content);
+ git_str_dispose(&path);
+ git_str_dispose(&content);
}
static void hack_index(char *files[])
{
char *filename;
struct stat statbuf;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_index_entry *entry;
struct p_timeval times[2];
time_t now;
@@ -153,12 +152,12 @@ static void hack_index(char *files[])
times[1].tv_usec = 0;
for (i = 0, filename = files[i]; filename; filename = files[++i]) {
- git_buf_clear(&path);
+ git_str_clear(&path);
cl_assert(entry = (git_index_entry *)
git_index_get_bypath(repo_index, filename, 0));
- cl_git_pass(git_buf_printf(&path, "%s/%s", TEST_REPO_PATH, filename));
+ cl_git_pass(git_str_printf(&path, "%s/%s", TEST_REPO_PATH, filename));
cl_git_pass(p_utimes(path.ptr, times));
cl_git_pass(p_stat(path.ptr, &statbuf));
@@ -178,7 +177,7 @@ static void hack_index(char *files[])
entry->file_size = (uint32_t)statbuf.st_size;
}
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
static void stage_random_files(char *files[])
@@ -196,7 +195,7 @@ static void stage_content(char *content[])
{
git_reference *head;
git_object *head_object;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
char *filename, *text;
size_t i;
@@ -208,9 +207,9 @@ static void stage_content(char *content[])
filename && text;
filename = content[++i], text = content[++i]) {
- git_buf_clear(&path);
+ git_str_clear(&path);
- cl_git_pass(git_buf_printf(&path, "%s/%s", TEST_REPO_PATH, filename));
+ cl_git_pass(git_str_printf(&path, "%s/%s", TEST_REPO_PATH, filename));
cl_git_mkfile(path.ptr, text);
cl_git_pass(git_index_add_bypath(repo_index, filename));
@@ -218,7 +217,7 @@ static void stage_content(char *content[])
git_object_free(head_object);
git_reference_free(head);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
static int merge_dirty_files(char *dirty_files[])
diff --git a/tests/merge/workdir/recursive.c b/tests/merge/workdir/recursive.c
index e7dc267e4..7669e1b1a 100644
--- a/tests/merge/workdir/recursive.c
+++ b/tests/merge/workdir/recursive.c
@@ -23,7 +23,7 @@ void test_merge_workdir_recursive__writes_conflict_with_virtual_base(void)
{
git_index *index;
git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
- git_buf conflicting_buf = GIT_BUF_INIT;
+ git_str conflicting_buf = GIT_STR_INIT;
struct merge_index_entry merge_index_entries[] = {
{ 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" },
@@ -46,7 +46,7 @@ void test_merge_workdir_recursive__writes_conflict_with_virtual_base(void)
cl_assert_equal_s(CONFLICTING_RECURSIVE_F1_TO_F2, conflicting_buf.ptr);
git_index_free(index);
- git_buf_dispose(&conflicting_buf);
+ git_str_dispose(&conflicting_buf);
}
void test_merge_workdir_recursive__conflicting_merge_base_with_diff3(void)
@@ -54,7 +54,7 @@ void test_merge_workdir_recursive__conflicting_merge_base_with_diff3(void)
git_index *index;
git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
- git_buf conflicting_buf = GIT_BUF_INIT;
+ git_str conflicting_buf = GIT_STR_INIT;
struct merge_index_entry merge_index_entries[] = {
{ 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" },
@@ -80,5 +80,5 @@ void test_merge_workdir_recursive__conflicting_merge_base_with_diff3(void)
cl_assert_equal_s(CONFLICTING_RECURSIVE_H2_TO_H1_WITH_DIFF3, conflicting_buf.ptr);
git_index_free(index);
- git_buf_dispose(&conflicting_buf);
+ git_str_dispose(&conflicting_buf);
}
diff --git a/tests/merge/workdir/renames.c b/tests/merge/workdir/renames.c
index e8cd333af..1b5128cf1 100644
--- a/tests/merge/workdir/renames.c
+++ b/tests/merge/workdir/renames.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "git2/repository.h"
#include "git2/merge.h"
-#include "buffer.h"
#include "merge.h"
#include "../merge_helpers.h"
#include "futils.h"
diff --git a/tests/merge/workdir/setup.c b/tests/merge/workdir/setup.c
index 0b85f2712..fe33e21f2 100644
--- a/tests/merge/workdir/setup.c
+++ b/tests/merge/workdir/setup.c
@@ -46,29 +46,29 @@ void test_merge_workdir_setup__cleanup(void)
static bool test_file_contents(const char *filename, const char *expected)
{
- git_buf file_path_buf = GIT_BUF_INIT, file_buf = GIT_BUF_INIT;
+ git_str file_path_buf = GIT_STR_INIT, file_buf = GIT_STR_INIT;
bool equals;
- git_buf_joinpath(&file_path_buf, git_repository_path(repo), filename);
+ git_str_joinpath(&file_path_buf, git_repository_path(repo), filename);
cl_git_pass(git_futils_readbuffer(&file_buf, file_path_buf.ptr));
equals = (strcmp(file_buf.ptr, expected) == 0);
- git_buf_dispose(&file_path_buf);
- git_buf_dispose(&file_buf);
+ git_str_dispose(&file_path_buf);
+ git_str_dispose(&file_buf);
return equals;
}
static void write_file_contents(const char *filename, const char *output)
{
- git_buf file_path_buf = GIT_BUF_INIT;
+ git_str file_path_buf = GIT_STR_INIT;
- git_buf_joinpath(&file_path_buf, git_repository_path(repo),
+ git_str_joinpath(&file_path_buf, git_repository_path(repo),
filename);
cl_git_rewritefile(file_path_buf.ptr, output);
- git_buf_dispose(&file_path_buf);
+ git_str_dispose(&file_path_buf);
}
/* git merge --no-ff octo1 */
@@ -464,41 +464,41 @@ static int create_remote_tracking_branch(const char *branch_name, const char *oi
{
int error = 0;
- git_buf remotes_path = GIT_BUF_INIT,
- origin_path = GIT_BUF_INIT,
- filename = GIT_BUF_INIT,
- data = GIT_BUF_INIT;
+ git_str remotes_path = GIT_STR_INIT,
+ origin_path = GIT_STR_INIT,
+ filename = GIT_STR_INIT,
+ data = GIT_STR_INIT;
- if ((error = git_buf_puts(&remotes_path, git_repository_path(repo))) < 0 ||
- (error = git_buf_puts(&remotes_path, GIT_REFS_REMOTES_DIR)) < 0)
+ if ((error = git_str_puts(&remotes_path, git_repository_path(repo))) < 0 ||
+ (error = git_str_puts(&remotes_path, GIT_REFS_REMOTES_DIR)) < 0)
goto done;
- if (!git_path_exists(git_buf_cstr(&remotes_path)) &&
- (error = p_mkdir(git_buf_cstr(&remotes_path), 0777)) < 0)
+ if (!git_path_exists(git_str_cstr(&remotes_path)) &&
+ (error = p_mkdir(git_str_cstr(&remotes_path), 0777)) < 0)
goto done;
- if ((error = git_buf_puts(&origin_path, git_buf_cstr(&remotes_path))) < 0 ||
- (error = git_buf_puts(&origin_path, "origin")) < 0)
+ if ((error = git_str_puts(&origin_path, git_str_cstr(&remotes_path))) < 0 ||
+ (error = git_str_puts(&origin_path, "origin")) < 0)
goto done;
- if (!git_path_exists(git_buf_cstr(&origin_path)) &&
- (error = p_mkdir(git_buf_cstr(&origin_path), 0777)) < 0)
+ if (!git_path_exists(git_str_cstr(&origin_path)) &&
+ (error = p_mkdir(git_str_cstr(&origin_path), 0777)) < 0)
goto done;
- if ((error = git_buf_puts(&filename, git_buf_cstr(&origin_path))) < 0 ||
- (error = git_buf_puts(&filename, "/")) < 0 ||
- (error = git_buf_puts(&filename, branch_name)) < 0 ||
- (error = git_buf_puts(&data, oid_str)) < 0 ||
- (error = git_buf_puts(&data, "\n")) < 0)
+ if ((error = git_str_puts(&filename, git_str_cstr(&origin_path))) < 0 ||
+ (error = git_str_puts(&filename, "/")) < 0 ||
+ (error = git_str_puts(&filename, branch_name)) < 0 ||
+ (error = git_str_puts(&data, oid_str)) < 0 ||
+ (error = git_str_puts(&data, "\n")) < 0)
goto done;
- cl_git_rewritefile(git_buf_cstr(&filename), git_buf_cstr(&data));
+ cl_git_rewritefile(git_str_cstr(&filename), git_str_cstr(&data));
done:
- git_buf_dispose(&remotes_path);
- git_buf_dispose(&origin_path);
- git_buf_dispose(&filename);
- git_buf_dispose(&data);
+ git_str_dispose(&remotes_path);
+ git_str_dispose(&origin_path);
+ git_str_dispose(&filename);
+ git_str_dispose(&data);
return error;
}
diff --git a/tests/merge/workdir/simple.c b/tests/merge/workdir/simple.c
index 6b4e17492..6c4cf7e3c 100644
--- a/tests/merge/workdir/simple.c
+++ b/tests/merge/workdir/simple.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "git2/repository.h"
#include "git2/merge.h"
-#include "buffer.h"
#include "merge.h"
#include "../merge_helpers.h"
#include "../conflict_data.h"
@@ -126,7 +125,7 @@ void test_merge_workdir_simple__automerge(void)
{
git_index *index;
const git_index_entry *entry;
- git_buf automergeable_buf = GIT_BUF_INIT;
+ git_str automergeable_buf = GIT_STR_INIT;
struct merge_index_entry merge_index_entries[] = {
ADDED_IN_MASTER_INDEX_ENTRY,
@@ -155,7 +154,7 @@ void test_merge_workdir_simple__automerge(void)
cl_git_pass(git_futils_readbuffer(&automergeable_buf,
TEST_REPO_PATH "/automergeable.txt"));
cl_assert(strcmp(automergeable_buf.ptr, AUTOMERGEABLE_MERGED_FILE) == 0);
- git_buf_dispose(&automergeable_buf);
+ git_str_dispose(&automergeable_buf);
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
@@ -202,7 +201,7 @@ void test_merge_workdir_simple__automerge_crlf(void)
#ifdef GIT_WIN32
git_index *index;
const git_index_entry *entry;
- git_buf automergeable_buf = GIT_BUF_INIT;
+ git_str automergeable_buf = GIT_STR_INIT;
struct merge_index_entry merge_index_entries[] = {
ADDED_IN_MASTER_INDEX_ENTRY,
@@ -230,7 +229,7 @@ void test_merge_workdir_simple__automerge_crlf(void)
cl_git_pass(git_futils_readbuffer(&automergeable_buf,
TEST_REPO_PATH "/automergeable.txt"));
cl_assert(strcmp(automergeable_buf.ptr, AUTOMERGEABLE_MERGED_FILE_CRLF) == 0);
- git_buf_dispose(&automergeable_buf);
+ git_str_dispose(&automergeable_buf);
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
@@ -246,7 +245,7 @@ void test_merge_workdir_simple__automerge_crlf(void)
void test_merge_workdir_simple__mergefile(void)
{
- git_buf conflicting_buf = GIT_BUF_INIT, mergemsg_buf = GIT_BUF_INIT;
+ git_str conflicting_buf = GIT_STR_INIT, mergemsg_buf = GIT_STR_INIT;
struct merge_index_entry merge_index_entries[] = {
ADDED_IN_MASTER_INDEX_ENTRY,
@@ -276,13 +275,13 @@ void test_merge_workdir_simple__mergefile(void)
cl_assert(strcmp(conflicting_buf.ptr, CONFLICTING_MERGE_FILE) == 0);
cl_git_pass(git_futils_readbuffer(&mergemsg_buf,
TEST_REPO_PATH "/.git/MERGE_MSG"));
- cl_assert(strcmp(git_buf_cstr(&mergemsg_buf),
+ cl_assert(strcmp(git_str_cstr(&mergemsg_buf),
"Merge commit '7cb63eed597130ba4abb87b3e544b85021905520'\n" \
"\n" \
"Conflicts:\n" \
"\tconflicting.txt\n") == 0);
- git_buf_dispose(&conflicting_buf);
- git_buf_dispose(&mergemsg_buf);
+ git_str_dispose(&conflicting_buf);
+ git_str_dispose(&mergemsg_buf);
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
@@ -290,7 +289,7 @@ void test_merge_workdir_simple__mergefile(void)
void test_merge_workdir_simple__diff3(void)
{
- git_buf conflicting_buf = GIT_BUF_INIT;
+ git_str conflicting_buf = GIT_STR_INIT;
struct merge_index_entry merge_index_entries[] = {
ADDED_IN_MASTER_INDEX_ENTRY,
@@ -318,7 +317,7 @@ void test_merge_workdir_simple__diff3(void)
cl_git_pass(git_futils_readbuffer(&conflicting_buf,
TEST_REPO_PATH "/conflicting.txt"));
cl_assert(strcmp(conflicting_buf.ptr, CONFLICTING_DIFF3_FILE) == 0);
- git_buf_dispose(&conflicting_buf);
+ git_str_dispose(&conflicting_buf);
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
@@ -326,7 +325,7 @@ void test_merge_workdir_simple__diff3(void)
void test_merge_workdir_simple__union(void)
{
- git_buf conflicting_buf = GIT_BUF_INIT;
+ git_str conflicting_buf = GIT_STR_INIT;
struct merge_index_entry merge_index_entries[] = {
ADDED_IN_MASTER_INDEX_ENTRY,
@@ -353,7 +352,7 @@ void test_merge_workdir_simple__union(void)
cl_git_pass(git_futils_readbuffer(&conflicting_buf,
TEST_REPO_PATH "/conflicting.txt"));
cl_assert(strcmp(conflicting_buf.ptr, CONFLICTING_UNION_FILE) == 0);
- git_buf_dispose(&conflicting_buf);
+ git_str_dispose(&conflicting_buf);
cl_assert(merge_test_index(repo_index, merge_index_entries, 6));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 4));
@@ -361,7 +360,7 @@ void test_merge_workdir_simple__union(void)
void test_merge_workdir_simple__gitattributes_union(void)
{
- git_buf conflicting_buf = GIT_BUF_INIT;
+ git_str conflicting_buf = GIT_STR_INIT;
struct merge_index_entry merge_index_entries[] = {
ADDED_IN_MASTER_INDEX_ENTRY,
@@ -389,7 +388,7 @@ void test_merge_workdir_simple__gitattributes_union(void)
cl_git_pass(git_futils_readbuffer(&conflicting_buf,
TEST_REPO_PATH "/conflicting.txt"));
cl_assert(strcmp(conflicting_buf.ptr, CONFLICTING_UNION_FILE) == 0);
- git_buf_dispose(&conflicting_buf);
+ git_str_dispose(&conflicting_buf);
cl_assert(merge_test_index(repo_index, merge_index_entries, 6));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 4));
@@ -398,7 +397,7 @@ void test_merge_workdir_simple__gitattributes_union(void)
void test_merge_workdir_simple__diff3_from_config(void)
{
git_config *config;
- git_buf conflicting_buf = GIT_BUF_INIT;
+ git_str conflicting_buf = GIT_STR_INIT;
struct merge_index_entry merge_index_entries[] = {
ADDED_IN_MASTER_INDEX_ENTRY,
@@ -429,7 +428,7 @@ void test_merge_workdir_simple__diff3_from_config(void)
cl_git_pass(git_futils_readbuffer(&conflicting_buf,
TEST_REPO_PATH "/conflicting.txt"));
cl_assert(strcmp(conflicting_buf.ptr, CONFLICTING_DIFF3_FILE) == 0);
- git_buf_dispose(&conflicting_buf);
+ git_str_dispose(&conflicting_buf);
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
@@ -440,7 +439,7 @@ void test_merge_workdir_simple__diff3_from_config(void)
void test_merge_workdir_simple__merge_overrides_config(void)
{
git_config *config;
- git_buf conflicting_buf = GIT_BUF_INIT;
+ git_str conflicting_buf = GIT_STR_INIT;
struct merge_index_entry merge_index_entries[] = {
ADDED_IN_MASTER_INDEX_ENTRY,
@@ -471,7 +470,7 @@ void test_merge_workdir_simple__merge_overrides_config(void)
cl_git_pass(git_futils_readbuffer(&conflicting_buf,
TEST_REPO_PATH "/conflicting.txt"));
cl_assert(strcmp(conflicting_buf.ptr, CONFLICTING_MERGE_FILE) == 0);
- git_buf_dispose(&conflicting_buf);
+ git_str_dispose(&conflicting_buf);
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
diff --git a/tests/merge/workdir/submodules.c b/tests/merge/workdir/submodules.c
index 35280e61e..5117be789 100644
--- a/tests/merge/workdir/submodules.c
+++ b/tests/merge/workdir/submodules.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "git2/repository.h"
#include "git2/merge.h"
-#include "buffer.h"
#include "merge.h"
#include "../merge_helpers.h"
diff --git a/tests/merge/workdir/trivial.c b/tests/merge/workdir/trivial.c
index c5bb7030e..fe8374851 100644
--- a/tests/merge/workdir/trivial.c
+++ b/tests/merge/workdir/trivial.c
@@ -30,26 +30,26 @@ void test_merge_workdir_trivial__cleanup(void)
static int merge_trivial(const char *ours, const char *theirs)
{
- git_buf branch_buf = GIT_BUF_INIT;
+ git_str branch_buf = GIT_STR_INIT;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_reference *our_ref, *their_ref;
git_annotated_commit *their_heads[1];
checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
- git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours);
+ git_str_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours);
cl_git_pass(git_reference_symbolic_create(&our_ref, repo, "HEAD", branch_buf.ptr, 1, NULL));
cl_git_pass(git_checkout_head(repo, &checkout_opts));
- git_buf_clear(&branch_buf);
- git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs);
+ git_str_clear(&branch_buf);
+ git_str_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs);
cl_git_pass(git_reference_lookup(&their_ref, repo, branch_buf.ptr));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, their_ref));
cl_git_pass(git_merge(repo, (const git_annotated_commit **)their_heads, 1, NULL, NULL));
- git_buf_dispose(&branch_buf);
+ git_str_dispose(&branch_buf);
git_reference_free(our_ref);
git_reference_free(their_ref);
git_annotated_commit_free(their_heads[0]);
diff --git a/tests/message/trailer.c b/tests/message/trailer.c
index 9cc83de72..919e10a49 100644
--- a/tests/message/trailer.c
+++ b/tests/message/trailer.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "message.h"
static void assert_trailers(const char *message, git_message_trailer *trailers)
{
diff --git a/tests/network/fetchlocal.c b/tests/network/fetchlocal.c
index 13f03100b..302d1544c 100644
--- a/tests/network/fetchlocal.c
+++ b/tests/network/fetchlocal.c
@@ -1,6 +1,5 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "path.h"
#include "remote.h"
diff --git a/tests/network/remote/defaultbranch.c b/tests/network/remote/defaultbranch.c
index b0417f764..a7c0d81f6 100644
--- a/tests/network/remote/defaultbranch.c
+++ b/tests/network/remote/defaultbranch.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "refspec.h"
#include "remote.h"
diff --git a/tests/network/remote/local.c b/tests/network/remote/local.c
index 16cce6777..f174044d7 100644
--- a/tests/network/remote/local.c
+++ b/tests/network/remote/local.c
@@ -1,11 +1,10 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "path.h"
#include "posix.h"
#include "git2/sys/repository.h"
static git_repository *repo;
-static git_buf file_path_buf = GIT_BUF_INIT;
+static git_str file_path_buf = GIT_STR_INIT;
static git_remote *remote;
static char *push_refspec_strings[] = {
@@ -25,7 +24,7 @@ void test_network_remote_local__initialize(void)
void test_network_remote_local__cleanup(void)
{
- git_buf_dispose(&file_path_buf);
+ git_str_dispose(&file_path_buf);
git_remote_free(remote);
remote = NULL;
@@ -38,9 +37,9 @@ void test_network_remote_local__cleanup(void)
static void connect_to_local_repository(const char *local_repository)
{
- git_buf_sets(&file_path_buf, cl_git_path_url(local_repository));
+ git_str_sets(&file_path_buf, cl_git_path_url(local_repository));
- cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf)));
+ cl_git_pass(git_remote_create_anonymous(&remote, repo, git_str_cstr(&file_path_buf)));
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL));
}
@@ -70,9 +69,9 @@ void test_network_remote_local__retrieve_advertised_before_connect(void)
const git_remote_head **refs;
size_t refs_len = 0;
- git_buf_sets(&file_path_buf, cl_git_path_url(cl_fixture("testrepo.git")));
+ git_str_sets(&file_path_buf, cl_git_path_url(cl_fixture("testrepo.git")));
- cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf)));
+ cl_git_pass(git_remote_create_anonymous(&remote, repo, git_str_cstr(&file_path_buf)));
cl_git_fail(git_remote_ls(&refs, &refs_len, remote));
}
@@ -472,10 +471,10 @@ void test_network_remote_local__anonymous_remote_inmemory_repo(void)
git_repository *inmemory;
git_remote *remote;
- git_buf_sets(&file_path_buf, cl_git_path_url(cl_fixture("testrepo.git")));
+ git_str_sets(&file_path_buf, cl_git_path_url(cl_fixture("testrepo.git")));
cl_git_pass(git_repository_new(&inmemory));
- cl_git_pass(git_remote_create_anonymous(&remote, inmemory, git_buf_cstr(&file_path_buf)));
+ cl_git_pass(git_remote_create_anonymous(&remote, inmemory, git_str_cstr(&file_path_buf)));
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL));
cl_assert(git_remote_connected(remote));
git_remote_disconnect(remote);
diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c
index ed6a89075..79c4f39fa 100644
--- a/tests/network/remote/remotes.c
+++ b/tests/network/remote/remotes.c
@@ -1,6 +1,5 @@
#include "clar_libgit2.h"
#include "config/config_helpers.h"
-#include "buffer.h"
#include "refspec.h"
#include "remote.h"
@@ -28,7 +27,7 @@ void test_network_remote_remotes__cleanup(void)
void test_network_remote_remotes__parsing(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
git_remote *_remote2 = NULL;
cl_assert_equal_s(git_remote_name(_remote), "test");
@@ -53,7 +52,7 @@ void test_network_remote_remotes__parsing(void)
cl_assert_equal_s(url.ptr, "git://github.com/libgit2/pushlibgit2");
git_remote_free(_remote2);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
static int remote_ready_callback(git_remote *remote, int direction, void *payload)
@@ -79,7 +78,7 @@ static int remote_ready_callback(git_remote *remote, int direction, void *payloa
void test_network_remote_remotes__remote_ready(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
callbacks.remote_ready = remote_ready_callback;
@@ -95,29 +94,31 @@ void test_network_remote_remotes__remote_ready(void)
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_PUSH, &callbacks));
cl_assert_equal_s(url.ptr, "push_url");
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
#ifndef GIT_DEPRECATE_HARD
static int urlresolve_callback(git_buf *url_resolved, const char *url, int direction, void *payload)
{
+ int error = -1;
+
cl_assert(strcmp(url, "git://github.com/libgit2/libgit2") == 0);
cl_assert(strcmp(payload, "payload") == 0);
cl_assert(url_resolved->size == 0);
if (direction == GIT_DIRECTION_PUSH)
- git_buf_sets(url_resolved, "pushresolve");
+ error = git_buf_set(url_resolved, "pushresolve", strlen("pushresolve") + 1);
if (direction == GIT_DIRECTION_FETCH)
- git_buf_sets(url_resolved, "fetchresolve");
+ error = git_buf_set(url_resolved, "fetchresolve", strlen("fetchresolve") + 1);
- return GIT_OK;
+ return error;
}
#endif
void test_network_remote_remotes__urlresolve(void)
{
#ifndef GIT_DEPRECATE_HARD
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
callbacks.resolve_url = urlresolve_callback;
@@ -133,7 +134,7 @@ void test_network_remote_remotes__urlresolve(void)
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_PUSH, &callbacks));
cl_assert_equal_s(url.ptr, "pushresolve");
- git_buf_dispose(&url);
+ git_str_dispose(&url);
#endif
}
@@ -151,7 +152,7 @@ static int urlresolve_passthrough_callback(git_buf *url_resolved, const char *ur
void test_network_remote_remotes__urlresolve_passthrough(void)
{
#ifndef GIT_DEPRECATE_HARD
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
const char *orig_url = "git://github.com/libgit2/libgit2";
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
@@ -167,13 +168,13 @@ void test_network_remote_remotes__urlresolve_passthrough(void)
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_PUSH, &callbacks));
cl_assert_equal_s(url.ptr, orig_url);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
#endif
}
void test_network_remote_remotes__instance_url(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
const char *orig_url = "git://github.com/libgit2/libgit2";
cl_assert_equal_s(git_remote_name(_remote), "test");
@@ -181,11 +182,11 @@ void test_network_remote_remotes__instance_url(void)
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_FETCH, NULL));
cl_assert_equal_s(url.ptr, orig_url);
- git_buf_clear(&url);
+ git_str_clear(&url);
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_PUSH, NULL));
cl_assert_equal_s(url.ptr, orig_url);
- git_buf_clear(&url);
+ git_str_clear(&url);
/* Setting the instance url updates the fetch and push URLs */
git_remote_set_instance_url(_remote, "https://github.com/new/remote/url");
@@ -194,11 +195,11 @@ void test_network_remote_remotes__instance_url(void)
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_FETCH, NULL));
cl_assert_equal_s(url.ptr, "https://github.com/new/remote/url");
- git_buf_clear(&url);
+ git_str_clear(&url);
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_PUSH, NULL));
cl_assert_equal_s(url.ptr, "https://github.com/new/remote/url");
- git_buf_clear(&url);
+ git_str_clear(&url);
/* Setting the instance push url updates only the push URL */
git_remote_set_instance_pushurl(_remote, "https://github.com/new/push/url");
@@ -207,13 +208,13 @@ void test_network_remote_remotes__instance_url(void)
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_FETCH, NULL));
cl_assert_equal_s(url.ptr, "https://github.com/new/remote/url");
- git_buf_clear(&url);
+ git_str_clear(&url);
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_PUSH, NULL));
cl_assert_equal_s(url.ptr, "https://github.com/new/push/url");
- git_buf_clear(&url);
+ git_str_clear(&url);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
void test_network_remote_remotes__pushurl(void)
diff --git a/tests/notes/notes.c b/tests/notes/notes.c
index af9686790..dd9ad1e4b 100644
--- a/tests/notes/notes.c
+++ b/tests/notes/notes.c
@@ -1,7 +1,5 @@
#include "clar_libgit2.h"
-#include "buffer.h"
-
static git_repository *_repo;
static git_signature *_sig;
@@ -282,7 +280,7 @@ void test_notes_notes__inserting_a_note_without_passing_a_namespace_uses_the_def
create_note(&note_oid, NULL, "08b041783f40edfe12bb406c9c9a8a040177c125", "hello world\n");
cl_git_pass(git_note_read(&note, _repo, NULL, &target_oid));
- cl_git_pass(git_note_read(&default_namespace_note, _repo, git_buf_cstr(&default_ref), &target_oid));
+ cl_git_pass(git_note_read(&default_namespace_note, _repo, default_ref.ptr, &target_oid));
assert_note_equal(note, "hello world\n", &note_oid);
assert_note_equal(default_namespace_note, "hello world\n", &note_oid);
diff --git a/tests/notes/notesref.c b/tests/notes/notesref.c
index 3bcb05f20..6ba324c76 100644
--- a/tests/notes/notesref.c
+++ b/tests/notes/notesref.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "notes.h"
-#include "buffer.h"
static git_repository *_repo;
static git_note *_note;
@@ -57,7 +56,7 @@ void test_notes_notesref__config_corenotesref(void)
cl_git_pass(git_note_default_ref(&default_ref, _repo));
cl_assert_equal_s("refs/notes/mydefaultnotesref", default_ref.ptr);
- git_buf_clear(&default_ref);
+ git_buf_dispose(&default_ref);
cl_git_pass(git_config_delete_entry(_cfg, "core.notesRef"));
diff --git a/tests/object/blob/filter.c b/tests/object/blob/filter.c
index a8e3d3097..00b553e71 100644
--- a/tests/object/blob/filter.c
+++ b/tests/object/blob/filter.c
@@ -24,7 +24,7 @@ static off64_t g_crlf_raw_len[CRLF_NUM_TEST_OBJECTS] = {
static git_oid g_crlf_oids[CRLF_NUM_TEST_OBJECTS];
-static git_buf g_crlf_filtered[CRLF_NUM_TEST_OBJECTS] = {
+static git_str g_crlf_filtered[CRLF_NUM_TEST_OBJECTS] = {
{ "", 0, 0 },
{ "foo\nbar\n", 0, 8 },
{ "foo\rbar\r", 0, 8 },
@@ -36,16 +36,16 @@ static git_buf g_crlf_filtered[CRLF_NUM_TEST_OBJECTS] = {
{ "\xFE\xFF\x00T\x00h\x00i\x00s\x00!", 0, 12 }
};
-static git_buf_text_stats g_crlf_filtered_stats[CRLF_NUM_TEST_OBJECTS] = {
+static git_str_text_stats g_crlf_filtered_stats[CRLF_NUM_TEST_OBJECTS] = {
{ 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 2, 0, 6, 0 },
{ 0, 0, 2, 0, 0, 6, 0 },
{ 0, 0, 2, 2, 2, 6, 0 },
{ 0, 0, 4, 4, 1, 31, 0 },
{ 0, 1, 1, 2, 1, 9, 5 },
- { GIT_BUF_BOM_UTF8, 0, 0, 1, 0, 16, 0 },
- { GIT_BUF_BOM_UTF8, 0, 2, 2, 2, 27, 0 },
- { GIT_BUF_BOM_UTF16_BE, 5, 0, 0, 0, 7, 5 },
+ { GIT_STR_BOM_UTF8, 0, 0, 1, 0, 16, 0 },
+ { GIT_STR_BOM_UTF8, 0, 2, 2, 2, 27, 0 },
+ { GIT_STR_BOM_UTF16_BE, 5, 0, 0, 0, 7, 5 },
};
void test_object_blob_filter__initialize(void)
@@ -90,19 +90,19 @@ void test_object_blob_filter__stats(void)
{
int i;
git_blob *blob;
- git_buf buf = GIT_BUF_INIT;
- git_buf_text_stats stats;
+ git_str buf = GIT_STR_INIT;
+ git_str_text_stats stats;
for (i = 0; i < CRLF_NUM_TEST_OBJECTS; i++) {
cl_git_pass(git_blob_lookup(&blob, g_repo, &g_crlf_oids[i]));
cl_git_pass(git_blob__getbuf(&buf, blob));
- git_buf_gather_text_stats(&stats, &buf, false);
+ git_str_gather_text_stats(&stats, &buf, false);
cl_assert_equal_i(
0, memcmp(&g_crlf_filtered_stats[i], &stats, sizeof(stats)));
git_blob_free(blob);
}
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
void test_object_blob_filter__to_odb(void)
diff --git a/tests/object/blob/fromstream.c b/tests/object/blob/fromstream.c
index df229f98f..60ff3991b 100644
--- a/tests/object/blob/fromstream.c
+++ b/tests/object/blob/fromstream.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "posix.h"
#include "path.h"
#include "futils.h"
@@ -48,15 +47,15 @@ void test_object_blob_fromstream__multiple_write(void)
static void write_attributes(git_repository *repo)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&buf, git_repository_path(repo), "info"));
- cl_git_pass(git_buf_joinpath(&buf, git_buf_cstr(&buf), "attributes"));
+ cl_git_pass(git_str_joinpath(&buf, git_repository_path(repo), "info"));
+ cl_git_pass(git_str_joinpath(&buf, git_str_cstr(&buf), "attributes"));
- cl_git_pass(git_futils_mkpath2file(git_buf_cstr(&buf), 0777));
- cl_git_rewritefile(git_buf_cstr(&buf), GITATTR);
+ cl_git_pass(git_futils_mkpath2file(git_str_cstr(&buf), 0777));
+ cl_git_rewritefile(git_str_cstr(&buf), GITATTR);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
static void assert_named_chunked_blob(const char *expected_sha, const char *fake_name)
diff --git a/tests/object/blob/write.c b/tests/object/blob/write.c
index 9a18d7cd4..802467498 100644
--- a/tests/object/blob/write.c
+++ b/tests/object/blob/write.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "posix.h"
#include "path.h"
#include "futils.h"
@@ -38,32 +37,32 @@ void test_object_blob_write__can_create_a_blob_in_a_standard_repo_from_a_file_lo
void test_object_blob_write__can_create_a_blob_in_a_standard_repo_from_a_absolute_filepath_pointing_outside_of_the_working_directory(void)
{
- git_buf full_path = GIT_BUF_INIT;
+ git_str full_path = GIT_STR_INIT;
repo = cl_git_sandbox_init(WORKDIR);
cl_must_pass(p_mkdir(ELSEWHERE, 0777));
cl_must_pass(git_path_prettify_dir(&full_path, ELSEWHERE, NULL));
- cl_must_pass(git_buf_puts(&full_path, "test.txt"));
+ cl_must_pass(git_str_puts(&full_path, "test.txt"));
- assert_blob_creation(ELSEWHERE "/test.txt", git_buf_cstr(&full_path), &git_blob_create_from_disk);
+ assert_blob_creation(ELSEWHERE "/test.txt", git_str_cstr(&full_path), &git_blob_create_from_disk);
- git_buf_dispose(&full_path);
+ git_str_dispose(&full_path);
cl_must_pass(git_futils_rmdir_r(ELSEWHERE, NULL, GIT_RMDIR_REMOVE_FILES));
}
void test_object_blob_write__can_create_a_blob_in_a_bare_repo_from_a_absolute_filepath(void)
{
- git_buf full_path = GIT_BUF_INIT;
+ git_str full_path = GIT_STR_INIT;
repo = cl_git_sandbox_init(BARE_REPO);
cl_must_pass(p_mkdir(ELSEWHERE, 0777));
cl_must_pass(git_path_prettify_dir(&full_path, ELSEWHERE, NULL));
- cl_must_pass(git_buf_puts(&full_path, "test.txt"));
+ cl_must_pass(git_str_puts(&full_path, "test.txt"));
- assert_blob_creation(ELSEWHERE "/test.txt", git_buf_cstr(&full_path), &git_blob_create_from_disk);
+ assert_blob_creation(ELSEWHERE "/test.txt", git_str_cstr(&full_path), &git_blob_create_from_disk);
- git_buf_dispose(&full_path);
+ git_str_dispose(&full_path);
cl_must_pass(git_futils_rmdir_r(ELSEWHERE, NULL, GIT_RMDIR_REMOVE_FILES));
}
diff --git a/tests/object/commit/commitstagedfile.c b/tests/object/commit/commitstagedfile.c
index f7ff05c01..7322a4e86 100644
--- a/tests/object/commit/commitstagedfile.c
+++ b/tests/object/commit/commitstagedfile.c
@@ -25,7 +25,7 @@ void test_object_commit_commitstagedfile__generate_predictable_object_ids(void)
git_oid expected_blob_oid, tree_oid, expected_tree_oid, commit_oid, expected_commit_oid;
git_signature *signature;
git_tree *tree;
- git_buf buffer;
+ git_buf buffer = GIT_BUF_INIT;
/*
* The test below replicates the following git scenario
@@ -111,7 +111,6 @@ void test_object_commit_commitstagedfile__generate_predictable_object_ids(void)
cl_git_pass(git_signature_new(&signature, "nulltoken", "emeric.fermas@gmail.com", 1323847743, 60));
cl_git_pass(git_tree_lookup(&tree, repo, &tree_oid));
- memset(&buffer, 0, sizeof(git_buf));
cl_git_pass(git_message_prettify(&buffer, "Initial commit", 0, '#'));
cl_git_pass(git_commit_create_v(
diff --git a/tests/object/lookup.c b/tests/object/lookup.c
index 2458537fc..a7b1ceeb4 100644
--- a/tests/object/lookup.c
+++ b/tests/object/lookup.c
@@ -66,13 +66,13 @@ void test_object_lookup__lookup_corrupt_object_returns_error(void)
{
const char *commit = "8e73b769e97678d684b809b163bebdae2911720f",
*file = "objects/8e/73b769e97678d684b809b163bebdae2911720f";
- git_buf path = GIT_BUF_INIT, contents = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT, contents = GIT_STR_INIT;
git_oid oid;
git_object *object;
size_t i;
cl_git_pass(git_oid_fromstr(&oid, commit));
- cl_git_pass(git_buf_joinpath(&path, git_repository_path(g_repo), file));
+ cl_git_pass(git_str_joinpath(&path, git_repository_path(g_repo), file));
cl_git_pass(git_futils_readbuffer(&contents, path.ptr));
/* Corrupt and try to read the object */
@@ -88,8 +88,8 @@ void test_object_lookup__lookup_corrupt_object_returns_error(void)
cl_git_pass(git_object_lookup(&object, g_repo, &oid, GIT_OBJECT_COMMIT));
git_object_free(object);
- git_buf_dispose(&path);
- git_buf_dispose(&contents);
+ git_str_dispose(&path);
+ git_str_dispose(&contents);
}
void test_object_lookup__lookup_object_with_wrong_hash_returns_error(void)
@@ -97,15 +97,15 @@ void test_object_lookup__lookup_object_with_wrong_hash_returns_error(void)
const char *oldloose = "objects/8e/73b769e97678d684b809b163bebdae2911720f",
*newloose = "objects/8e/73b769e97678d684b809b163bebdae2911720e",
*commit = "8e73b769e97678d684b809b163bebdae2911720e";
- git_buf oldpath = GIT_BUF_INIT, newpath = GIT_BUF_INIT;
+ git_str oldpath = GIT_STR_INIT, newpath = GIT_STR_INIT;
git_object *object;
git_oid oid;
cl_git_pass(git_oid_fromstr(&oid, commit));
/* Copy object to another location with wrong hash */
- cl_git_pass(git_buf_joinpath(&oldpath, git_repository_path(g_repo), oldloose));
- cl_git_pass(git_buf_joinpath(&newpath, git_repository_path(g_repo), newloose));
+ cl_git_pass(git_str_joinpath(&oldpath, git_repository_path(g_repo), oldloose));
+ cl_git_pass(git_str_joinpath(&newpath, git_repository_path(g_repo), newloose));
cl_git_pass(git_futils_cp(oldpath.ptr, newpath.ptr, 0644));
/* Verify that lookup fails due to a hashsum mismatch */
@@ -117,6 +117,6 @@ void test_object_lookup__lookup_object_with_wrong_hash_returns_error(void)
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, 1));
git_object_free(object);
- git_buf_dispose(&oldpath);
- git_buf_dispose(&newpath);
+ git_str_dispose(&oldpath);
+ git_str_dispose(&newpath);
}
diff --git a/tests/object/message.c b/tests/object/message.c
index bc005340b..d87c8ef70 100644
--- a/tests/object/message.c
+++ b/tests/object/message.c
@@ -1,13 +1,11 @@
#include "clar_libgit2.h"
-#include "buffer.h"
-#include "message.h"
static void assert_message_prettifying(char *expected_output, char *input, int strip_comments)
{
git_buf prettified_message = GIT_BUF_INIT;
git_message_prettify(&prettified_message, input, strip_comments, '#');
- cl_assert_equal_s(expected_output, git_buf_cstr(&prettified_message));
+ cl_assert_equal_s(expected_output, prettified_message.ptr);
git_buf_dispose(&prettified_message);
}
diff --git a/tests/object/raw/hash.c b/tests/object/raw/hash.c
index 3be1f83b3..5a3e81855 100644
--- a/tests/object/raw/hash.c
+++ b/tests/object/raw/hash.c
@@ -56,7 +56,7 @@ void test_object_raw_hash__hash_buffer_in_single_call(void)
void test_object_raw_hash__hash_vector(void)
{
git_oid id1, id2;
- git_buf_vec vec[2];
+ git_str_vec vec[2];
cl_git_pass(git_oid_fromstr(&id1, hello_id));
diff --git a/tests/object/tree/write.c b/tests/object/tree/write.c
index 1bc5a50a0..a4ceb35b6 100644
--- a/tests/object/tree/write.c
+++ b/tests/object/tree/write.c
@@ -394,12 +394,12 @@ void test_object_tree_write__cruel_paths(void)
for (i = 0; i < count; ++i) {
for (j = 0; j < count; ++j) {
- git_buf b = GIT_BUF_INIT;
- cl_git_pass(git_buf_joinpath(&b, the_paths[i], the_paths[j]));
+ git_str b = GIT_STR_INIT;
+ cl_git_pass(git_str_joinpath(&b, the_paths[i], the_paths[j]));
cl_git_pass(git_tree_entry_bypath(&te, tree, b.ptr));
cl_assert_equal_s(the_paths[j], git_tree_entry_name(te));
git_tree_entry_free(te);
- git_buf_dispose(&b);
+ git_str_dispose(&b);
}
}
diff --git a/tests/odb/alternates.c b/tests/odb/alternates.c
index f65a44bb5..e36010b75 100644
--- a/tests/odb/alternates.c
+++ b/tests/odb/alternates.c
@@ -2,7 +2,7 @@
#include "odb.h"
#include "filebuf.h"
-static git_buf destpath, filepath;
+static git_str destpath, filepath;
static const char *paths[] = {
"A.git", "B.git", "C.git", "D.git", "E.git", "F.git", "G.git"
};
@@ -13,8 +13,8 @@ void test_odb_alternates__cleanup(void)
{
size_t i;
- git_buf_dispose(&destpath);
- git_buf_dispose(&filepath);
+ git_str_dispose(&destpath);
+ git_str_dispose(&filepath);
for (i = 0; i < ARRAY_SIZE(paths); i++)
cl_fixture_cleanup(paths[i]);
@@ -22,18 +22,18 @@ void test_odb_alternates__cleanup(void)
static void init_linked_repo(const char *path, const char *alternate)
{
- git_buf_clear(&destpath);
- git_buf_clear(&filepath);
+ git_str_clear(&destpath);
+ git_str_clear(&filepath);
cl_git_pass(git_repository_init(&repo, path, 1));
cl_git_pass(git_path_prettify(&destpath, alternate, NULL));
- cl_git_pass(git_buf_joinpath(&destpath, destpath.ptr, "objects"));
- cl_git_pass(git_buf_joinpath(&filepath, git_repository_path(repo), "objects/info"));
+ cl_git_pass(git_str_joinpath(&destpath, destpath.ptr, "objects"));
+ cl_git_pass(git_str_joinpath(&filepath, git_repository_path(repo), "objects/info"));
cl_git_pass(git_futils_mkdir(filepath.ptr, 0755, GIT_MKDIR_PATH));
- cl_git_pass(git_buf_joinpath(&filepath, filepath.ptr , "alternates"));
+ cl_git_pass(git_str_joinpath(&filepath, filepath.ptr , "alternates"));
- cl_git_pass(git_filebuf_open(&file, git_buf_cstr(&filepath), 0, 0666));
- git_filebuf_printf(&file, "%s\n", git_buf_cstr(&destpath));
+ cl_git_pass(git_filebuf_open(&file, git_str_cstr(&filepath), 0, 0666));
+ git_filebuf_printf(&file, "%s\n", git_str_cstr(&destpath));
cl_git_pass(git_filebuf_commit(&file));
git_repository_free(repo);
diff --git a/tests/odb/foreach.c b/tests/odb/foreach.c
index 02112380b..c2a448363 100644
--- a/tests/odb/foreach.c
+++ b/tests/odb/foreach.c
@@ -2,7 +2,6 @@
#include "odb.h"
#include "git2/odb_backend.h"
#include "pack.h"
-#include "buffer.h"
static git_odb *_odb;
static git_repository *_repo;
@@ -121,15 +120,15 @@ void test_odb_foreach__files_in_objects_dir(void)
{
git_repository *repo;
git_odb *odb;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
int nobj = 0;
cl_fixture_sandbox("testrepo.git");
cl_git_pass(git_repository_open(&repo, "testrepo.git"));
- cl_git_pass(git_buf_joinpath(&buf, git_repository_path(repo), "objects/somefile"));
+ cl_git_pass(git_str_joinpath(&buf, git_repository_path(repo), "objects/somefile"));
cl_git_mkfile(buf.ptr, "");
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
cl_git_pass(git_repository_odb(&odb, repo));
cl_git_pass(git_odb_foreach(odb, foreach_cb, &nobj));
diff --git a/tests/odb/freshen.c b/tests/odb/freshen.c
index 1ecd92a8d..2396e3774 100644
--- a/tests/odb/freshen.c
+++ b/tests/odb/freshen.c
@@ -19,7 +19,7 @@ void test_odb_freshen__cleanup(void)
static void set_time_wayback(struct stat *out, const char *fn)
{
- git_buf fullpath = GIT_BUF_INIT;
+ git_str fullpath = GIT_STR_INIT;
struct p_timeval old[2];
old[0].tv_sec = 1234567890;
@@ -27,11 +27,11 @@ static void set_time_wayback(struct stat *out, const char *fn)
old[1].tv_sec = 1234567890;
old[1].tv_usec = 0;
- git_buf_joinpath(&fullpath, "testrepo.git/objects", fn);
+ git_str_joinpath(&fullpath, "testrepo.git/objects", fn);
- cl_must_pass(p_utimes(git_buf_cstr(&fullpath), old));
- cl_must_pass(p_lstat(git_buf_cstr(&fullpath), out));
- git_buf_dispose(&fullpath);
+ cl_must_pass(p_utimes(git_str_cstr(&fullpath), old));
+ cl_must_pass(p_lstat(git_str_cstr(&fullpath), out));
+ git_str_dispose(&fullpath);
}
#define LOOSE_STR "my new file\n"
diff --git a/tests/odb/largefiles.c b/tests/odb/largefiles.c
index ff82291b3..acc786ee4 100644
--- a/tests/odb/largefiles.c
+++ b/tests/odb/largefiles.c
@@ -23,11 +23,11 @@ void test_odb_largefiles__cleanup(void)
static void writefile(git_oid *oid)
{
static git_odb_stream *stream;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
size_t i;
for (i = 0; i < 3041; i++)
- cl_git_pass(git_buf_puts(&buf, "Hello, world.\n"));
+ cl_git_pass(git_str_puts(&buf, "Hello, world.\n"));
cl_git_pass(git_odb_open_wstream(&stream, odb, LARGEFILE_SIZE, GIT_OBJECT_BLOB));
for (i = 0; i < 126103; i++)
@@ -36,13 +36,13 @@ static void writefile(git_oid *oid)
cl_git_pass(git_odb_stream_finalize_write(oid, stream));
git_odb_stream_free(stream);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
void test_odb_largefiles__write_from_memory(void)
{
git_oid expected, oid;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
size_t i;
#ifndef GIT_ARCH_64
@@ -55,7 +55,7 @@ void test_odb_largefiles__write_from_memory(void)
cl_skip();
for (i = 0; i < (3041*126103); i++)
- cl_git_pass(git_buf_puts(&buf, "Hello, world.\n"));
+ cl_git_pass(git_str_puts(&buf, "Hello, world.\n"));
git_oid_fromstr(&expected, "3fb56989cca483b21ba7cb0a6edb229d10e1c26c");
cl_git_pass(git_odb_write(&oid, odb, buf.ptr, buf.size, GIT_OBJECT_BLOB));
diff --git a/tests/online/clone.c b/tests/online/clone.c
index 7d43c6a09..c55cf9f95 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -180,7 +180,7 @@ static int fetch_progress(const git_indexer_progress *stats, void *payload)
void test_online_clone__can_checkout_a_cloned_repo(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_reference *head, *remote_head;
bool checkout_progress_cb_was_called = false,
fetch_progress_cb_was_called = false;
@@ -193,8 +193,8 @@ void test_online_clone__can_checkout_a_cloned_repo(void)
cl_git_pass(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options));
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "master.txt"));
- cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&path)));
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_repo), "master.txt"));
+ cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&path)));
cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(head));
@@ -209,7 +209,7 @@ void test_online_clone__can_checkout_a_cloned_repo(void)
git_reference_free(remote_head);
git_reference_free(head);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
static int remote_mirror_cb(git_remote **out, git_repository *repo,
@@ -406,16 +406,16 @@ void test_online_clone__credentials(void)
void test_online_clone__credentials_via_custom_headers(void)
{
const char *creds = "libgit3:libgit3";
- git_buf auth = GIT_BUF_INIT;
+ git_str auth = GIT_STR_INIT;
- cl_git_pass(git_buf_puts(&auth, "Authorization: Basic "));
- cl_git_pass(git_buf_encode_base64(&auth, creds, strlen(creds)));
+ cl_git_pass(git_str_puts(&auth, "Authorization: Basic "));
+ cl_git_pass(git_str_encode_base64(&auth, creds, strlen(creds)));
g_options.fetch_opts.custom_headers.count = 1;
g_options.fetch_opts.custom_headers.strings = &auth.ptr;
cl_git_pass(git_clone(&g_repo, "https://bitbucket.org/libgit2/testgitrepository.git", "./foo", &g_options));
- git_buf_dispose(&auth);
+ git_str_dispose(&auth);
}
void test_online_clone__bitbucket_style(void)
@@ -807,12 +807,12 @@ static int proxy_cert_cb(git_cert *cert, int valid, const char *host, void *payl
void test_online_clone__proxy_credentials_request(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
cl_skip();
- cl_git_pass(git_buf_printf(&url, "%s://%s/",
+ cl_git_pass(git_str_printf(&url, "%s://%s/",
_remote_proxy_scheme ? _remote_proxy_scheme : "http",
_remote_proxy_host));
@@ -824,17 +824,17 @@ void test_online_clone__proxy_credentials_request(void)
cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
cl_assert(called_proxy_creds);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
void test_online_clone__proxy_credentials_in_url(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
cl_skip();
- cl_git_pass(git_buf_printf(&url, "%s://%s:%s@%s/",
+ cl_git_pass(git_str_printf(&url, "%s://%s:%s@%s/",
_remote_proxy_scheme ? _remote_proxy_scheme : "http",
_remote_proxy_user, _remote_proxy_pass, _remote_proxy_host));
@@ -845,12 +845,12 @@ void test_online_clone__proxy_credentials_in_url(void)
cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
cl_assert(called_proxy_creds == 0);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
void test_online_clone__proxy_credentials_in_environment(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
cl_skip();
@@ -863,7 +863,7 @@ void test_online_clone__proxy_credentials_in_environment(void)
g_options.fetch_opts.proxy_opts.type = GIT_PROXY_AUTO;
g_options.fetch_opts.proxy_opts.certificate_check = proxy_cert_cb;
- cl_git_pass(git_buf_printf(&url, "%s://%s:%s@%s/",
+ cl_git_pass(git_str_printf(&url, "%s://%s:%s@%s/",
_remote_proxy_scheme ? _remote_proxy_scheme : "http",
_remote_proxy_user, _remote_proxy_pass, _remote_proxy_host));
@@ -873,17 +873,17 @@ void test_online_clone__proxy_credentials_in_environment(void)
cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
void test_online_clone__proxy_credentials_in_url_https(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
cl_skip();
- cl_git_pass(git_buf_printf(&url, "%s://%s:%s@%s/",
+ cl_git_pass(git_str_printf(&url, "%s://%s:%s@%s/",
_remote_proxy_scheme ? _remote_proxy_scheme : "http",
_remote_proxy_user, _remote_proxy_pass, _remote_proxy_host));
@@ -895,7 +895,7 @@ void test_online_clone__proxy_credentials_in_url_https(void)
cl_git_pass(git_clone(&g_repo, "https://github.com/libgit2/TestGitRepository", "./foo", &g_options));
cl_assert(called_proxy_creds == 0);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
void test_online_clone__proxy_auto_not_detected(void)
@@ -907,12 +907,12 @@ void test_online_clone__proxy_auto_not_detected(void)
void test_online_clone__proxy_cred_callback_after_failed_url_creds(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
cl_skip();
- cl_git_pass(git_buf_printf(&url, "%s://invalid_user_name:INVALID_pass_WORD@%s/",
+ cl_git_pass(git_str_printf(&url, "%s://invalid_user_name:INVALID_pass_WORD@%s/",
_remote_proxy_scheme ? _remote_proxy_scheme : "http",
_remote_proxy_host));
@@ -924,7 +924,7 @@ void test_online_clone__proxy_cred_callback_after_failed_url_creds(void)
cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
cl_assert(called_proxy_creds);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
void test_online_clone__azurerepos(void)
diff --git a/tests/online/customcert.c b/tests/online/customcert.c
index c7a0de1a1..098212b14 100644
--- a/tests/online/customcert.c
+++ b/tests/online/customcert.c
@@ -28,22 +28,22 @@ void test_online_customcert__initialize(void)
g_repo = NULL;
if (!initialized) {
- git_buf path = GIT_BUF_INIT, file = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT, file = GIT_STR_INIT;
char cwd[GIT_PATH_MAX];
cl_fixture_sandbox(CUSTOM_CERT_ONE_PATH);
cl_fixture_sandbox(CUSTOM_CERT_TWO_FILE);
cl_must_pass(p_getcwd(cwd, GIT_PATH_MAX));
- cl_git_pass(git_buf_joinpath(&path, cwd, CUSTOM_CERT_ONE_PATH));
- cl_git_pass(git_buf_joinpath(&file, cwd, CUSTOM_CERT_TWO_FILE));
+ cl_git_pass(git_str_joinpath(&path, cwd, CUSTOM_CERT_ONE_PATH));
+ cl_git_pass(git_str_joinpath(&file, cwd, CUSTOM_CERT_TWO_FILE));
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SSL_CERT_LOCATIONS,
file.ptr, path.ptr));
initialized = true;
- git_buf_dispose(&file);
- git_buf_dispose(&path);
+ git_str_dispose(&file);
+ git_str_dispose(&path);
}
#endif
}
diff --git a/tests/online/fetch.c b/tests/online/fetch.c
index 67dfd69ed..914291015 100644
--- a/tests/online/fetch.c
+++ b/tests/online/fetch.c
@@ -226,13 +226,13 @@ void test_online_fetch__twice(void)
void test_online_fetch__proxy(void)
{
git_remote *remote;
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
git_fetch_options fetch_opts;
if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
cl_skip();
- cl_git_pass(git_buf_printf(&url, "%s://%s:%s@%s/",
+ cl_git_pass(git_str_printf(&url, "%s://%s:%s@%s/",
_remote_proxy_scheme ? _remote_proxy_scheme : "http",
_remote_proxy_user, _remote_proxy_pass, _remote_proxy_host));
@@ -245,5 +245,5 @@ void test_online_fetch__proxy(void)
cl_git_pass(git_remote_fetch(remote, NULL, &fetch_opts, NULL));
git_remote_free(remote);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
diff --git a/tests/online/fetchhead.c b/tests/online/fetchhead.c
index b61993138..30cce3a90 100644
--- a/tests/online/fetchhead.c
+++ b/tests/online/fetchhead.c
@@ -52,7 +52,7 @@ static void fetchhead_test_fetch(const char *fetchspec, const char *expected_fet
{
git_remote *remote;
git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT;
- git_buf fetchhead_buf = GIT_BUF_INIT;
+ git_str fetchhead_buf = GIT_STR_INIT;
int equals = 0;
git_strarray array, *active_refs = NULL;
@@ -72,7 +72,7 @@ static void fetchhead_test_fetch(const char *fetchspec, const char *expected_fet
equals = (strcmp(fetchhead_buf.ptr, expected_fetchhead) == 0);
- git_buf_dispose(&fetchhead_buf);
+ git_str_dispose(&fetchhead_buf);
cl_assert(equals);
}
@@ -157,7 +157,7 @@ void test_online_fetchhead__colon_only_dst_refspec_creates_no_branch(void)
void test_online_fetchhead__creds_get_stripped(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
git_remote *remote;
cl_git_pass(git_repository_init(&g_repo, "./foo", 0));
@@ -169,5 +169,5 @@ void test_online_fetchhead__creds_get_stripped(void)
"49322bb17d3acc9146f98c97d078513228bbf3c0\t\thttps://github.com/libgit2/TestGitRepository\n");
git_remote_free(remote);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
diff --git a/tests/online/push.c b/tests/online/push.c
index c82b606cb..51adc3930 100644
--- a/tests/online/push.c
+++ b/tests/online/push.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "posix.h"
#include "vector.h"
#include "../submodule/submodule_helpers.h"
@@ -129,28 +128,28 @@ static void do_verify_push_status(record_callbacks_data *data, const push_status
}
if (failed) {
- git_buf msg = GIT_BUF_INIT;
+ git_str msg = GIT_STR_INIT;
- git_buf_puts(&msg, "Expected and actual push statuses differ:\nEXPECTED:\n");
+ git_str_puts(&msg, "Expected and actual push statuses differ:\nEXPECTED:\n");
for(i = 0; i < expected_len; i++) {
- git_buf_printf(&msg, "%s: %s\n",
+ git_str_printf(&msg, "%s: %s\n",
expected[i].ref,
expected[i].success ? "success" : "failed");
}
- git_buf_puts(&msg, "\nACTUAL:\n");
+ git_str_puts(&msg, "\nACTUAL:\n");
git_vector_foreach(actual, i, iter) {
if (iter->success)
- git_buf_printf(&msg, "%s: success\n", iter->ref);
+ git_str_printf(&msg, "%s: success\n", iter->ref);
else
- git_buf_printf(&msg, "%s: failed with message: %s", iter->ref, iter->msg);
+ git_str_printf(&msg, "%s: failed with message: %s", iter->ref, iter->msg);
}
- cl_fail(git_buf_cstr(&msg));
+ cl_fail(git_str_cstr(&msg));
- git_buf_dispose(&msg);
+ git_str_dispose(&msg);
}
git_vector_foreach(actual, i, iter) {
@@ -192,7 +191,7 @@ static void verify_tracking_branches(git_remote *remote, expected_ref expected_r
{
git_refspec *fetch_spec;
size_t i, j;
- git_buf msg = GIT_BUF_INIT;
+ git_str msg = GIT_STR_INIT;
git_buf ref_name = GIT_BUF_INIT;
git_vector actual_refs = GIT_VECTOR_INIT;
git_branch_iterator *iter;
@@ -230,12 +229,12 @@ static void verify_tracking_branches(git_remote *remote, expected_ref expected_r
/* Find matching remote branch */
git_vector_foreach(&actual_refs, j, actual_ref) {
- if (!strcmp(git_buf_cstr(&ref_name), actual_ref))
+ if (!strcmp(ref_name.ptr, actual_ref))
break;
}
if (j == actual_refs.length) {
- git_buf_printf(&msg, "Did not find expected tracking branch '%s'.", git_buf_cstr(&ref_name));
+ git_str_printf(&msg, "Did not find expected tracking branch '%s'.", ref_name.ptr);
failed = 1;
goto failed;
}
@@ -244,7 +243,7 @@ static void verify_tracking_branches(git_remote *remote, expected_ref expected_r
cl_git_pass(git_reference_name_to_id(&oid, remote->repo, actual_ref));
if (git_oid_cmp(expected_refs[i].oid, &oid) != 0) {
- git_buf_puts(&msg, "Tracking branch commit does not match expected ID.");
+ git_str_puts(&msg, "Tracking branch commit does not match expected ID.");
failed = 1;
goto failed;
}
@@ -255,27 +254,27 @@ static void verify_tracking_branches(git_remote *remote, expected_ref expected_r
/* Make sure there are no extra branches */
if (actual_refs.length > 0) {
- git_buf_puts(&msg, "Unexpected remote tracking branches exist.");
+ git_str_puts(&msg, "Unexpected remote tracking branches exist.");
failed = 1;
goto failed;
}
failed:
if (failed)
- cl_fail(git_buf_cstr(&msg));
+ cl_fail(git_str_cstr(&msg));
git_vector_foreach(&actual_refs, i, actual_ref)
git__free(actual_ref);
git_vector_free(&actual_refs);
- git_buf_dispose(&msg);
+ git_str_dispose(&msg);
git_buf_dispose(&ref_name);
}
static void verify_update_tips_callback(git_remote *remote, expected_ref expected_refs[], size_t expected_refs_len)
{
git_refspec *fetch_spec;
- git_buf msg = GIT_BUF_INIT;
+ git_str msg = GIT_STR_INIT;
git_buf ref_name = GIT_BUF_INIT;
updated_tip *tip = NULL;
size_t i, j;
@@ -293,18 +292,18 @@ static void verify_update_tips_callback(git_remote *remote, expected_ref expecte
/* Find matching update_tip entry */
git_vector_foreach(&_record_cbs_data.updated_tips, j, tip) {
- if (!strcmp(git_buf_cstr(&ref_name), tip->name))
+ if (!strcmp(ref_name.ptr, tip->name))
break;
}
if (j == _record_cbs_data.updated_tips.length) {
- git_buf_printf(&msg, "Did not find expected updated tip entry for branch '%s'.", git_buf_cstr(&ref_name));
+ git_str_printf(&msg, "Did not find expected updated tip entry for branch '%s'.", ref_name.ptr);
failed = 1;
goto failed;
}
if (git_oid_cmp(expected_refs[i].oid, &tip->new_oid) != 0) {
- git_buf_printf(&msg, "Updated tip ID does not match expected ID");
+ git_str_printf(&msg, "Updated tip ID does not match expected ID");
failed = 1;
goto failed;
}
@@ -312,10 +311,10 @@ static void verify_update_tips_callback(git_remote *remote, expected_ref expecte
failed:
if (failed)
- cl_fail(git_buf_cstr(&msg));
+ cl_fail(git_str_cstr(&msg));
git_buf_dispose(&ref_name);
- git_buf_dispose(&msg);
+ git_str_dispose(&msg);
}
void test_online_push__initialize(void)
diff --git a/tests/online/push_util.c b/tests/online/push_util.c
index b39f78114..94e310f3d 100644
--- a/tests/online/push_util.c
+++ b/tests/online/push_util.c
@@ -1,6 +1,4 @@
-
#include "clar_libgit2.h"
-#include "buffer.h"
#include "vector.h"
#include "push_util.h"
@@ -57,7 +55,7 @@ int record_update_tips_cb(const char *refname, const git_oid *a, const git_oid *
int create_deletion_refspecs(git_vector *out, const git_remote_head **heads, size_t heads_len)
{
- git_buf del_spec = GIT_BUF_INIT;
+ git_str del_spec = GIT_STR_INIT;
int valid;
size_t i;
@@ -70,9 +68,9 @@ int create_deletion_refspecs(git_vector *out, const git_remote_head **heads, siz
/* Create a refspec that deletes a branch in the remote */
if (strcmp(head->name, "refs/heads/master")) {
- cl_git_pass(git_buf_putc(&del_spec, ':'));
- cl_git_pass(git_buf_puts(&del_spec, head->name));
- cl_git_pass(git_vector_insert(out, git_buf_detach(&del_spec)));
+ cl_git_pass(git_str_putc(&del_spec, ':'));
+ cl_git_pass(git_str_puts(&del_spec, head->name));
+ cl_git_pass(git_vector_insert(out, git_str_detach(&del_spec)));
}
}
@@ -88,7 +86,7 @@ int record_ref_cb(git_remote_head *head, void *payload)
void verify_remote_refs(const git_remote_head *actual_refs[], size_t actual_refs_len, const expected_ref expected_refs[], size_t expected_refs_len)
{
size_t i, j = 0;
- git_buf msg = GIT_BUF_INIT;
+ git_str msg = GIT_STR_INIT;
const git_remote_head *actual;
char *oid_str;
bool master_present = false;
@@ -120,24 +118,24 @@ void verify_remote_refs(const git_remote_head *actual_refs[], size_t actual_refs
return;
failed:
- git_buf_puts(&msg, "Expected and actual refs differ:\nEXPECTED:\n");
+ git_str_puts(&msg, "Expected and actual refs differ:\nEXPECTED:\n");
for(i = 0; i < expected_refs_len; i++) {
oid_str = git_oid_tostr_s(expected_refs[i].oid);
- cl_git_pass(git_buf_printf(&msg, "%s = %s\n", expected_refs[i].name, oid_str));
+ cl_git_pass(git_str_printf(&msg, "%s = %s\n", expected_refs[i].name, oid_str));
}
- git_buf_puts(&msg, "\nACTUAL:\n");
+ git_str_puts(&msg, "\nACTUAL:\n");
for (i = 0; i < actual_refs_len; i++) {
actual = actual_refs[i];
if (master_present && !strcmp(actual->name, "refs/heads/master"))
continue;
oid_str = git_oid_tostr_s(&actual->oid);
- cl_git_pass(git_buf_printf(&msg, "%s = %s\n", actual->name, oid_str));
+ cl_git_pass(git_str_printf(&msg, "%s = %s\n", actual->name, oid_str));
}
- cl_fail(git_buf_cstr(&msg));
+ cl_fail(git_str_cstr(&msg));
- git_buf_dispose(&msg);
+ git_str_dispose(&msg);
}
diff --git a/tests/pack/filelimit.c b/tests/pack/filelimit.c
index 5e0b77e9b..2b7bf6e95 100644
--- a/tests/pack/filelimit.c
+++ b/tests/pack/filelimit.c
@@ -34,12 +34,12 @@ void test_pack_filelimit__initialize_unlimited(void)
void test_pack_filelimit__cleanup(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, original_mwindow_file_limit));
- cl_git_pass(git_buf_joinpath(&path, clar_sandbox_path(), "repo.git"));
+ cl_git_pass(git_str_joinpath(&path, clar_sandbox_path(), "repo.git"));
cl_fixture_cleanup(path.ptr);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
/*
@@ -54,7 +54,7 @@ void create_packfile_commit(
size_t commit_index,
size_t commit_count)
{
- git_buf file_contents = GIT_BUF_INIT;
+ git_str file_contents = GIT_STR_INIT;
git_treebuilder *treebuilder;
git_packbuilder *packbuilder;
git_signature *s;
@@ -67,7 +67,7 @@ void create_packfile_commit(
cl_git_pass(git_blob_create_from_buffer(&oid, repo, "", 0));
cl_git_pass(git_treebuilder_insert(NULL, treebuilder, "README.md", &oid, 0100644));
- cl_git_pass(git_buf_printf(&file_contents, "Commit %zd/%zd", commit_index, commit_count));
+ cl_git_pass(git_str_printf(&file_contents, "Commit %zd/%zd", commit_index, commit_count));
cl_git_pass(git_blob_create_from_buffer(&oid, repo, file_contents.ptr, file_contents.size));
cl_git_pass(git_treebuilder_insert(NULL, treebuilder, "file.txt", &oid, 0100644));
@@ -82,7 +82,7 @@ void create_packfile_commit(
cl_git_pass(git_oid_cpy(out_commit_id, &commit_id));
- git_buf_dispose(&file_contents);
+ git_str_dispose(&file_contents);
git_treebuilder_free(treebuilder);
git_packbuilder_free(packbuilder);
git_signature_free(s);
@@ -90,7 +90,7 @@ void create_packfile_commit(
void test_pack_filelimit__open_repo_with_multiple_packfiles(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_mwindow_ctl *ctl = &git_mwindow__mem_ctl;
git_repository *repo;
git_revwalk *walk;
@@ -103,7 +103,7 @@ void test_pack_filelimit__open_repo_with_multiple_packfiles(void)
* Create a repository and populate it with 16 commits, each in its own
* packfile.
*/
- cl_git_pass(git_buf_joinpath(&path, clar_sandbox_path(), "repo.git"));
+ cl_git_pass(git_str_joinpath(&path, clar_sandbox_path(), "repo.git"));
cl_git_pass(git_repository_init(&repo, path.ptr, true));
for (i = 0; i < commit_count; ++i) {
create_packfile_commit(repo, &id, parent_id, i + 1, commit_count);
@@ -130,7 +130,7 @@ void test_pack_filelimit__open_repo_with_multiple_packfiles(void)
cl_assert_equal_i(expected_open_mwindow_files, open_windows);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
git_revwalk_free(walk);
git_repository_free(repo);
}
diff --git a/tests/pack/indexer.c b/tests/pack/indexer.c
index 422c3def4..5958bc4ba 100644
--- a/tests/pack/indexer.c
+++ b/tests/pack/indexer.c
@@ -279,10 +279,10 @@ void test_pack_indexer__out_of_order_with_connectivity_checks(void)
git_indexer_free(idx);
}
-static int find_tmp_file_recurs(void *opaque, git_buf *path)
+static int find_tmp_file_recurs(void *opaque, git_str *path)
{
int error = 0;
- git_buf *first_tmp_file = opaque;
+ git_str *first_tmp_file = opaque;
struct stat st;
if ((error = p_lstat_posixly(path->ptr, &st)) < 0)
@@ -292,8 +292,8 @@ static int find_tmp_file_recurs(void *opaque, git_buf *path)
return git_path_direach(path, 0, find_tmp_file_recurs, opaque);
/* This is the template that's used in git_futils_mktmp. */
- if (strstr(git_buf_cstr(path), "_git2_") != NULL)
- return git_buf_sets(first_tmp_file, git_buf_cstr(path));
+ if (strstr(git_str_cstr(path), "_git2_") != NULL)
+ return git_str_sets(first_tmp_file, git_str_cstr(path));
return 0;
}
@@ -301,21 +301,21 @@ static int find_tmp_file_recurs(void *opaque, git_buf *path)
void test_pack_indexer__no_tmp_files(void)
{
git_indexer *idx = NULL;
- git_buf path = GIT_BUF_INIT;
- git_buf first_tmp_file = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
+ git_str first_tmp_file = GIT_STR_INIT;
/* Precondition: there are no temporary files. */
- cl_git_pass(git_buf_sets(&path, clar_sandbox_path()));
+ cl_git_pass(git_str_sets(&path, clar_sandbox_path()));
cl_git_pass(find_tmp_file_recurs(&first_tmp_file, &path));
- git_buf_dispose(&path);
- cl_assert(git_buf_len(&first_tmp_file) == 0);
+ git_str_dispose(&path);
+ cl_assert(git_str_len(&first_tmp_file) == 0);
cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL));
git_indexer_free(idx);
- cl_git_pass(git_buf_sets(&path, clar_sandbox_path()));
+ cl_git_pass(git_str_sets(&path, clar_sandbox_path()));
cl_git_pass(find_tmp_file_recurs(&first_tmp_file, &path));
- git_buf_dispose(&path);
- cl_assert(git_buf_len(&first_tmp_file) == 0);
- git_buf_dispose(&first_tmp_file);
+ git_str_dispose(&path);
+ cl_assert(git_str_len(&first_tmp_file) == 0);
+ git_str_dispose(&first_tmp_file);
}
diff --git a/tests/pack/midx.c b/tests/pack/midx.c
index d5b91d28b..9dd949363 100644
--- a/tests/pack/midx.c
+++ b/tests/pack/midx.c
@@ -12,12 +12,12 @@ void test_pack_midx__parse(void)
struct git_midx_file *idx;
struct git_midx_entry e;
git_oid id;
- git_buf midx_path = GIT_BUF_INIT;
+ git_str midx_path = GIT_STR_INIT;
cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
- cl_git_pass(git_buf_joinpath(&midx_path, git_repository_path(repo), "objects/pack/multi-pack-index"));
- cl_git_pass(git_midx_open(&idx, git_buf_cstr(&midx_path)));
- cl_assert_equal_i(git_midx_needs_refresh(idx, git_buf_cstr(&midx_path)), 0);
+ cl_git_pass(git_str_joinpath(&midx_path, git_repository_path(repo), "objects/pack/multi-pack-index"));
+ cl_git_pass(git_midx_open(&idx, git_str_cstr(&midx_path)));
+ cl_assert_equal_i(git_midx_needs_refresh(idx, git_str_cstr(&midx_path)), 0);
cl_git_pass(git_oid_fromstr(&id, "5001298e0c09ad9c34e4249bc5801c75e9754fa5"));
cl_git_pass(git_midx_entry_find(&e, idx, &id, GIT_OID_HEXSZ));
@@ -28,7 +28,7 @@ void test_pack_midx__parse(void)
git_midx_free(idx);
git_repository_free(repo);
- git_buf_dispose(&midx_path);
+ git_str_dispose(&midx_path);
}
void test_pack_midx__lookup(void)
@@ -51,27 +51,28 @@ void test_pack_midx__writer(void)
{
git_repository *repo;
git_midx_writer *w = NULL;
- git_buf midx = GIT_BUF_INIT, expected_midx = GIT_BUF_INIT, path = GIT_BUF_INIT;
+ git_buf midx = GIT_BUF_INIT;
+ git_str expected_midx = GIT_STR_INIT, path = GIT_STR_INIT;
cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
- cl_git_pass(git_buf_joinpath(&path, git_repository_path(repo), "objects/pack"));
- cl_git_pass(git_midx_writer_new(&w, git_buf_cstr(&path)));
+ cl_git_pass(git_str_joinpath(&path, git_repository_path(repo), "objects/pack"));
+ cl_git_pass(git_midx_writer_new(&w, git_str_cstr(&path)));
cl_git_pass(git_midx_writer_add(w, "pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx"));
cl_git_pass(git_midx_writer_add(w, "pack-d85f5d483273108c9d8dd0e4728ccf0b2982423a.idx"));
cl_git_pass(git_midx_writer_add(w, "pack-a81e489679b7d3418f9ab594bda8ceb37dd4c695.idx"));
cl_git_pass(git_midx_writer_dump(&midx, w));
- cl_git_pass(git_buf_joinpath(&path, git_repository_path(repo), "objects/pack/multi-pack-index"));
- cl_git_pass(git_futils_readbuffer(&expected_midx, git_buf_cstr(&path)));
+ cl_git_pass(git_str_joinpath(&path, git_repository_path(repo), "objects/pack/multi-pack-index"));
+ cl_git_pass(git_futils_readbuffer(&expected_midx, git_str_cstr(&path)));
- cl_assert_equal_i(git_buf_len(&midx), git_buf_len(&expected_midx));
- cl_assert_equal_strn(git_buf_cstr(&midx), git_buf_cstr(&expected_midx), git_buf_len(&midx));
+ cl_assert_equal_i(midx.size, git_str_len(&expected_midx));
+ cl_assert_equal_strn(midx.ptr, git_str_cstr(&expected_midx), midx.size);
git_buf_dispose(&midx);
- git_buf_dispose(&expected_midx);
- git_buf_dispose(&path);
+ git_str_dispose(&expected_midx);
+ git_str_dispose(&path);
git_midx_writer_free(w);
git_repository_free(repo);
}
@@ -81,30 +82,30 @@ void test_pack_midx__odb_create(void)
git_repository *repo;
git_odb *odb;
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
- git_buf midx = GIT_BUF_INIT, expected_midx = GIT_BUF_INIT, midx_path = GIT_BUF_INIT;
+ git_str midx = GIT_STR_INIT, expected_midx = GIT_STR_INIT, midx_path = GIT_STR_INIT;
struct stat st;
opts.bare = true;
opts.local = GIT_CLONE_LOCAL;
cl_git_pass(git_clone(&repo, cl_fixture("testrepo/.gitted"), "./clone.git", &opts));
- cl_git_pass(git_buf_joinpath(&midx_path, git_repository_path(repo), "objects/pack/multi-pack-index"));
- cl_git_fail(p_stat(git_buf_cstr(&midx_path), &st));
+ cl_git_pass(git_str_joinpath(&midx_path, git_repository_path(repo), "objects/pack/multi-pack-index"));
+ cl_git_fail(p_stat(git_str_cstr(&midx_path), &st));
cl_git_pass(git_repository_odb(&odb, repo));
cl_git_pass(git_odb_write_multi_pack_index(odb));
git_odb_free(odb);
- cl_git_pass(p_stat(git_buf_cstr(&midx_path), &st));
+ cl_git_pass(p_stat(git_str_cstr(&midx_path), &st));
cl_git_pass(git_futils_readbuffer(&expected_midx, cl_fixture("testrepo.git/objects/pack/multi-pack-index")));
- cl_git_pass(git_futils_readbuffer(&midx, git_buf_cstr(&midx_path)));
- cl_assert_equal_i(git_buf_len(&midx), git_buf_len(&expected_midx));
- cl_assert_equal_strn(git_buf_cstr(&midx), git_buf_cstr(&expected_midx), git_buf_len(&midx));
+ cl_git_pass(git_futils_readbuffer(&midx, git_str_cstr(&midx_path)));
+ cl_assert_equal_i(git_str_len(&midx), git_str_len(&expected_midx));
+ cl_assert_equal_strn(git_str_cstr(&midx), git_str_cstr(&expected_midx), git_str_len(&midx));
git_repository_free(repo);
- git_buf_dispose(&midx);
- git_buf_dispose(&midx_path);
- git_buf_dispose(&expected_midx);
+ git_str_dispose(&midx);
+ git_str_dispose(&midx_path);
+ git_str_dispose(&expected_midx);
cl_git_pass(git_futils_rmdir_r("./clone.git", NULL, GIT_RMDIR_REMOVE_FILES));
-} \ No newline at end of file
+}
diff --git a/tests/pack/packbuilder.c b/tests/pack/packbuilder.c
index 5d93ede06..b4c655c5e 100644
--- a/tests/pack/packbuilder.c
+++ b/tests/pack/packbuilder.c
@@ -96,7 +96,7 @@ static int feed_indexer(void *ptr, size_t len, void *payload)
void test_pack_packbuilder__create_pack(void)
{
git_indexer_progress stats;
- git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT, path = GIT_STR_INIT;
git_hash_ctx ctx;
git_oid hash;
char hex[GIT_OID_HEXSZ+1]; hex[GIT_OID_HEXSZ] = '\0';
@@ -108,7 +108,7 @@ void test_pack_packbuilder__create_pack(void)
cl_git_pass(git_indexer_commit(_indexer, &stats));
git_oid_fmt(hex, git_indexer_hash(_indexer));
- git_buf_printf(&path, "pack-%s.pack", hex);
+ git_str_printf(&path, "pack-%s.pack", hex);
/*
* By default, packfiles are created with only one thread.
@@ -124,15 +124,15 @@ void test_pack_packbuilder__create_pack(void)
*
*/
- cl_git_pass(git_futils_readbuffer(&buf, git_buf_cstr(&path)));
+ cl_git_pass(git_futils_readbuffer(&buf, git_str_cstr(&path)));
cl_git_pass(git_hash_ctx_init(&ctx, GIT_HASH_ALGORITHM_SHA1));
cl_git_pass(git_hash_update(&ctx, buf.ptr, buf.size));
cl_git_pass(git_hash_final(hash.id, &ctx));
git_hash_ctx_cleanup(&ctx);
- git_buf_dispose(&path);
- git_buf_dispose(&buf);
+ git_str_dispose(&path);
+ git_str_dispose(&buf);
git_oid_fmt(hex, &hash);
diff --git a/tests/patch/parse.c b/tests/patch/parse.c
index 3f89eb51a..a3c4c6730 100644
--- a/tests/patch/parse.c
+++ b/tests/patch/parse.c
@@ -27,13 +27,14 @@ static void ensure_patch_validity(git_patch *patch)
cl_assert_equal_i(0, delta->new_file.size);
}
-static void ensure_identical_patch_inout(const char *content) {
+static void ensure_identical_patch_inout(const char *content)
+{
git_buf buf = GIT_BUF_INIT;
git_patch *patch;
cl_git_pass(git_patch_from_buffer(&patch, content, strlen(content), NULL));
cl_git_pass(git_patch_to_buf(&buf, patch));
- cl_assert_equal_strn(git_buf_cstr(&buf), content, strlen(content));
+ cl_assert_equal_strn(buf.ptr, content, strlen(content));
git_patch_free(patch);
git_buf_dispose(&buf);
@@ -131,12 +132,13 @@ void test_patch_parse__files_with_whitespaces_succeeds(void)
void test_patch_parse__lifetime_of_patch_does_not_depend_on_buffer(void)
{
- git_buf diff = GIT_BUF_INIT, rendered = GIT_BUF_INIT;
+ git_str diff = GIT_STR_INIT;
+ git_buf rendered = GIT_BUF_INIT;
git_patch *patch;
- cl_git_pass(git_buf_sets(&diff, PATCH_ORIGINAL_TO_CHANGE_MIDDLE));
+ cl_git_pass(git_str_sets(&diff, PATCH_ORIGINAL_TO_CHANGE_MIDDLE));
cl_git_pass(git_patch_from_buffer(&patch, diff.ptr, diff.size, NULL));
- git_buf_dispose(&diff);
+ git_str_dispose(&diff);
cl_git_pass(git_patch_to_buf(&rendered, patch));
cl_assert_equal_s(PATCH_ORIGINAL_TO_CHANGE_MIDDLE, rendered.ptr);
diff --git a/tests/path/core.c b/tests/path/core.c
index c875a862c..1d6066933 100644
--- a/tests/path/core.c
+++ b/tests/path/core.c
@@ -12,11 +12,11 @@ static void test_make_relative(
const char *parent,
int expected_status)
{
- git_buf buf = GIT_BUF_INIT;
- git_buf_puts(&buf, path);
+ git_str buf = GIT_STR_INIT;
+ git_str_puts(&buf, path);
cl_assert_equal_i(expected_status, git_path_make_relative(&buf, parent));
cl_assert_equal_s(expected_path, buf.ptr);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
void test_path_core__make_relative(void)
@@ -373,19 +373,19 @@ static void test_join_unrooted(
const char *path,
const char *base)
{
- git_buf result = GIT_BUF_INIT;
+ git_str result = GIT_STR_INIT;
ssize_t root_at;
cl_git_pass(git_path_join_unrooted(&result, path, base, &root_at));
cl_assert_equal_s(expected_result, result.ptr);
cl_assert_equal_i(expected_rootlen, root_at);
- git_buf_dispose(&result);
+ git_str_dispose(&result);
}
void test_path_core__join_unrooted(void)
{
- git_buf out = GIT_BUF_INIT;
+ git_str out = GIT_STR_INIT;
test_join_unrooted("foo", 0, "foo", NULL);
test_join_unrooted("foo/bar", 0, "foo/bar", NULL);
@@ -421,7 +421,7 @@ void test_path_core__join_unrooted(void)
/* Trailing slash in the base is ignored */
test_join_unrooted("c:/foo/bar/foobar", 6, "c:/foo/bar/foobar", "c:/foo/");
- git_buf_dispose(&out);
+ git_str_dispose(&out);
}
void test_path_core__join_unrooted_respects_funny_windows_roots(void)
diff --git a/tests/rebase/sign.c b/tests/rebase/sign.c
index 06c18937a..dc99407dd 100644
--- a/tests/rebase/sign.c
+++ b/tests/rebase/sign.c
@@ -263,8 +263,8 @@ int signing_cb_passthrough(
const char *commit_content,
void *payload)
{
- cl_assert_equal_b(false, git_buf_is_allocated(signature));
- cl_assert_equal_b(false, git_buf_is_allocated(signature_field));
+ cl_assert_equal_i(0, signature->size);
+ cl_assert_equal_i(0, signature_field->size);
cl_assert_equal_s(expected_commit_content, commit_content);
cl_assert_equal_p(NULL, payload);
return GIT_PASSTHROUGH;
@@ -342,8 +342,8 @@ cttVRsdOoego+fiy08eFE+aJIeYiINRGhqOBTsuqG4jIdpdKxPE=\n\
=KbsY\n\
-----END PGP SIGNATURE-----";
- cl_assert_equal_b(false, git_buf_is_allocated(signature));
- cl_assert_equal_b(false, git_buf_is_allocated(signature_field));
+ cl_assert_equal_i(0, signature->size);
+ cl_assert_equal_i(0, signature_field->size);
cl_assert_equal_s(expected_commit_content, commit_content);
cl_assert_equal_p(NULL, payload);
@@ -426,8 +426,10 @@ int signing_cb_magic_field(
const char *signature_content = "magic word: pretty please";
const char *signature_field_content = "magicsig";
- cl_assert_equal_b(false, git_buf_is_allocated(signature));
- cl_assert_equal_b(false, git_buf_is_allocated(signature_field));
+ cl_assert_equal_p(NULL, signature->ptr);
+ cl_assert_equal_i(0, signature->size);
+ cl_assert_equal_p(NULL, signature_field->ptr);
+ cl_assert_equal_i(0, signature_field->size);
cl_assert_equal_s(expected_commit_content, commit_content);
cl_assert_equal_p(NULL, payload);
diff --git a/tests/rebase/submodule.c b/tests/rebase/submodule.c
index a28b3f4b2..0b3c2d5b5 100644
--- a/tests/rebase/submodule.c
+++ b/tests/rebase/submodule.c
@@ -65,7 +65,7 @@ void test_rebase_submodule__init_untracked(void)
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_annotated_commit *branch_head, *upstream_head;
- git_buf untracked_path = GIT_BUF_INIT;
+ git_str untracked_path = GIT_STR_INIT;
FILE *fp;
git_submodule *submodule;
@@ -78,11 +78,11 @@ void test_rebase_submodule__init_untracked(void)
cl_git_pass(git_submodule_lookup(&submodule, repo, "my-submodule"));
cl_git_pass(git_submodule_update(submodule, 1, NULL));
- git_buf_printf(&untracked_path, "%s/my-submodule/untracked", git_repository_workdir(repo));
- fp = fopen(git_buf_cstr(&untracked_path), "w");
+ git_str_printf(&untracked_path, "%s/my-submodule/untracked", git_repository_workdir(repo));
+ fp = fopen(git_str_cstr(&untracked_path), "w");
fprintf(fp, "An untracked file in a submodule should not block a rebase\n");
fclose(fp);
- git_buf_dispose(&untracked_path);
+ git_str_dispose(&untracked_path);
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL));
diff --git a/tests/refs/basic.c b/tests/refs/basic.c
index 9e4c22964..32742f9cc 100644
--- a/tests/refs/basic.c
+++ b/tests/refs/basic.c
@@ -49,7 +49,7 @@ void test_refs_basic__longpaths(void)
const char *base;
size_t base_len, extra_len;
ssize_t remain_len, i;
- git_buf refname = GIT_BUF_INIT;
+ git_str refname = GIT_STR_INIT;
git_reference *one = NULL, *two = NULL;
git_oid id;
@@ -62,10 +62,10 @@ void test_refs_basic__longpaths(void)
remain_len = (ssize_t)MAX_PATH - (base_len + extra_len);
cl_assert(remain_len > 0);
- cl_git_pass(git_buf_puts(&refname, "refs/heads/"));
+ cl_git_pass(git_str_puts(&refname, "refs/heads/"));
for (i = 0; i < remain_len; i++) {
- cl_git_pass(git_buf_putc(&refname, 'a'));
+ cl_git_pass(git_str_putc(&refname, 'a'));
}
/*
@@ -75,11 +75,11 @@ void test_refs_basic__longpaths(void)
cl_git_pass(git_reference_create(&one, g_repo, refname.ptr, &id, 0, NULL));
/* Adding one more character gives us a path that is too long. */
- cl_git_pass(git_buf_putc(&refname, 'z'));
+ cl_git_pass(git_str_putc(&refname, 'z'));
cl_git_fail(git_reference_create(&two, g_repo, refname.ptr, &id, 0, NULL));
git_reference_free(one);
git_reference_free(two);
- git_buf_dispose(&refname);
+ git_str_dispose(&refname);
#endif
}
diff --git a/tests/refs/branches/create.c b/tests/refs/branches/create.c
index 70ffad88d..7a49ad548 100644
--- a/tests/refs/branches/create.c
+++ b/tests/refs/branches/create.c
@@ -120,19 +120,19 @@ static void assert_branch_matches_name(
const char *expected, const char *lookup_as)
{
git_reference *ref;
- git_buf b = GIT_BUF_INIT;
+ git_str b = GIT_STR_INIT;
cl_git_pass(git_branch_lookup(&ref, repo, lookup_as, GIT_BRANCH_LOCAL));
- cl_git_pass(git_buf_sets(&b, "refs/heads/"));
- cl_git_pass(git_buf_puts(&b, expected));
+ cl_git_pass(git_str_sets(&b, "refs/heads/"));
+ cl_git_pass(git_str_puts(&b, expected));
cl_assert_equal_s(b.ptr, git_reference_name(ref));
cl_git_pass(
git_oid_cmp(git_reference_target(ref), git_commit_id(target)));
git_reference_free(ref);
- git_buf_dispose(&b);
+ git_str_dispose(&b);
}
void test_refs_branches_create__can_create_branch_with_unicode(void)
diff --git a/tests/refs/branches/delete.c b/tests/refs/branches/delete.c
index 6093c7886..aad5c090f 100644
--- a/tests/refs/branches/delete.c
+++ b/tests/refs/branches/delete.c
@@ -153,8 +153,8 @@ void test_refs_branches_delete__removes_empty_folders(void)
git_oid oidzero = {{0}};
git_signature *sig;
- git_buf ref_folder = GIT_BUF_INIT;
- git_buf reflog_folder = GIT_BUF_INIT;
+ git_str ref_folder = GIT_STR_INIT;
+ git_str reflog_folder = GIT_STR_INIT;
/* Create a new branch with a nested name */
cl_git_pass(git_oid_fromstr(&commit_id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"));
@@ -170,19 +170,19 @@ void test_refs_branches_delete__removes_empty_folders(void)
git_signature_free(sig);
git_reflog_free(log);
- cl_git_pass(git_buf_joinpath(&ref_folder, commondir, "refs/heads/some/deep"));
- cl_git_pass(git_buf_join3(&reflog_folder, '/', commondir, GIT_REFLOG_DIR, "refs/heads/some/deep"));
+ cl_git_pass(git_str_joinpath(&ref_folder, commondir, "refs/heads/some/deep"));
+ cl_git_pass(git_str_join3(&reflog_folder, '/', commondir, GIT_REFLOG_DIR, "refs/heads/some/deep"));
- cl_assert(git_path_exists(git_buf_cstr(&ref_folder)) == true);
- cl_assert(git_path_exists(git_buf_cstr(&reflog_folder)) == true);
+ cl_assert(git_path_exists(git_str_cstr(&ref_folder)) == true);
+ cl_assert(git_path_exists(git_str_cstr(&reflog_folder)) == true);
cl_git_pass(git_branch_delete(branch));
- cl_assert(git_path_exists(git_buf_cstr(&ref_folder)) == false);
- cl_assert(git_path_exists(git_buf_cstr(&reflog_folder)) == false);
+ cl_assert(git_path_exists(git_str_cstr(&ref_folder)) == false);
+ cl_assert(git_path_exists(git_str_cstr(&reflog_folder)) == false);
git_reference_free(branch);
- git_buf_dispose(&ref_folder);
- git_buf_dispose(&reflog_folder);
+ git_str_dispose(&ref_folder);
+ git_str_dispose(&reflog_folder);
}
diff --git a/tests/refs/branches/move.c b/tests/refs/branches/move.c
index 2cba9dfd3..46a5082d2 100644
--- a/tests/refs/branches/move.c
+++ b/tests/refs/branches/move.c
@@ -67,16 +67,14 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll
{
git_reference *original_ref, *new_ref;
git_config *config;
- git_buf buf = GIT_BUF_INIT;
- char *original_remote, *original_merge;
+ git_buf original_remote = GIT_BUF_INIT,
+ original_merge = GIT_BUF_INIT;
const char *str;
cl_git_pass(git_repository_config_snapshot(&config, repo));
- cl_git_pass(git_config_get_string_buf(&buf, config, "branch.master.remote"));
- original_remote = git_buf_detach(&buf);
- cl_git_pass(git_config_get_string_buf(&buf, config, "branch.master.merge"));
- original_merge = git_buf_detach(&buf);
+ cl_git_pass(git_config_get_string_buf(&original_remote, config, "branch.master.remote"));
+ cl_git_pass(git_config_get_string_buf(&original_merge, config, "branch.master.merge"));
git_config_free(config);
cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2"));
@@ -88,9 +86,9 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll
cl_git_pass(git_repository_config_snapshot(&config, repo));
cl_git_pass(git_config_get_string(&str, config, "branch.master.remote"));
- cl_assert_equal_s(original_remote, str);
+ cl_assert_equal_s(original_remote.ptr, str);
cl_git_pass(git_config_get_string(&str, config, "branch.master.merge"));
- cl_assert_equal_s(original_merge, str);
+ cl_assert_equal_s(original_merge.ptr, str);
git_config_free(config);
cl_assert_equal_i(GIT_EEXISTS,
@@ -100,9 +98,9 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll
cl_git_pass(git_repository_config_snapshot(&config, repo));
cl_git_pass(git_config_get_string(&str, config, "branch.master.remote"));
- cl_assert_equal_s(original_remote, str);
+ cl_assert_equal_s(original_remote.ptr, str);
cl_git_pass(git_config_get_string(&str, config, "branch.master.merge"));
- cl_assert_equal_s(original_merge, str);
+ cl_assert_equal_s(original_merge.ptr, str);
git_config_free(config);
git_reference_free(original_ref);
@@ -115,11 +113,12 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll
cl_git_pass(git_repository_config_snapshot(&config, repo));
cl_git_pass(git_config_get_string(&str, config, "branch.master.remote"));
- cl_assert_equal_s(original_remote, str);
+ cl_assert_equal_s(original_remote.ptr, str);
cl_git_pass(git_config_get_string(&str, config, "branch.master.merge"));
- cl_assert_equal_s(original_merge, str);
+ cl_assert_equal_s(original_merge.ptr, str);
- git__free(original_remote); git__free(original_merge);
+ git_buf_dispose(&original_remote);
+ git_buf_dispose(&original_merge);
git_reference_free(original_ref);
git_config_free(config);
}
diff --git a/tests/refs/branches/remote.c b/tests/refs/branches/remote.c
index 27a3b0c44..e2bd3485a 100644
--- a/tests/refs/branches/remote.c
+++ b/tests/refs/branches/remote.c
@@ -32,10 +32,9 @@ void test_refs_branches_remote__can_get_remote_for_branch(void)
void test_refs_branches_remote__no_matching_remote_returns_error(void)
{
const char *unknown = "refs/remotes/nonexistent/master";
- git_buf buf;
+ git_buf buf = GIT_BUF_INIT;
git_error_clear();
- memset(&buf, 0, sizeof(git_buf));
cl_git_fail_with(git_branch_remote_name(&buf, g_repo, unknown), GIT_ENOTFOUND);
cl_assert(git_error_last() != NULL);
}
@@ -43,10 +42,9 @@ void test_refs_branches_remote__no_matching_remote_returns_error(void)
void test_refs_branches_remote__local_remote_returns_error(void)
{
const char *local = "refs/heads/master";
- git_buf buf;
+ git_buf buf = GIT_BUF_INIT;
git_error_clear();
- memset(&buf, 0, sizeof(git_buf));
cl_git_fail_with(git_branch_remote_name(&buf, g_repo, local), GIT_ERROR);
cl_assert(git_error_last() != NULL);
}
@@ -54,7 +52,7 @@ void test_refs_branches_remote__local_remote_returns_error(void)
void test_refs_branches_remote__ambiguous_remote_returns_error(void)
{
git_remote *remote;
- git_buf buf;
+ git_buf buf = GIT_BUF_INIT;
/* Create the remote */
cl_git_pass(git_remote_create_with_fetchspec(&remote, g_repo, "addtest", "http://github.com/libgit2/libgit2", "refs/heads/*:refs/remotes/test/*"));
@@ -62,7 +60,6 @@ void test_refs_branches_remote__ambiguous_remote_returns_error(void)
git_remote_free(remote);
git_error_clear();
- memset(&buf, 0, sizeof(git_buf));
cl_git_fail_with(git_branch_remote_name(&buf, g_repo, remote_tracking_branch_name), GIT_EAMBIGUOUS);
cl_assert(git_error_last() != NULL);
}
diff --git a/tests/refs/branches/upstreamname.c b/tests/refs/branches/upstreamname.c
index 2eb639738..5bae154d2 100644
--- a/tests/refs/branches/upstreamname.c
+++ b/tests/refs/branches/upstreamname.c
@@ -8,7 +8,6 @@ void test_refs_branches_upstreamname__initialize(void)
{
cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
- git_buf_init(&upstream_name, 0);
}
void test_refs_branches_upstreamname__cleanup(void)
@@ -24,7 +23,7 @@ void test_refs_branches_upstreamname__can_retrieve_the_remote_tracking_reference
cl_git_pass(git_branch_upstream_name(
&upstream_name, repo, "refs/heads/master"));
- cl_assert_equal_s("refs/remotes/test/master", git_buf_cstr(&upstream_name));
+ cl_assert_equal_s("refs/remotes/test/master", upstream_name.ptr);
}
void test_refs_branches_upstreamname__can_retrieve_the_local_upstream_reference_name_of_a_local_branch(void)
@@ -32,5 +31,5 @@ void test_refs_branches_upstreamname__can_retrieve_the_local_upstream_reference_
cl_git_pass(git_branch_upstream_name(
&upstream_name, repo, "refs/heads/track-local"));
- cl_assert_equal_s("refs/heads/master", git_buf_cstr(&upstream_name));
+ cl_assert_equal_s("refs/heads/master", upstream_name.ptr);
}
diff --git a/tests/refs/delete.c b/tests/refs/delete.c
index 3e99a7959..c76d126eb 100644
--- a/tests/refs/delete.c
+++ b/tests/refs/delete.c
@@ -29,10 +29,10 @@ void test_refs_delete__packed_loose(void)
{
/* deleting a ref which is both packed and loose should remove both tracks in the filesystem */
git_reference *looked_up_ref, *another_looked_up_ref;
- git_buf temp_path = GIT_BUF_INIT;
+ git_str temp_path = GIT_STR_INIT;
/* Ensure the loose reference exists on the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), packed_test_head_name));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), packed_test_head_name));
cl_assert(git_path_exists(temp_path.ptr));
/* Lookup the reference */
@@ -52,7 +52,7 @@ void test_refs_delete__packed_loose(void)
cl_assert(!git_path_exists(temp_path.ptr));
git_reference_free(another_looked_up_ref);
- git_buf_dispose(&temp_path);
+ git_str_dispose(&temp_path);
}
void test_refs_delete__packed_only(void)
diff --git a/tests/refs/pack.c b/tests/refs/pack.c
index 676fb1759..125b1adb0 100644
--- a/tests/refs/pack.c
+++ b/tests/refs/pack.c
@@ -33,11 +33,11 @@ static void packall(void)
void test_refs_pack__empty(void)
{
/* create a packfile for an empty folder */
- git_buf temp_path = GIT_BUF_INIT;
+ git_str temp_path = GIT_STR_INIT;
- cl_git_pass(git_buf_join_n(&temp_path, '/', 3, git_repository_path(g_repo), GIT_REFS_HEADS_DIR, "empty_dir"));
+ cl_git_pass(git_str_join_n(&temp_path, '/', 3, git_repository_path(g_repo), GIT_REFS_HEADS_DIR, "empty_dir"));
cl_git_pass(git_futils_mkdir_r(temp_path.ptr, GIT_REFS_DIR_MODE));
- git_buf_dispose(&temp_path);
+ git_str_dispose(&temp_path);
packall();
}
@@ -46,7 +46,7 @@ void test_refs_pack__loose(void)
{
/* create a packfile from all the loose refs in a repo */
git_reference *reference;
- git_buf temp_path = GIT_BUF_INIT;
+ git_str temp_path = GIT_STR_INIT;
/* Ensure a known loose ref can be looked up */
cl_git_pass(git_reference_lookup(&reference, g_repo, loose_tag_ref_name));
@@ -62,7 +62,7 @@ void test_refs_pack__loose(void)
packall();
/* Ensure the packed-refs file exists */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), GIT_PACKEDREFS_FILE));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), GIT_PACKEDREFS_FILE));
cl_assert(git_path_exists(temp_path.ptr));
/* Ensure the known ref can still be looked up but is now packed */
@@ -71,11 +71,11 @@ void test_refs_pack__loose(void)
cl_assert_equal_s(reference->name, loose_tag_ref_name);
/* Ensure the known ref has been removed from the loose folder structure */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), loose_tag_ref_name));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), loose_tag_ref_name));
cl_assert(!git_path_exists(temp_path.ptr));
git_reference_free(reference);
- git_buf_dispose(&temp_path);
+ git_str_dispose(&temp_path);
}
void test_refs_pack__symbolic(void)
diff --git a/tests/refs/read.c b/tests/refs/read.c
index 1bbc38766..a622c770b 100644
--- a/tests/refs/read.c
+++ b/tests/refs/read.c
@@ -31,7 +31,7 @@ void test_refs_read__loose_tag(void)
/* lookup a loose tag reference */
git_reference *reference;
git_object *object;
- git_buf ref_name_from_tag_name = GIT_BUF_INIT;
+ git_str ref_name_from_tag_name = GIT_STR_INIT;
cl_git_pass(git_reference_lookup(&reference, g_repo, loose_tag_ref_name));
cl_assert(git_reference_type(reference) & GIT_REFERENCE_DIRECT);
@@ -43,9 +43,9 @@ void test_refs_read__loose_tag(void)
cl_assert(git_object_type(object) == GIT_OBJECT_TAG);
/* Ensure the name of the tag matches the name of the reference */
- cl_git_pass(git_buf_joinpath(&ref_name_from_tag_name, GIT_REFS_TAGS_DIR, git_tag_name((git_tag *)object)));
+ cl_git_pass(git_str_joinpath(&ref_name_from_tag_name, GIT_REFS_TAGS_DIR, git_tag_name((git_tag *)object)));
cl_assert_equal_s(ref_name_from_tag_name.ptr, loose_tag_ref_name);
- git_buf_dispose(&ref_name_from_tag_name);
+ git_str_dispose(&ref_name_from_tag_name);
git_object_free(object);
diff --git a/tests/refs/ref_helpers.c b/tests/refs/ref_helpers.c
index 42b49216c..e55364c6e 100644
--- a/tests/refs/ref_helpers.c
+++ b/tests/refs/ref_helpers.c
@@ -2,24 +2,23 @@
#include "git2/refs.h"
#include "common.h"
#include "util.h"
-#include "buffer.h"
#include "path.h"
int reference_is_packed(git_reference *ref)
{
- git_buf ref_path = GIT_BUF_INIT;
+ git_str ref_path = GIT_STR_INIT;
int packed;
assert(ref);
- if (git_buf_joinpath(&ref_path,
+ if (git_str_joinpath(&ref_path,
git_repository_path(git_reference_owner(ref)),
git_reference_name(ref)) < 0)
return -1;
packed = !git_path_isfile(ref_path.ptr);
- git_buf_dispose(&ref_path);
+ git_str_dispose(&ref_path);
return packed;
}
diff --git a/tests/refs/reflog/messages.c b/tests/refs/reflog/messages.c
index 53b8c6f3e..ed183d2f2 100644
--- a/tests/refs/reflog/messages.c
+++ b/tests/refs/reflog/messages.c
@@ -338,7 +338,7 @@ void test_refs_reflog_messages__updating_a_direct_reference(void)
void test_refs_reflog_messages__creating_branches_default_messages(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
git_annotated_commit *annotated;
git_object *obj;
git_commit *target;
@@ -350,11 +350,11 @@ void test_refs_reflog_messages__creating_branches_default_messages(void)
cl_git_pass(git_branch_create(&branch1, g_repo, NEW_BRANCH_NAME, target, false));
- cl_git_pass(git_buf_printf(&buf, "branch: Created from %s", git_oid_tostr_s(git_commit_id(target))));
+ cl_git_pass(git_str_printf(&buf, "branch: Created from %s", git_oid_tostr_s(git_commit_id(target))));
cl_reflog_check_entry(g_repo, "refs/heads/" NEW_BRANCH_NAME, 0,
GIT_OID_HEX_ZERO,
git_oid_tostr_s(git_commit_id(target)),
- g_email, git_buf_cstr(&buf));
+ g_email, git_str_cstr(&buf));
cl_git_pass(git_reference_remove(g_repo, "refs/heads/" NEW_BRANCH_NAME));
@@ -367,7 +367,7 @@ void test_refs_reflog_messages__creating_branches_default_messages(void)
g_email, "branch: Created from e90810b8df3");
git_annotated_commit_free(annotated);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
git_commit_free(target);
git_reference_free(branch1);
git_reference_free(branch2);
diff --git a/tests/refs/reflog/reflog.c b/tests/refs/reflog/reflog.c
index 5cefc3227..5bb6138df 100644
--- a/tests/refs/reflog/reflog.c
+++ b/tests/refs/reflog/reflog.c
@@ -100,60 +100,60 @@ void test_refs_reflog_reflog__append_then_read(void)
void test_refs_reflog_reflog__renaming_the_reference_moves_the_reflog(void)
{
git_reference *master, *new_master;
- git_buf master_log_path = GIT_BUF_INIT, moved_log_path = GIT_BUF_INIT;
+ git_str master_log_path = GIT_STR_INIT, moved_log_path = GIT_STR_INIT;
- git_buf_joinpath(&master_log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
- git_buf_puts(&moved_log_path, git_buf_cstr(&master_log_path));
- git_buf_joinpath(&master_log_path, git_buf_cstr(&master_log_path), "refs/heads/master");
- git_buf_joinpath(&moved_log_path, git_buf_cstr(&moved_log_path), "refs/moved");
+ git_str_joinpath(&master_log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
+ git_str_puts(&moved_log_path, git_str_cstr(&master_log_path));
+ git_str_joinpath(&master_log_path, git_str_cstr(&master_log_path), "refs/heads/master");
+ git_str_joinpath(&moved_log_path, git_str_cstr(&moved_log_path), "refs/moved");
- cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&master_log_path)));
- cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&moved_log_path)));
+ cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&master_log_path)));
+ cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&moved_log_path)));
cl_git_pass(git_reference_lookup(&master, g_repo, "refs/heads/master"));
cl_git_pass(git_reference_rename(&new_master, master, "refs/moved", 0, NULL));
git_reference_free(master);
- cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&master_log_path)));
- cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&moved_log_path)));
+ cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&master_log_path)));
+ cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&moved_log_path)));
git_reference_free(new_master);
- git_buf_dispose(&moved_log_path);
- git_buf_dispose(&master_log_path);
+ git_str_dispose(&moved_log_path);
+ git_str_dispose(&master_log_path);
}
void test_refs_reflog_reflog__deleting_the_reference_deletes_the_reflog(void)
{
git_reference *master;
- git_buf master_log_path = GIT_BUF_INIT;
+ git_str master_log_path = GIT_STR_INIT;
- git_buf_joinpath(&master_log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
- git_buf_joinpath(&master_log_path, git_buf_cstr(&master_log_path), "refs/heads/master");
+ git_str_joinpath(&master_log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
+ git_str_joinpath(&master_log_path, git_str_cstr(&master_log_path), "refs/heads/master");
- cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&master_log_path)));
+ cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&master_log_path)));
cl_git_pass(git_reference_lookup(&master, g_repo, "refs/heads/master"));
cl_git_pass(git_reference_delete(master));
git_reference_free(master);
- cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&master_log_path)));
- git_buf_dispose(&master_log_path);
+ cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&master_log_path)));
+ git_str_dispose(&master_log_path);
}
void test_refs_reflog_reflog__removes_empty_reflog_dir(void)
{
git_reference *ref;
- git_buf log_path = GIT_BUF_INIT;
+ git_str log_path = GIT_STR_INIT;
git_oid id;
/* Create a new branch pointing at the HEAD */
git_oid_fromstr(&id, current_master_tip);
cl_git_pass(git_reference_create(&ref, g_repo, "refs/heads/new-dir/new-head", &id, 0, NULL));
- git_buf_joinpath(&log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
- git_buf_joinpath(&log_path, git_buf_cstr(&log_path), "refs/heads/new-dir/new-head");
+ git_str_joinpath(&log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
+ git_str_joinpath(&log_path, git_str_cstr(&log_path), "refs/heads/new-dir/new-head");
- cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&log_path)));
+ cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&log_path)));
cl_git_pass(git_reference_delete(ref));
git_reference_free(ref);
@@ -163,13 +163,13 @@ void test_refs_reflog_reflog__removes_empty_reflog_dir(void)
cl_git_pass(git_reference_create(&ref, g_repo, "refs/heads/new-dir", &id, 0, NULL));
git_reference_free(ref);
- git_buf_dispose(&log_path);
+ git_str_dispose(&log_path);
}
void test_refs_reflog_reflog__fails_gracefully_on_nonempty_reflog_dir(void)
{
git_reference *ref;
- git_buf log_path = GIT_BUF_INIT;
+ git_str log_path = GIT_STR_INIT;
git_oid id;
/* Create a new branch pointing at the HEAD */
@@ -177,10 +177,10 @@ void test_refs_reflog_reflog__fails_gracefully_on_nonempty_reflog_dir(void)
cl_git_pass(git_reference_create(&ref, g_repo, "refs/heads/new-dir/new-head", &id, 0, NULL));
git_reference_free(ref);
- git_buf_joinpath(&log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
- git_buf_joinpath(&log_path, git_buf_cstr(&log_path), "refs/heads/new-dir/new-head");
+ git_str_joinpath(&log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
+ git_str_joinpath(&log_path, git_str_cstr(&log_path), "refs/heads/new-dir/new-head");
- cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&log_path)));
+ cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&log_path)));
/* delete the ref manually, leave the reflog */
cl_must_pass(p_unlink("testrepo.git/refs/heads/new-dir/new-head"));
@@ -190,7 +190,7 @@ void test_refs_reflog_reflog__fails_gracefully_on_nonempty_reflog_dir(void)
cl_git_fail_with(GIT_EDIRECTORY, git_reference_create(&ref, g_repo, "refs/heads/new-dir", &id, 0, NULL));
git_reference_free(ref);
- git_buf_dispose(&log_path);
+ git_str_dispose(&log_path);
}
static void assert_has_reflog(bool expected_result, const char *name)
@@ -209,17 +209,17 @@ void test_refs_reflog_reflog__reading_the_reflog_from_a_reference_with_no_log_re
{
git_reflog *reflog;
const char *refname = "refs/heads/subtrees";
- git_buf subtrees_log_path = GIT_BUF_INIT;
+ git_str subtrees_log_path = GIT_STR_INIT;
- git_buf_join_n(&subtrees_log_path, '/', 3, git_repository_path(g_repo), GIT_REFLOG_DIR, refname);
- cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&subtrees_log_path)));
+ git_str_join_n(&subtrees_log_path, '/', 3, git_repository_path(g_repo), GIT_REFLOG_DIR, refname);
+ cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&subtrees_log_path)));
cl_git_pass(git_reflog_read(&reflog, g_repo, refname));
cl_assert_equal_i(0, (int)git_reflog_entrycount(reflog));
git_reflog_free(reflog);
- git_buf_dispose(&subtrees_log_path);
+ git_str_dispose(&subtrees_log_path);
}
void test_refs_reflog_reflog__reading_a_reflog_with_invalid_format_succeeds(void)
@@ -231,7 +231,7 @@ void test_refs_reflog_reflog__reading_a_reflog_with_invalid_format_succeeds(void
const git_reflog_entry *entry;
git_reference *ref;
git_oid id;
- git_buf logpath = GIT_BUF_INIT, logcontents = GIT_BUF_INIT;
+ git_str logpath = GIT_STR_INIT, logcontents = GIT_STR_INIT;
char *star;
/* Create a new branch. */
@@ -242,18 +242,18 @@ void test_refs_reflog_reflog__reading_a_reflog_with_invalid_format_succeeds(void
* Corrupt the branch reflog by introducing a newline inside the reflog message.
* We do this by replacing '*' with '\n'
*/
- cl_git_pass(git_buf_join_n(&logpath, '/', 3, git_repository_path(g_repo), GIT_REFLOG_DIR, refname));
- cl_git_pass(git_futils_readbuffer(&logcontents, git_buf_cstr(&logpath)));
- cl_assert((star = strchr(git_buf_cstr(&logcontents), '*')) != NULL);
+ cl_git_pass(git_str_join_n(&logpath, '/', 3, git_repository_path(g_repo), GIT_REFLOG_DIR, refname));
+ cl_git_pass(git_futils_readbuffer(&logcontents, git_str_cstr(&logpath)));
+ cl_assert((star = strchr(git_str_cstr(&logcontents), '*')) != NULL);
*star = '\n';
- cl_git_rewritefile(git_buf_cstr(&logpath), git_buf_cstr(&logcontents));
+ cl_git_rewritefile(git_str_cstr(&logpath), git_str_cstr(&logcontents));
/*
* Confirm that the file was rewritten successfully
* and now contains a '\n' in the expected location
*/
- cl_git_pass(git_futils_readbuffer(&logcontents, git_buf_cstr(&logpath)));
- cl_assert(strstr(git_buf_cstr(&logcontents), "Reflog\nmessage") != NULL);
+ cl_git_pass(git_futils_readbuffer(&logcontents, git_str_cstr(&logpath)));
+ cl_assert(strstr(git_str_cstr(&logcontents), "Reflog\nmessage") != NULL);
cl_git_pass(git_reflog_read(&reflog, g_repo, refname));
cl_assert(entry = git_reflog_entry_byindex(reflog, 0));
@@ -261,14 +261,14 @@ void test_refs_reflog_reflog__reading_a_reflog_with_invalid_format_succeeds(void
git_reference_free(ref);
git_reflog_free(reflog);
- git_buf_dispose(&logpath);
- git_buf_dispose(&logcontents);
+ git_str_dispose(&logpath);
+ git_str_dispose(&logcontents);
}
void test_refs_reflog_reflog__cannot_write_a_moved_reflog(void)
{
git_reference *master, *new_master;
- git_buf master_log_path = GIT_BUF_INIT, moved_log_path = GIT_BUF_INIT;
+ git_str master_log_path = GIT_STR_INIT, moved_log_path = GIT_STR_INIT;
git_reflog *reflog;
cl_git_pass(git_reference_lookup(&master, g_repo, "refs/heads/master"));
@@ -283,8 +283,8 @@ void test_refs_reflog_reflog__cannot_write_a_moved_reflog(void)
git_reflog_free(reflog);
git_reference_free(new_master);
- git_buf_dispose(&moved_log_path);
- git_buf_dispose(&master_log_path);
+ git_str_dispose(&moved_log_path);
+ git_str_dispose(&master_log_path);
}
void test_refs_reflog_reflog__renaming_with_an_invalid_name_returns_EINVALIDSPEC(void)
diff --git a/tests/refs/reflog/reflog_helpers.c b/tests/refs/reflog/reflog_helpers.c
index aecb78b02..22619a4e3 100644
--- a/tests/refs/reflog/reflog_helpers.c
+++ b/tests/refs/reflog/reflog_helpers.c
@@ -3,7 +3,7 @@
#include "repository.h"
#include "reflog.h"
-static int reflog_entry_tostr(git_buf *out, const git_reflog_entry *entry)
+static int reflog_entry_tostr(git_str *out, const git_reflog_entry *entry)
{
char old_oid[GIT_OID_HEXSZ], new_oid[GIT_OID_HEXSZ];
@@ -12,7 +12,7 @@ static int reflog_entry_tostr(git_buf *out, const git_reflog_entry *entry)
git_oid_tostr((char *)&old_oid, GIT_OID_HEXSZ, git_reflog_entry_id_old(entry));
git_oid_tostr((char *)&new_oid, GIT_OID_HEXSZ, git_reflog_entry_id_new(entry));
- return git_buf_printf(out, "%s %s %s %s", old_oid, new_oid, "somesig", git_reflog_entry_message(entry));
+ return git_str_printf(out, "%s %s %s %s", old_oid, new_oid, "somesig", git_reflog_entry_message(entry));
}
size_t reflog_entrycount(git_repository *repo, const char *name)
@@ -34,7 +34,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
{
git_reflog *log;
const git_reflog_entry *entry;
- git_buf result = GIT_BUF_INIT;
+ git_str result = GIT_STR_INIT;
cl_git_pass(git_reflog_read(&log, repo, reflog));
entry = git_reflog_entry_byindex(log, idx);
@@ -47,7 +47,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
if (git_oid_cmp(git_object_id(obj), git_reflog_entry_id_old(entry)) != 0) {
git_oid__writebuf(&result, "\tOld OID: \"", git_object_id(obj));
git_oid__writebuf(&result, "\" != \"", git_reflog_entry_id_old(entry));
- git_buf_puts(&result, "\"\n");
+ git_str_puts(&result, "\"\n");
}
git_object_free(obj);
} else {
@@ -56,7 +56,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
if (git_oid_cmp(oid, git_reflog_entry_id_old(entry)) != 0) {
git_oid__writebuf(&result, "\tOld OID: \"", oid);
git_oid__writebuf(&result, "\" != \"", git_reflog_entry_id_old(entry));
- git_buf_puts(&result, "\"\n");
+ git_str_puts(&result, "\"\n");
}
git__free(oid);
}
@@ -67,7 +67,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
if (git_oid_cmp(git_object_id(obj), git_reflog_entry_id_new(entry)) != 0) {
git_oid__writebuf(&result, "\tNew OID: \"", git_object_id(obj));
git_oid__writebuf(&result, "\" != \"", git_reflog_entry_id_new(entry));
- git_buf_puts(&result, "\"\n");
+ git_str_puts(&result, "\"\n");
}
git_object_free(obj);
} else {
@@ -76,26 +76,26 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
if (git_oid_cmp(oid, git_reflog_entry_id_new(entry)) != 0) {
git_oid__writebuf(&result, "\tNew OID: \"", oid);
git_oid__writebuf(&result, "\" != \"", git_reflog_entry_id_new(entry));
- git_buf_puts(&result, "\"\n");
+ git_str_puts(&result, "\"\n");
}
git__free(oid);
}
}
if (email && strcmp(email, git_reflog_entry_committer(entry)->email) != 0)
- git_buf_printf(&result, "\tEmail: \"%s\" != \"%s\"\n", email, git_reflog_entry_committer(entry)->email);
+ git_str_printf(&result, "\tEmail: \"%s\" != \"%s\"\n", email, git_reflog_entry_committer(entry)->email);
if (message) {
const char *entry_msg = git_reflog_entry_message(entry);
if (entry_msg == NULL) entry_msg = "";
if (entry_msg && strcmp(message, entry_msg) != 0)
- git_buf_printf(&result, "\tMessage: \"%s\" != \"%s\"\n", message, entry_msg);
+ git_str_printf(&result, "\tMessage: \"%s\" != \"%s\"\n", message, entry_msg);
}
- if (git_buf_len(&result) != 0)
- clar__fail(file, func, line, "Reflog entry mismatch", git_buf_cstr(&result), 1);
+ if (git_str_len(&result) != 0)
+ clar__fail(file, func, line, "Reflog entry mismatch", git_str_cstr(&result), 1);
- git_buf_dispose(&result);
+ git_str_dispose(&result);
git_reflog_free(log);
}
@@ -103,17 +103,17 @@ void reflog_print(git_repository *repo, const char *reflog_name)
{
git_reflog *reflog;
size_t idx;
- git_buf out = GIT_BUF_INIT;
+ git_str out = GIT_STR_INIT;
git_reflog_read(&reflog, repo, reflog_name);
for (idx = 0; idx < git_reflog_entrycount(reflog); idx++) {
const git_reflog_entry *entry = git_reflog_entry_byindex(reflog, idx);
reflog_entry_tostr(&out, entry);
- git_buf_putc(&out, '\n');
+ git_str_putc(&out, '\n');
}
- fprintf(stderr, "%s", git_buf_cstr(&out));
- git_buf_dispose(&out);
+ fprintf(stderr, "%s", git_str_cstr(&out));
+ git_str_dispose(&out);
git_reflog_free(reflog);
}
diff --git a/tests/refs/rename.c b/tests/refs/rename.c
index b1b75cd64..fa732234a 100644
--- a/tests/refs/rename.c
+++ b/tests/refs/rename.c
@@ -36,11 +36,11 @@ void test_refs_rename__loose(void)
{
/* rename a loose reference */
git_reference *looked_up_ref, *new_ref, *another_looked_up_ref;
- git_buf temp_path = GIT_BUF_INIT;
+ git_str temp_path = GIT_STR_INIT;
const char *new_name = "refs/tags/Nemo/knows/refs.kung-fu";
/* Ensure the ref doesn't exist on the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), new_name));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), new_name));
cl_assert(!git_path_exists(temp_path.ptr));
/* Retrieval of the reference to rename */
@@ -66,23 +66,23 @@ void test_refs_rename__loose(void)
cl_assert(reference_is_packed(new_ref) == 0);
/* ...and the ref can be found in the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), new_name));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), new_name));
cl_assert(git_path_exists(temp_path.ptr));
git_reference_free(new_ref);
git_reference_free(another_looked_up_ref);
- git_buf_dispose(&temp_path);
+ git_str_dispose(&temp_path);
}
void test_refs_rename__packed(void)
{
/* rename a packed reference (should make it loose) */
git_reference *looked_up_ref, *new_ref, *another_looked_up_ref;
- git_buf temp_path = GIT_BUF_INIT;
+ git_str temp_path = GIT_STR_INIT;
const char *brand_new_name = "refs/heads/brand_new_name";
/* Ensure the ref doesn't exist on the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), packed_head_name));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), packed_head_name));
cl_assert(!git_path_exists(temp_path.ptr));
/* The reference can however be looked-up... */
@@ -108,23 +108,23 @@ void test_refs_rename__packed(void)
cl_assert(reference_is_packed(new_ref) == 0);
/* ...and the ref now happily lives in the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), brand_new_name));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), brand_new_name));
cl_assert(git_path_exists(temp_path.ptr));
git_reference_free(new_ref);
git_reference_free(another_looked_up_ref);
- git_buf_dispose(&temp_path);
+ git_str_dispose(&temp_path);
}
void test_refs_rename__packed_doesnt_pack_others(void)
{
/* renaming a packed reference does not pack another reference which happens to be in both loose and pack state */
git_reference *looked_up_ref, *another_looked_up_ref, *renamed_ref;
- git_buf temp_path = GIT_BUF_INIT;
+ git_str temp_path = GIT_STR_INIT;
const char *brand_new_name = "refs/heads/brand_new_name";
/* Ensure the other reference exists on the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), packed_test_head_name));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), packed_test_head_name));
cl_assert(git_path_exists(temp_path.ptr));
/* Lookup the other reference */
@@ -155,7 +155,7 @@ void test_refs_rename__packed_doesnt_pack_others(void)
git_reference_free(renamed_ref);
git_reference_free(another_looked_up_ref);
- git_buf_dispose(&temp_path);
+ git_str_dispose(&temp_path);
}
void test_refs_rename__name_collision(void)
diff --git a/tests/refs/revparse.c b/tests/refs/revparse.c
index bc6e0a4c4..9c960702a 100644
--- a/tests/refs/revparse.c
+++ b/tests/refs/revparse.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "git2/revparse.h"
-#include "buffer.h"
#include "refs.h"
#include "path.h"
@@ -292,7 +291,7 @@ void test_refs_revparse__upstream(void)
void test_refs_revparse__ordinal(void)
{
assert_invalid_single_spec("master@{-2}");
-
+
/* TODO: make the test below actually fail
* cl_git_fail(git_revparse_single(&g_obj, g_repo, "master@{1a}"));
*/
@@ -326,19 +325,19 @@ void test_refs_revparse__previous_head(void)
static void create_fake_stash_reference_and_reflog(git_repository *repo)
{
git_reference *master, *new_master;
- git_buf log_path = GIT_BUF_INIT;
+ git_str log_path = GIT_STR_INIT;
- git_buf_joinpath(&log_path, git_repository_path(repo), "logs/refs/fakestash");
+ git_str_joinpath(&log_path, git_repository_path(repo), "logs/refs/fakestash");
- cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&log_path)));
+ cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&log_path)));
cl_git_pass(git_reference_lookup(&master, repo, "refs/heads/master"));
cl_git_pass(git_reference_rename(&new_master, master, "refs/fakestash", 0, NULL));
git_reference_free(master);
- cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&log_path)));
+ cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&log_path)));
- git_buf_dispose(&log_path);
+ git_str_dispose(&log_path);
git_reference_free(new_master);
}
@@ -555,7 +554,7 @@ void test_refs_revparse__a_too_short_objectid_returns_EAMBIGUOUS(void)
/*
* $ echo "aabqhq" | git hash-object -t blob --stdin
* dea509d0b3cb8ee0650f6ca210bc83f4678851ba
- *
+ *
* $ echo "aaazvc" | git hash-object -t blob --stdin
* dea509d097ce692e167dfc6a48a7a280cc5e877e
*/
@@ -569,11 +568,11 @@ void test_refs_revparse__a_not_precise_enough_objectid_returns_EAMBIGUOUS(void)
cl_git_mkfile("testrepo/one.txt", "aabqhq\n");
cl_git_mkfile("testrepo/two.txt", "aaazvc\n");
-
+
cl_git_pass(git_repository_index(&index, repo));
cl_git_pass(git_index_add_bypath(index, "one.txt"));
cl_git_pass(git_index_add_bypath(index, "two.txt"));
-
+
cl_git_fail_with(git_revparse_single(&obj, repo, "dea509d0"), GIT_EAMBIGUOUS);
cl_git_pass(git_revparse_single(&obj, repo, "dea509d09"));
@@ -588,7 +587,7 @@ void test_refs_revparse__issue_994(void)
git_repository *repo;
git_reference *head, *with_at;
git_object *target;
-
+
repo = cl_git_sandbox_init("testrepo.git");
cl_assert_equal_i(GIT_ENOTFOUND,
diff --git a/tests/remote/fetch.c b/tests/remote/fetch.c
index 7e825ca16..209c42993 100644
--- a/tests/remote/fetch.c
+++ b/tests/remote/fetch.c
@@ -15,24 +15,24 @@ static char *NON_FORCE_FETCHSPEC = "refs/heads/main:refs/remotes/repo1/main";
void test_remote_fetch__initialize(void) {
git_config *c;
- git_buf repo1_path_buf = GIT_BUF_INIT;
- git_buf repo2_path_buf = GIT_BUF_INIT;
+ git_str repo1_path_buf = GIT_STR_INIT;
+ git_str repo2_path_buf = GIT_STR_INIT;
const char *sandbox = clar_sandbox_path();
- cl_git_pass(git_buf_joinpath(&repo1_path_buf, sandbox, "fetchtest_repo1"));
- repo1_path = git_buf_detach(&repo1_path_buf);
+ cl_git_pass(git_str_joinpath(&repo1_path_buf, sandbox, "fetchtest_repo1"));
+ repo1_path = git_str_detach(&repo1_path_buf);
cl_git_pass(git_repository_init(&repo1, repo1_path, true));
- cl_git_pass(git_buf_joinpath(&repo2_path_buf, sandbox, "fetchtest_repo2"));
- repo2_path = git_buf_detach(&repo2_path_buf);
+ cl_git_pass(git_str_joinpath(&repo2_path_buf, sandbox, "fetchtest_repo2"));
+ repo2_path = git_str_detach(&repo2_path_buf);
cl_git_pass(git_repository_init(&repo2, repo2_path, true));
cl_git_pass(git_repository_config(&c, repo1));
cl_git_pass(git_config_set_string(c, "user.email", "some@email"));
cl_git_pass(git_config_set_string(c, "user.name", "some@name"));
git_config_free(c);
- git_buf_dispose(&repo1_path_buf);
- git_buf_dispose(&repo2_path_buf);
+ git_str_dispose(&repo1_path_buf);
+ git_str_dispose(&repo2_path_buf);
}
void test_remote_fetch__cleanup(void) {
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..e23bb77f9 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_STR_INIT, txt = GIT_STR_INIT, bin = GIT_STR_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_STR_INIT, txt = GIT_STR_INIT, bin = GIT_STR_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)
diff --git a/tests/reset/hard.c b/tests/reset/hard.c
index 1ea1d13fb..36e8f1470 100644
--- a/tests/reset/hard.c
+++ b/tests/reset/hard.c
@@ -40,7 +40,7 @@ static int strequal_ignore_eol(const char *exp, const char *str)
void test_reset_hard__resetting_reverts_modified_files(void)
{
- git_buf path = GIT_BUF_INIT, content = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT, content = GIT_STR_INIT;
int i;
static const char *files[4] = {
"current_file",
@@ -64,7 +64,7 @@ void test_reset_hard__resetting_reverts_modified_files(void)
cl_assert(wd);
for (i = 0; i < 4; ++i) {
- cl_git_pass(git_buf_joinpath(&path, wd, files[i]));
+ cl_git_pass(git_str_joinpath(&path, wd, files[i]));
cl_git_pass(git_futils_readbuffer(&content, path.ptr));
cl_assert_equal_s(before[i], content.ptr);
}
@@ -74,7 +74,7 @@ void test_reset_hard__resetting_reverts_modified_files(void)
cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL));
for (i = 0; i < 4; ++i) {
- cl_git_pass(git_buf_joinpath(&path, wd, files[i]));
+ cl_git_pass(git_str_joinpath(&path, wd, files[i]));
if (after[i]) {
cl_git_pass(git_futils_readbuffer(&content, path.ptr));
cl_assert(strequal_ignore_eol(after[i], content.ptr));
@@ -83,8 +83,8 @@ void test_reset_hard__resetting_reverts_modified_files(void)
}
}
- git_buf_dispose(&content);
- git_buf_dispose(&path);
+ git_str_dispose(&content);
+ git_str_dispose(&path);
}
void test_reset_hard__cannot_reset_in_a_bare_repository(void)
@@ -165,42 +165,42 @@ void test_reset_hard__resetting_reverts_unmerged(void)
void test_reset_hard__cleans_up_merge(void)
{
- git_buf merge_head_path = GIT_BUF_INIT,
- merge_msg_path = GIT_BUF_INIT,
- merge_mode_path = GIT_BUF_INIT,
- orig_head_path = GIT_BUF_INIT;
+ git_str merge_head_path = GIT_STR_INIT,
+ merge_msg_path = GIT_STR_INIT,
+ merge_mode_path = GIT_STR_INIT,
+ orig_head_path = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&merge_head_path, git_repository_path(repo), "MERGE_HEAD"));
- cl_git_mkfile(git_buf_cstr(&merge_head_path), "beefbeefbeefbeefbeefbeefbeefbeefbeefbeef\n");
+ cl_git_pass(git_str_joinpath(&merge_head_path, git_repository_path(repo), "MERGE_HEAD"));
+ cl_git_mkfile(git_str_cstr(&merge_head_path), "beefbeefbeefbeefbeefbeefbeefbeefbeefbeef\n");
- cl_git_pass(git_buf_joinpath(&merge_msg_path, git_repository_path(repo), "MERGE_MSG"));
- cl_git_mkfile(git_buf_cstr(&merge_msg_path), "Merge commit 0017bd4ab1ec30440b17bae1680cff124ab5f1f6\n");
+ cl_git_pass(git_str_joinpath(&merge_msg_path, git_repository_path(repo), "MERGE_MSG"));
+ cl_git_mkfile(git_str_cstr(&merge_msg_path), "Merge commit 0017bd4ab1ec30440b17bae1680cff124ab5f1f6\n");
- cl_git_pass(git_buf_joinpath(&merge_mode_path, git_repository_path(repo), "MERGE_MODE"));
- cl_git_mkfile(git_buf_cstr(&merge_mode_path), "");
+ cl_git_pass(git_str_joinpath(&merge_mode_path, git_repository_path(repo), "MERGE_MODE"));
+ cl_git_mkfile(git_str_cstr(&merge_mode_path), "");
- cl_git_pass(git_buf_joinpath(&orig_head_path, git_repository_path(repo), "ORIG_HEAD"));
- cl_git_mkfile(git_buf_cstr(&orig_head_path), "0017bd4ab1ec30440b17bae1680cff124ab5f1f6");
+ cl_git_pass(git_str_joinpath(&orig_head_path, git_repository_path(repo), "ORIG_HEAD"));
+ cl_git_mkfile(git_str_cstr(&orig_head_path), "0017bd4ab1ec30440b17bae1680cff124ab5f1f6");
cl_git_pass(git_revparse_single(&target, repo, "0017bd4"));
cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL));
- cl_assert(!git_path_exists(git_buf_cstr(&merge_head_path)));
- cl_assert(!git_path_exists(git_buf_cstr(&merge_msg_path)));
- cl_assert(!git_path_exists(git_buf_cstr(&merge_mode_path)));
+ cl_assert(!git_path_exists(git_str_cstr(&merge_head_path)));
+ cl_assert(!git_path_exists(git_str_cstr(&merge_msg_path)));
+ cl_assert(!git_path_exists(git_str_cstr(&merge_mode_path)));
- cl_assert(git_path_exists(git_buf_cstr(&orig_head_path)));
- cl_git_pass(p_unlink(git_buf_cstr(&orig_head_path)));
+ cl_assert(git_path_exists(git_str_cstr(&orig_head_path)));
+ cl_git_pass(p_unlink(git_str_cstr(&orig_head_path)));
- git_buf_dispose(&merge_head_path);
- git_buf_dispose(&merge_msg_path);
- git_buf_dispose(&merge_mode_path);
- git_buf_dispose(&orig_head_path);
+ git_str_dispose(&merge_head_path);
+ git_str_dispose(&merge_msg_path);
+ git_str_dispose(&merge_mode_path);
+ git_str_dispose(&orig_head_path);
}
void test_reset_hard__reflog_is_correct(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
git_annotated_commit *annotated;
const char *exp_msg = "commit: Add a file which name should appear before the "
"\"subdir/\" folder while being dealt with by the treewalker";
@@ -218,12 +218,12 @@ void test_reset_hard__reflog_is_correct(void)
/* Moved branch, expect id in message */
cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
- cl_git_pass(git_buf_printf(&buf, "reset: moving to %s", git_oid_tostr_s(git_object_id(target))));
+ cl_git_pass(git_str_printf(&buf, "reset: moving to %s", git_oid_tostr_s(git_object_id(target))));
cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL));
- reflog_check(repo, "HEAD", 4, NULL, git_buf_cstr(&buf));
- reflog_check(repo, "refs/heads/master", 4, NULL, git_buf_cstr(&buf));
+ reflog_check(repo, "HEAD", 4, NULL, git_str_cstr(&buf));
+ reflog_check(repo, "refs/heads/master", 4, NULL, git_str_cstr(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
/* Moved branch, expect revspec in message */
exp_msg = "reset: moving to HEAD~^{commit}";
diff --git a/tests/reset/mixed.c b/tests/reset/mixed.c
index 9928c6871..4a78d4c37 100644
--- a/tests/reset/mixed.c
+++ b/tests/reset/mixed.c
@@ -50,7 +50,7 @@ void test_reset_mixed__resetting_refreshes_the_index_to_the_commit_tree(void)
void test_reset_mixed__reflog_is_correct(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
git_annotated_commit *annotated;
const char *exp_msg = "commit: Updating test data so we can test inter-hunk-context";
@@ -68,12 +68,12 @@ void test_reset_mixed__reflog_is_correct(void)
/* Moved branch, expect id in message */
cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
- git_buf_clear(&buf);
- cl_git_pass(git_buf_printf(&buf, "reset: moving to %s", git_oid_tostr_s(git_object_id(target))));
+ git_str_clear(&buf);
+ cl_git_pass(git_str_printf(&buf, "reset: moving to %s", git_oid_tostr_s(git_object_id(target))));
cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL));
- reflog_check(repo, "HEAD", 10, NULL, git_buf_cstr(&buf));
- reflog_check(repo, "refs/heads/master", 10, NULL, git_buf_cstr(&buf));
- git_buf_dispose(&buf);
+ reflog_check(repo, "HEAD", 10, NULL, git_str_cstr(&buf));
+ reflog_check(repo, "refs/heads/master", 10, NULL, git_str_cstr(&buf));
+ git_str_dispose(&buf);
/* Moved branch, expect revspec in message */
exp_msg = "reset: moving to HEAD~^{commit}";
diff --git a/tests/reset/soft.c b/tests/reset/soft.c
index d9cfb0553..aca0834f2 100644
--- a/tests/reset/soft.c
+++ b/tests/reset/soft.c
@@ -116,33 +116,33 @@ void test_reset_soft__resetting_against_an_unborn_head_repo_makes_the_head_no_lo
void test_reset_soft__fails_when_merging(void)
{
- git_buf merge_head_path = GIT_BUF_INIT;
+ git_str merge_head_path = GIT_STR_INIT;
cl_git_pass(git_repository_detach_head(repo));
- cl_git_pass(git_buf_joinpath(&merge_head_path, git_repository_path(repo), "MERGE_HEAD"));
- cl_git_mkfile(git_buf_cstr(&merge_head_path), "beefbeefbeefbeefbeefbeefbeefbeefbeefbeef\n");
+ cl_git_pass(git_str_joinpath(&merge_head_path, git_repository_path(repo), "MERGE_HEAD"));
+ cl_git_mkfile(git_str_cstr(&merge_head_path), "beefbeefbeefbeefbeefbeefbeefbeefbeefbeef\n");
cl_git_pass(git_revparse_single(&target, repo, KNOWN_COMMIT_IN_BARE_REPO));
cl_assert_equal_i(GIT_EUNMERGED, git_reset(repo, target, GIT_RESET_SOFT, NULL));
- cl_git_pass(p_unlink(git_buf_cstr(&merge_head_path)));
+ cl_git_pass(p_unlink(git_str_cstr(&merge_head_path)));
- git_buf_dispose(&merge_head_path);
+ git_str_dispose(&merge_head_path);
}
void test_reset_soft__fails_when_index_contains_conflicts_independently_of_MERGE_HEAD_file_existence(void)
{
git_index *index;
git_reference *head;
- git_buf merge_head_path = GIT_BUF_INIT;
+ git_str merge_head_path = GIT_STR_INIT;
cl_git_sandbox_cleanup();
repo = cl_git_sandbox_init("mergedrepo");
- cl_git_pass(git_buf_joinpath(&merge_head_path, git_repository_path(repo), "MERGE_HEAD"));
- cl_git_pass(p_unlink(git_buf_cstr(&merge_head_path)));
- git_buf_dispose(&merge_head_path);
+ cl_git_pass(git_str_joinpath(&merge_head_path, git_repository_path(repo), "MERGE_HEAD"));
+ cl_git_pass(p_unlink(git_str_cstr(&merge_head_path)));
+ git_str_dispose(&merge_head_path);
cl_git_pass(git_repository_index(&index, repo));
cl_assert_equal_i(true, git_index_has_conflicts(index));
diff --git a/tests/revert/bare.c b/tests/revert/bare.c
index 03cffbf3e..9261cfe86 100644
--- a/tests/revert/bare.c
+++ b/tests/revert/bare.c
@@ -1,7 +1,6 @@
#include "clar.h"
#include "clar_libgit2.h"
-#include "buffer.h"
#include "futils.h"
#include "git2/revert.h"
diff --git a/tests/revert/workdir.c b/tests/revert/workdir.c
index 2ad059d99..36824044b 100644
--- a/tests/revert/workdir.c
+++ b/tests/revert/workdir.c
@@ -1,7 +1,6 @@
#include "clar.h"
#include "clar_libgit2.h"
-#include "buffer.h"
#include "futils.h"
#include "git2/revert.h"
@@ -66,7 +65,7 @@ void test_revert_workdir__conflicts(void)
git_reference *head_ref;
git_commit *head, *commit;
git_oid revert_oid;
- git_buf conflicting_buf = GIT_BUF_INIT, mergemsg_buf = GIT_BUF_INIT;
+ git_str conflicting_buf = GIT_STR_INIT, mergemsg_buf = GIT_STR_INIT;
struct merge_index_entry merge_index_entries[] = {
{ 0100644, "7731926a337c4eaba1e2187d90ebfa0a93659382", 1, "file1.txt" },
@@ -126,8 +125,8 @@ void test_revert_workdir__conflicts(void)
git_commit_free(commit);
git_commit_free(head);
git_reference_free(head_ref);
- git_buf_dispose(&mergemsg_buf);
- git_buf_dispose(&conflicting_buf);
+ git_str_dispose(&mergemsg_buf);
+ git_str_dispose(&conflicting_buf);
}
/* git reset --hard 39467716290f6df775a91cdb9a4eb39295018145
@@ -308,7 +307,7 @@ void test_revert_workdir__again_after_edit(void)
*/
void test_revert_workdir__again_after_edit_two(void)
{
- git_buf diff_buf = GIT_BUF_INIT;
+ git_str diff_buf = GIT_STR_INIT;
git_config *config;
git_oid head_commit_oid, revert_commit_oid;
git_commit *head_commit, *revert_commit;
@@ -350,7 +349,7 @@ void test_revert_workdir__again_after_edit_two(void)
git_commit_free(revert_commit);
git_commit_free(head_commit);
git_config_free(config);
- git_buf_dispose(&diff_buf);
+ git_str_dispose(&diff_buf);
}
/* git reset --hard 72333f47d4e83616630ff3b0ffe4c0faebcc3c45
diff --git a/tests/stash/apply.c b/tests/stash/apply.c
index 5eb59545e..c3d1ef0c2 100644
--- a/tests/stash/apply.c
+++ b/tests/stash/apply.c
@@ -70,7 +70,7 @@ void test_stash_apply__cleanup(void)
void test_stash_apply__with_default(void)
{
- git_buf where = GIT_BUF_INIT;
+ git_str where = GIT_STR_INIT;
cl_git_pass(git_stash_apply(repo, 0, NULL));
@@ -85,7 +85,7 @@ void test_stash_apply__with_default(void)
cl_git_pass(git_futils_readbuffer(&where, "stash/where"));
cl_assert_equal_s("....\n", where.ptr);
- git_buf_dispose(&where);
+ git_str_dispose(&where);
}
void test_stash_apply__with_existing_file(void)
@@ -114,7 +114,7 @@ void test_stash_apply__merges_new_file(void)
void test_stash_apply__with_reinstate_index(void)
{
- git_buf where = GIT_BUF_INIT;
+ git_str where = GIT_STR_INIT;
git_stash_apply_options opts = GIT_STASH_APPLY_OPTIONS_INIT;
opts.flags = GIT_STASH_APPLY_REINSTATE_INDEX;
@@ -132,7 +132,7 @@ void test_stash_apply__with_reinstate_index(void)
cl_git_pass(git_futils_readbuffer(&where, "stash/where"));
cl_assert_equal_s("....\n", where.ptr);
- git_buf_dispose(&where);
+ git_str_dispose(&where);
}
void test_stash_apply__conflict_index_with_default(void)
diff --git a/tests/stash/save.c b/tests/stash/save.c
index d568567d5..1fbcf0957 100644
--- a/tests/stash/save.c
+++ b/tests/stash/save.c
@@ -201,12 +201,12 @@ void test_stash_save__untracked_regression(void)
const char *paths[] = {"what", "where", "how", "why"};
git_reference *head;
git_commit *head_commit;
- git_buf untracked_dir;
+ git_str untracked_dir;
const char* workdir = git_repository_workdir(repo);
- git_buf_init(&untracked_dir, 0);
- git_buf_printf(&untracked_dir, "%sz", workdir);
+ git_str_init(&untracked_dir, 0);
+ git_str_printf(&untracked_dir, "%sz", workdir);
cl_assert(!p_mkdir(untracked_dir.ptr, 0777));
@@ -227,7 +227,7 @@ void test_stash_save__untracked_regression(void)
git_reference_free(head);
git_commit_free(head_commit);
- git_buf_dispose(&untracked_dir);
+ git_str_dispose(&untracked_dir);
}
#define MESSAGE "Look Ma! I'm on TV!"
diff --git a/tests/status/renames.c b/tests/status/renames.c
index 7deec980f..e69dbcce0 100644
--- a/tests/status/renames.c
+++ b/tests/status/renames.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "path.h"
#include "posix.h"
#include "status_helpers.h"
@@ -23,11 +22,11 @@ void test_status_renames__cleanup(void)
static void _rename_helper(
git_repository *repo, const char *from, const char *to, const char *extra)
{
- git_buf oldpath = GIT_BUF_INIT, newpath = GIT_BUF_INIT;
+ git_str oldpath = GIT_STR_INIT, newpath = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(
+ cl_git_pass(git_str_joinpath(
&oldpath, git_repository_workdir(repo), from));
- cl_git_pass(git_buf_joinpath(
+ cl_git_pass(git_str_joinpath(
&newpath, git_repository_workdir(repo), to));
cl_git_pass(p_rename(oldpath.ptr, newpath.ptr));
@@ -35,8 +34,8 @@ static void _rename_helper(
if (extra)
cl_git_append2file(newpath.ptr, extra);
- git_buf_dispose(&oldpath);
- git_buf_dispose(&newpath);
+ git_str_dispose(&oldpath);
+ git_str_dispose(&newpath);
}
#define rename_file(R,O,N) _rename_helper((R), (O), (N), NULL)
diff --git a/tests/status/worktree.c b/tests/status/worktree.c
index d9fce4404..4ab04094a 100644
--- a/tests/status/worktree.c
+++ b/tests/status/worktree.c
@@ -100,9 +100,9 @@ void test_status_worktree__empty_repository(void)
cl_assert_equal_i(0, count);
}
-static int remove_file_cb(void *data, git_buf *file)
+static int remove_file_cb(void *data, git_str *file)
{
- const char *filename = git_buf_cstr(file);
+ const char *filename = git_str_cstr(file);
GIT_UNUSED(data);
@@ -112,7 +112,7 @@ static int remove_file_cb(void *data, git_buf *file)
if (git_path_isdir(filename))
cl_git_pass(git_futils_rmdir_r(filename, NULL, GIT_RMDIR_REMOVE_FILES));
else
- cl_git_pass(p_unlink(git_buf_cstr(file)));
+ cl_git_pass(p_unlink(git_str_cstr(file)));
return 0;
}
@@ -122,12 +122,12 @@ void test_status_worktree__purged_worktree(void)
{
status_entry_counts counts;
git_repository *repo = cl_git_sandbox_init("status");
- git_buf workdir = GIT_BUF_INIT;
+ git_str workdir = GIT_STR_INIT;
/* first purge the contents of the worktree */
- cl_git_pass(git_buf_sets(&workdir, git_repository_workdir(repo)));
+ cl_git_pass(git_str_sets(&workdir, git_repository_workdir(repo)));
cl_git_pass(git_path_direach(&workdir, 0, remove_file_cb, NULL));
- git_buf_dispose(&workdir);
+ git_str_dispose(&workdir);
/* now get status */
memset(&counts, 0x0, sizeof(status_entry_counts));
@@ -369,78 +369,78 @@ static int cb_status__check_592(const char *p, unsigned int s, void *payload)
void test_status_worktree__issue_592(void)
{
git_repository *repo;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
repo = cl_git_sandbox_init("issue_592");
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(repo), "l.txt"));
- cl_git_pass(p_unlink(git_buf_cstr(&path)));
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(repo), "l.txt"));
+ cl_git_pass(p_unlink(git_str_cstr(&path)));
cl_assert(!git_path_exists("issue_592/l.txt"));
cl_git_pass(git_status_foreach(repo, cb_status__check_592, "l.txt"));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_status_worktree__issue_592_2(void)
{
git_repository *repo;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
repo = cl_git_sandbox_init("issue_592");
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(repo), "c/a.txt"));
- cl_git_pass(p_unlink(git_buf_cstr(&path)));
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(repo), "c/a.txt"));
+ cl_git_pass(p_unlink(git_str_cstr(&path)));
cl_assert(!git_path_exists("issue_592/c/a.txt"));
cl_git_pass(git_status_foreach(repo, cb_status__check_592, "c/a.txt"));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_status_worktree__issue_592_3(void)
{
git_repository *repo;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
repo = cl_git_sandbox_init("issue_592");
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(repo), "c"));
- cl_git_pass(git_futils_rmdir_r(git_buf_cstr(&path), NULL, GIT_RMDIR_REMOVE_FILES));
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(repo), "c"));
+ cl_git_pass(git_futils_rmdir_r(git_str_cstr(&path), NULL, GIT_RMDIR_REMOVE_FILES));
cl_assert(!git_path_exists("issue_592/c/a.txt"));
cl_git_pass(git_status_foreach(repo, cb_status__check_592, "c/a.txt"));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_status_worktree__issue_592_4(void)
{
git_repository *repo;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
repo = cl_git_sandbox_init("issue_592");
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(repo), "t/b.txt"));
- cl_git_pass(p_unlink(git_buf_cstr(&path)));
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(repo), "t/b.txt"));
+ cl_git_pass(p_unlink(git_str_cstr(&path)));
cl_git_pass(git_status_foreach(repo, cb_status__check_592, "t/b.txt"));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_status_worktree__issue_592_5(void)
{
git_repository *repo;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
repo = cl_git_sandbox_init("issue_592");
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(repo), "t"));
- cl_git_pass(git_futils_rmdir_r(git_buf_cstr(&path), NULL, GIT_RMDIR_REMOVE_FILES));
- cl_git_pass(p_mkdir(git_buf_cstr(&path), 0777));
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(repo), "t"));
+ cl_git_pass(git_futils_rmdir_r(git_str_cstr(&path), NULL, GIT_RMDIR_REMOVE_FILES));
+ cl_git_pass(p_mkdir(git_str_cstr(&path), 0777));
cl_git_pass(git_status_foreach(repo, cb_status__check_592, NULL));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_status_worktree__issue_592_ignores_0(void)
@@ -610,8 +610,8 @@ void test_status_worktree__filemode_non755(void)
git_repository *repo = cl_git_sandbox_init("filemodes");
status_entry_counts counts;
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
- git_buf executable_path = GIT_BUF_INIT;
- git_buf nonexecutable_path = GIT_BUF_INIT;
+ git_str executable_path = GIT_STR_INIT;
+ git_str nonexecutable_path = GIT_STR_INIT;
if (!cl_is_chmod_supported())
return;
@@ -620,14 +620,14 @@ void test_status_worktree__filemode_non755(void)
GIT_STATUS_OPT_INCLUDE_IGNORED |
GIT_STATUS_OPT_INCLUDE_UNMODIFIED;
- git_buf_joinpath(&executable_path, git_repository_workdir(repo), "exec_on");
- cl_must_pass(p_chmod(git_buf_cstr(&executable_path), 0744));
- git_buf_dispose(&executable_path);
+ git_str_joinpath(&executable_path, git_repository_workdir(repo), "exec_on");
+ cl_must_pass(p_chmod(git_str_cstr(&executable_path), 0744));
+ git_str_dispose(&executable_path);
- git_buf_joinpath(&nonexecutable_path, git_repository_workdir(repo), "exec_off");
+ git_str_joinpath(&nonexecutable_path, git_repository_workdir(repo), "exec_off");
- cl_must_pass(p_chmod(git_buf_cstr(&nonexecutable_path), 0655));
- git_buf_dispose(&nonexecutable_path);
+ cl_must_pass(p_chmod(git_str_cstr(&nonexecutable_path), 0655));
+ git_str_dispose(&nonexecutable_path);
memset(&counts, 0, sizeof(counts));
counts.expected_entry_count = filemode_count;
@@ -789,7 +789,7 @@ static void assert_ignore_case(
int expected_camel_cased_file_status)
{
unsigned int status;
- git_buf lower_case_path = GIT_BUF_INIT, camel_case_path = GIT_BUF_INIT;
+ git_str lower_case_path = GIT_STR_INIT, camel_case_path = GIT_STR_INIT;
git_repository *repo, *repo2;
repo = cl_git_sandbox_init("empty_standard_repo");
@@ -797,10 +797,10 @@ static void assert_ignore_case(
cl_repo_set_bool(repo, "core.ignorecase", should_ignore_case);
- cl_git_pass(git_buf_joinpath(&lower_case_path,
+ cl_git_pass(git_str_joinpath(&lower_case_path,
git_repository_workdir(repo), "plop"));
- cl_git_mkfile(git_buf_cstr(&lower_case_path), "");
+ cl_git_mkfile(git_str_cstr(&lower_case_path), "");
stage_and_commit(repo, "plop");
@@ -809,10 +809,10 @@ static void assert_ignore_case(
cl_git_pass(git_status_file(&status, repo2, "plop"));
cl_assert_equal_i(GIT_STATUS_CURRENT, status);
- cl_git_pass(git_buf_joinpath(&camel_case_path,
+ cl_git_pass(git_str_joinpath(&camel_case_path,
git_repository_workdir(repo), "Plop"));
- cl_git_pass(p_rename(git_buf_cstr(&lower_case_path), git_buf_cstr(&camel_case_path)));
+ cl_git_pass(p_rename(git_str_cstr(&lower_case_path), git_str_cstr(&camel_case_path)));
cl_git_pass(git_status_file(&status, repo2, "plop"));
cl_assert_equal_i(expected_lower_cased_file_status, status);
@@ -821,8 +821,8 @@ static void assert_ignore_case(
cl_assert_equal_i(expected_camel_cased_file_status, status);
git_repository_free(repo2);
- git_buf_dispose(&lower_case_path);
- git_buf_dispose(&camel_case_path);
+ git_str_dispose(&lower_case_path);
+ git_str_dispose(&camel_case_path);
}
void test_status_worktree__file_status_honors_core_ignorecase_true(void)
diff --git a/tests/str/basic.c b/tests/str/basic.c
new file mode 100644
index 000000000..5d2556805
--- /dev/null
+++ b/tests/str/basic.c
@@ -0,0 +1,50 @@
+#include "clar_libgit2.h"
+
+static const char *test_string = "Have you seen that? Have you seeeen that??";
+
+void test_str_basic__resize(void)
+{
+ git_str buf1 = GIT_STR_INIT;
+ git_str_puts(&buf1, test_string);
+ cl_assert(git_str_oom(&buf1) == 0);
+ cl_assert_equal_s(git_str_cstr(&buf1), test_string);
+
+ git_str_puts(&buf1, test_string);
+ cl_assert(strlen(git_str_cstr(&buf1)) == strlen(test_string) * 2);
+ git_str_dispose(&buf1);
+}
+
+void test_str_basic__resize_incremental(void)
+{
+ git_str buf1 = GIT_STR_INIT;
+
+ /* Presently, asking for 6 bytes will round up to 8. */
+ cl_git_pass(git_str_puts(&buf1, "Hello"));
+ cl_assert_equal_i(5, buf1.size);
+ cl_assert_equal_i(8, buf1.asize);
+
+ /* Ensure an additional byte does not realloc. */
+ cl_git_pass(git_str_grow_by(&buf1, 1));
+ cl_assert_equal_i(5, buf1.size);
+ cl_assert_equal_i(8, buf1.asize);
+
+ /* But requesting many does. */
+ cl_git_pass(git_str_grow_by(&buf1, 16));
+ cl_assert_equal_i(5, buf1.size);
+ cl_assert(buf1.asize > 8);
+
+ git_str_dispose(&buf1);
+}
+
+void test_str_basic__printf(void)
+{
+ git_str buf2 = GIT_STR_INIT;
+ git_str_printf(&buf2, "%s %s %d ", "shoop", "da", 23);
+ cl_assert(git_str_oom(&buf2) == 0);
+ cl_assert_equal_s(git_str_cstr(&buf2), "shoop da 23 ");
+
+ git_str_printf(&buf2, "%s %d", "woop", 42);
+ cl_assert(git_str_oom(&buf2) == 0);
+ cl_assert_equal_s(git_str_cstr(&buf2), "shoop da 23 woop 42");
+ git_str_dispose(&buf2);
+}
diff --git a/tests/buf/oom.c b/tests/str/oom.c
index 726234ef8..3d59ead01 100644
--- a/tests/buf/oom.c
+++ b/tests/str/oom.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
/* Override default allocators with ones that will fail predictably. */
@@ -18,7 +17,7 @@ static void *oom_realloc(void *p, size_t n, const char *file, int line)
return (n > 100) ? NULL : std_alloc.grealloc(p, n, file, line);
}
-void test_buf_oom__initialize(void)
+void test_str_oom__initialize(void)
{
git_stdalloc_init_allocator(&std_alloc);
git_stdalloc_init_allocator(&oom_alloc);
@@ -29,31 +28,31 @@ void test_buf_oom__initialize(void)
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_ALLOCATOR, &oom_alloc));
}
-void test_buf_oom__cleanup(void)
+void test_str_oom__cleanup(void)
{
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_ALLOCATOR, NULL));
}
-void test_buf_oom__grow(void)
+void test_str_oom__grow(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_grow(&buf, 42));
- cl_assert(!git_buf_oom(&buf));
+ cl_git_pass(git_str_grow(&buf, 42));
+ cl_assert(!git_str_oom(&buf));
- cl_assert(git_buf_grow(&buf, 101) == -1);
- cl_assert(git_buf_oom(&buf));
+ cl_assert(git_str_grow(&buf, 101) == -1);
+ cl_assert(git_str_oom(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
-void test_buf_oom__grow_by(void)
+void test_str_oom__grow_by(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_grow_by(&buf, 42));
- cl_assert(!git_buf_oom(&buf));
+ cl_git_pass(git_str_grow_by(&buf, 42));
+ cl_assert(!git_str_oom(&buf));
- cl_assert(git_buf_grow_by(&buf, 101) == -1);
- cl_assert(git_buf_oom(&buf));
+ cl_assert(git_str_grow_by(&buf, 101) == -1);
+ cl_assert(git_str_oom(&buf));
}
diff --git a/tests/buf/percent.c b/tests/str/percent.c
index 8c47b833d..339389075 100644
--- a/tests/buf/percent.c
+++ b/tests/str/percent.c
@@ -1,28 +1,27 @@
#include "clar_libgit2.h"
-#include "buffer.h"
static void expect_decode_pass(const char *expected, const char *encoded)
{
- git_buf in = GIT_BUF_INIT, out = GIT_BUF_INIT;
+ git_str in = GIT_STR_INIT, out = GIT_STR_INIT;
/*
* ensure that we only read the given length of the input buffer
* by putting garbage at the end. this will ensure that we do
* not, eg, rely on nul-termination or walk off the end of the buf.
*/
- cl_git_pass(git_buf_puts(&in, encoded));
- cl_git_pass(git_buf_PUTS(&in, "TRAILER"));
+ cl_git_pass(git_str_puts(&in, encoded));
+ cl_git_pass(git_str_PUTS(&in, "TRAILER"));
- cl_git_pass(git_buf_decode_percent(&out, in.ptr, strlen(encoded)));
+ cl_git_pass(git_str_decode_percent(&out, in.ptr, strlen(encoded)));
- cl_assert_equal_s(expected, git_buf_cstr(&out));
- cl_assert_equal_i(strlen(expected), git_buf_len(&out));
+ cl_assert_equal_s(expected, git_str_cstr(&out));
+ cl_assert_equal_i(strlen(expected), git_str_len(&out));
- git_buf_dispose(&in);
- git_buf_dispose(&out);
+ git_str_dispose(&in);
+ git_str_dispose(&out);
}
-void test_buf_percent__decode_succeeds(void)
+void test_str_percent__decode_succeeds(void)
{
expect_decode_pass("", "");
expect_decode_pass(" ", "%20");
@@ -37,7 +36,7 @@ void test_buf_percent__decode_succeeds(void)
expect_decode_pass("foo bar ", "foo%20bar%20");
}
-void test_buf_percent__ignores_invalid(void)
+void test_str_percent__ignores_invalid(void)
{
expect_decode_pass("githu%%.com", "githu%%.com");
expect_decode_pass("github.co%2", "github.co%2");
diff --git a/tests/buf/quote.c b/tests/str/quote.c
index 8867ae7d6..2c6546247 100644
--- a/tests/buf/quote.c
+++ b/tests/str/quote.c
@@ -1,20 +1,19 @@
#include "clar_libgit2.h"
-#include "buffer.h"
static void expect_quote_pass(const char *expected, const char *str)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_puts(&buf, str));
- cl_git_pass(git_buf_quote(&buf));
+ cl_git_pass(git_str_puts(&buf, str));
+ cl_git_pass(git_str_quote(&buf));
- cl_assert_equal_s(expected, git_buf_cstr(&buf));
- cl_assert_equal_i(strlen(expected), git_buf_len(&buf));
+ cl_assert_equal_s(expected, git_str_cstr(&buf));
+ cl_assert_equal_i(strlen(expected), git_str_len(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
-void test_buf_quote__quote_succeeds(void)
+void test_str_quote__quote_succeeds(void)
{
expect_quote_pass("", "");
expect_quote_pass("foo", "foo");
@@ -30,28 +29,28 @@ void test_buf_quote__quote_succeeds(void)
static void expect_unquote_pass(const char *expected, const char *quoted)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_puts(&buf, quoted));
- cl_git_pass(git_buf_unquote(&buf));
+ cl_git_pass(git_str_puts(&buf, quoted));
+ cl_git_pass(git_str_unquote(&buf));
- cl_assert_equal_s(expected, git_buf_cstr(&buf));
- cl_assert_equal_i(strlen(expected), git_buf_len(&buf));
+ cl_assert_equal_s(expected, git_str_cstr(&buf));
+ cl_assert_equal_i(strlen(expected), git_str_len(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
static void expect_unquote_fail(const char *quoted)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_puts(&buf, quoted));
- cl_git_fail(git_buf_unquote(&buf));
+ cl_git_pass(git_str_puts(&buf, quoted));
+ cl_git_fail(git_str_unquote(&buf));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
-void test_buf_quote__unquote_succeeds(void)
+void test_str_quote__unquote_succeeds(void)
{
expect_unquote_pass("", "\"\"");
expect_unquote_pass(" ", "\" \"");
@@ -68,7 +67,7 @@ void test_buf_quote__unquote_succeeds(void)
expect_unquote_pass("0xff: \377", "\"0xff: \\377\"");
}
-void test_buf_quote__unquote_fails(void)
+void test_str_quote__unquote_fails(void)
{
expect_unquote_fail("no quotes at all");
expect_unquote_fail("\"no trailing quote");
diff --git a/tests/str/splice.c b/tests/str/splice.c
new file mode 100644
index 000000000..14e844e2f
--- /dev/null
+++ b/tests/str/splice.c
@@ -0,0 +1,92 @@
+#include "clar_libgit2.h"
+
+static git_str _buf;
+
+void test_str_splice__initialize(void) {
+ git_str_init(&_buf, 16);
+}
+
+void test_str_splice__cleanup(void) {
+ git_str_dispose(&_buf);
+}
+
+void test_str_splice__preprend(void)
+{
+ git_str_sets(&_buf, "world!");
+
+ cl_git_pass(git_str_splice(&_buf, 0, 0, "Hello Dolly", strlen("Hello ")));
+
+ cl_assert_equal_s("Hello world!", git_str_cstr(&_buf));
+}
+
+void test_str_splice__append(void)
+{
+ git_str_sets(&_buf, "Hello");
+
+ cl_git_pass(git_str_splice(&_buf, git_str_len(&_buf), 0, " world!", strlen(" world!")));
+
+ cl_assert_equal_s("Hello world!", git_str_cstr(&_buf));
+}
+
+void test_str_splice__insert_at(void)
+{
+ git_str_sets(&_buf, "Hell world!");
+
+ cl_git_pass(git_str_splice(&_buf, strlen("Hell"), 0, "o", strlen("o")));
+
+ cl_assert_equal_s("Hello world!", git_str_cstr(&_buf));
+}
+
+void test_str_splice__remove_at(void)
+{
+ git_str_sets(&_buf, "Hello world of warcraft!");
+
+ cl_git_pass(git_str_splice(&_buf, strlen("Hello world"), strlen(" of warcraft"), "", 0));
+
+ cl_assert_equal_s("Hello world!", git_str_cstr(&_buf));
+}
+
+void test_str_splice__replace(void)
+{
+ git_str_sets(&_buf, "Hell0 w0rld!");
+
+ cl_git_pass(git_str_splice(&_buf, strlen("Hell"), strlen("0 w0"), "o wo", strlen("o wo")));
+
+ cl_assert_equal_s("Hello world!", git_str_cstr(&_buf));
+}
+
+void test_str_splice__replace_with_longer(void)
+{
+ git_str_sets(&_buf, "Hello you!");
+
+ cl_git_pass(git_str_splice(&_buf, strlen("Hello "), strlen("you"), "world", strlen("world")));
+
+ cl_assert_equal_s("Hello world!", git_str_cstr(&_buf));
+}
+
+void test_str_splice__replace_with_shorter(void)
+{
+ git_str_sets(&_buf, "Brave new world!");
+
+ cl_git_pass(git_str_splice(&_buf, 0, strlen("Brave new"), "Hello", strlen("Hello")));
+
+ cl_assert_equal_s("Hello world!", git_str_cstr(&_buf));
+}
+
+void test_str_splice__truncate(void)
+{
+ git_str_sets(&_buf, "Hello world!!");
+
+ cl_git_pass(git_str_splice(&_buf, strlen("Hello world!"), strlen("!"), "", 0));
+
+ cl_assert_equal_s("Hello world!", git_str_cstr(&_buf));
+}
+
+void test_str_splice__dont_do_anything(void)
+{
+ git_str_sets(&_buf, "Hello world!");
+
+ cl_git_pass(git_str_splice(&_buf, 3, 0, "Hello", 0));
+
+ cl_assert_equal_s("Hello world!", git_str_cstr(&_buf));
+}
diff --git a/tests/stress/diff.c b/tests/stress/diff.c
index 2ea0d4076..aecf08bbe 100644
--- a/tests/stress/diff.c
+++ b/tests/stress/diff.c
@@ -90,7 +90,7 @@ void test_stress_diff__rename_big_files(void)
git_index *index;
char tmp[64];
int i, j;
- git_buf b = GIT_BUF_INIT;
+ git_str b = GIT_STR_INIT;
g_repo = cl_git_sandbox_init("renames");
@@ -99,7 +99,7 @@ void test_stress_diff__rename_big_files(void)
for (i = 0; i < 100; i += 1) {
p_snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
for (j = i * 256; j > 0; --j)
- git_buf_printf(&b, "more content %d\n", i);
+ git_str_printf(&b, "more content %d\n", i);
cl_git_mkfile(tmp, b.ptr);
}
@@ -108,7 +108,7 @@ void test_stress_diff__rename_big_files(void)
cl_git_pass(git_index_add_bypath(index, tmp + strlen("renames/")));
}
- git_buf_dispose(&b);
+ git_str_dispose(&b);
git_index_free(index);
test_with_many(100);
@@ -119,13 +119,13 @@ void test_stress_diff__rename_many_files(void)
git_index *index;
char tmp[64];
int i;
- git_buf b = GIT_BUF_INIT;
+ git_str b = GIT_STR_INIT;
g_repo = cl_git_sandbox_init("renames");
cl_git_pass(git_repository_index(&index, g_repo));
- git_buf_printf(&b, "%08d\n" ANOTHER_POEM "%08d\n" ANOTHER_POEM ANOTHER_POEM, 0, 0);
+ git_str_printf(&b, "%08d\n" ANOTHER_POEM "%08d\n" ANOTHER_POEM ANOTHER_POEM, 0, 0);
for (i = 0; i < 2500; i += 1) {
p_snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
@@ -133,7 +133,7 @@ void test_stress_diff__rename_many_files(void)
b.ptr[8] = '\n';
cl_git_mkfile(tmp, b.ptr);
}
- git_buf_dispose(&b);
+ git_str_dispose(&b);
for (i = 0; i < 2500; i += 1) {
p_snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
diff --git a/tests/submodule/add.c b/tests/submodule/add.c
index fc458f826..b564123dd 100644
--- a/tests/submodule/add.c
+++ b/tests/submodule/add.c
@@ -17,20 +17,20 @@ void test_submodule_add__cleanup(void)
static void assert_submodule_url(const char* name, const char *url)
{
- git_buf key = GIT_BUF_INIT;
+ git_str key = GIT_STR_INIT;
- cl_git_pass(git_buf_printf(&key, "submodule.%s.url", name));
- assert_config_entry_value(g_repo, git_buf_cstr(&key), url);
+ cl_git_pass(git_str_printf(&key, "submodule.%s.url", name));
+ assert_config_entry_value(g_repo, git_str_cstr(&key), url);
- git_buf_dispose(&key);
+ git_str_dispose(&key);
}
void test_submodule_add__url_absolute(void)
{
git_submodule *sm;
git_repository *repo;
- git_buf dot_git_content = GIT_BUF_INIT;
+ git_str dot_git_content = GIT_STR_INIT;
g_repo = setup_fixture_submod2();
@@ -63,7 +63,7 @@ void test_submodule_add__url_absolute(void)
cl_assert_equal_s("gitdir: ../.git/modules/sm_libgit2/", dot_git_content.ptr);
git_repository_free(repo);
- git_buf_dispose(&dot_git_content);
+ git_str_dispose(&dot_git_content);
/* add a submodule not using a gitlink */
@@ -151,11 +151,11 @@ void test_submodule_add__path_exists_in_index(void)
{
git_index *index;
git_submodule *sm;
- git_buf filename = GIT_BUF_INIT;
+ git_str filename = GIT_STR_INIT;
g_repo = cl_git_sandbox_init("testrepo");
- cl_git_pass(git_buf_joinpath(&filename, "subdirectory", "test.txt"));
+ cl_git_pass(git_str_joinpath(&filename, "subdirectory", "test.txt"));
cl_git_pass(git_repository_index__weakptr(&index, g_repo));
@@ -164,14 +164,14 @@ void test_submodule_add__path_exists_in_index(void)
cl_git_fail_with(git_submodule_add_setup(&sm, g_repo, "./", "subdirectory", 1), GIT_EEXISTS);
git_submodule_free(sm);
- git_buf_dispose(&filename);
+ git_str_dispose(&filename);
}
void test_submodule_add__file_exists_in_index(void)
{
git_index *index;
git_submodule *sm;
- git_buf name = GIT_BUF_INIT;
+ git_str name = GIT_STR_INIT;
g_repo = cl_git_sandbox_init("testrepo");
@@ -182,7 +182,7 @@ void test_submodule_add__file_exists_in_index(void)
cl_git_fail_with(git_submodule_add_setup(&sm, g_repo, "./", "subdirectory", 1), GIT_EEXISTS);
git_submodule_free(sm);
- git_buf_dispose(&name);
+ git_str_dispose(&name);
}
void test_submodule_add__submodule_clone(void)
diff --git a/tests/submodule/escape.c b/tests/submodule/escape.c
index 08eb76809..bcd52b510 100644
--- a/tests/submodule/escape.c
+++ b/tests/submodule/escape.c
@@ -33,17 +33,17 @@ void test_submodule_escape__from_gitdir(void)
{
int foundit;
git_submodule *sm;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
unsigned int sm_location;
g_repo = setup_fixture_submodule_simple();
- cl_git_pass(git_buf_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules"));
+ cl_git_pass(git_str_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules"));
cl_git_rewritefile(buf.ptr,
"[submodule \"" EVIL_SM_NAME "\"]\n"
" path = testrepo\n"
" url = ../testrepo.git\n");
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
/* Find it all the different ways we know about it */
foundit = 0;
@@ -67,17 +67,17 @@ void test_submodule_escape__from_gitdir_windows(void)
{
int foundit;
git_submodule *sm;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
unsigned int sm_location;
g_repo = setup_fixture_submodule_simple();
- cl_git_pass(git_buf_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules"));
+ cl_git_pass(git_str_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules"));
cl_git_rewritefile(buf.ptr,
"[submodule \"" EVIL_SM_NAME_WINDOWS "\"]\n"
" path = testrepo\n"
" url = ../testrepo.git\n");
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
/* Find it all the different ways we know about it */
foundit = 0;
diff --git a/tests/submodule/init.c b/tests/submodule/init.c
index a1d870b9e..bf865a9e8 100644
--- a/tests/submodule/init.c
+++ b/tests/submodule/init.c
@@ -15,13 +15,13 @@ void test_submodule_init__absolute_url(void)
{
git_submodule *sm;
git_config *cfg;
- git_buf absolute_url = GIT_BUF_INIT;
+ git_str absolute_url = GIT_STR_INIT;
const char *config_url;
g_repo = setup_fixture_submodule_simple();
cl_assert(git_path_dirname_r(&absolute_url, git_repository_workdir(g_repo)) > 0);
- cl_git_pass(git_buf_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git"));
+ cl_git_pass(git_str_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git"));
/* write the absolute url to the .gitmodules file*/
cl_git_pass(git_submodule_set_url(g_repo, "testrepo", absolute_url.ptr));
@@ -39,7 +39,7 @@ void test_submodule_init__absolute_url(void)
cl_git_pass(git_config_get_string(&config_url, cfg, "submodule.testrepo.url"));
cl_assert_equal_s(absolute_url.ptr, config_url);
- git_buf_dispose(&absolute_url);
+ git_str_dispose(&absolute_url);
git_config_free(cfg);
git_submodule_free(sm);
}
@@ -48,13 +48,13 @@ void test_submodule_init__relative_url(void)
{
git_submodule *sm;
git_config *cfg;
- git_buf absolute_url = GIT_BUF_INIT;
+ git_str absolute_url = GIT_STR_INIT;
const char *config_url;
g_repo = setup_fixture_submodule_simple();
cl_assert(git_path_dirname_r(&absolute_url, git_repository_workdir(g_repo)) > 0);
- cl_git_pass(git_buf_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git"));
+ cl_git_pass(git_str_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git"));
cl_git_pass(git_submodule_lookup(&sm, g_repo, "testrepo"));
@@ -69,7 +69,7 @@ void test_submodule_init__relative_url(void)
cl_git_pass(git_config_get_string(&config_url, cfg, "submodule.testrepo.url"));
cl_assert_equal_s(absolute_url.ptr, config_url);
- git_buf_dispose(&absolute_url);
+ git_str_dispose(&absolute_url);
git_config_free(cfg);
git_submodule_free(sm);
}
@@ -78,7 +78,7 @@ void test_submodule_init__relative_url_detached_head(void)
{
git_submodule *sm;
git_config *cfg;
- git_buf absolute_url = GIT_BUF_INIT;
+ git_str absolute_url = GIT_STR_INIT;
const char *config_url;
git_reference *head_ref = NULL;
git_object *head_commit = NULL;
@@ -92,7 +92,7 @@ void test_submodule_init__relative_url_detached_head(void)
cl_git_pass(git_repository_set_head_detached(g_repo, git_commit_id((git_commit *)head_commit)));
cl_assert(git_path_dirname_r(&absolute_url, git_repository_workdir(g_repo)) > 0);
- cl_git_pass(git_buf_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git"));
+ cl_git_pass(git_str_joinpath(&absolute_url, absolute_url.ptr, "testrepo.git"));
cl_git_pass(git_submodule_lookup(&sm, g_repo, "testrepo"));
@@ -107,7 +107,7 @@ void test_submodule_init__relative_url_detached_head(void)
cl_git_pass(git_config_get_string(&config_url, cfg, "submodule.testrepo.url"));
cl_assert_equal_s(absolute_url.ptr, config_url);
- git_buf_dispose(&absolute_url);
+ git_str_dispose(&absolute_url);
git_config_free(cfg);
git_object_free(head_commit);
git_reference_free(head_ref);
diff --git a/tests/submodule/inject_option.c b/tests/submodule/inject_option.c
index cfc02acff..e28ff8489 100644
--- a/tests/submodule/inject_option.c
+++ b/tests/submodule/inject_option.c
@@ -33,14 +33,14 @@ void test_submodule_inject_option__url(void)
{
int foundit;
git_submodule *sm;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules"));
+ cl_git_pass(git_str_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules"));
cl_git_rewritefile(buf.ptr,
"[submodule \"naughty\"]\n"
" path = testrepo\n"
" url = -u./payload\n");
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
/* We do want to find it, but with the appropriate field empty */
foundit = 0;
@@ -58,14 +58,14 @@ void test_submodule_inject_option__path(void)
{
int foundit;
git_submodule *sm;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules"));
+ cl_git_pass(git_str_joinpath(&buf, git_repository_workdir(g_repo), ".gitmodules"));
cl_git_rewritefile(buf.ptr,
"[submodule \"naughty\"]\n"
" path = --something\n"
" url = blah.git\n");
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
/* We do want to find it, but with the appropriate field empty */
foundit = 0;
diff --git a/tests/submodule/lookup.c b/tests/submodule/lookup.c
index f49ebb4bd..acfdc838c 100644
--- a/tests/submodule/lookup.c
+++ b/tests/submodule/lookup.c
@@ -255,7 +255,7 @@ static void add_submodule_with_commit(const char *name)
git_submodule *sm;
git_repository *smrepo;
git_index *idx;
- git_buf p = GIT_BUF_INIT;
+ git_str p = GIT_STR_INIT;
cl_git_pass(git_submodule_add_setup(&sm, g_repo,
"https://github.com/libgit2/libgit2.git", name, 1));
@@ -265,9 +265,9 @@ static void add_submodule_with_commit(const char *name)
cl_git_pass(git_submodule_open(&smrepo, sm));
cl_git_pass(git_repository_index(&idx, smrepo));
- cl_git_pass(git_buf_joinpath(&p, git_repository_workdir(smrepo), "file"));
+ cl_git_pass(git_str_joinpath(&p, git_repository_workdir(smrepo), "file"));
cl_git_mkfile(p.ptr, "new file");
- git_buf_dispose(&p);
+ git_str_dispose(&p);
cl_git_pass(git_index_add_bypath(idx, "file"));
cl_git_pass(git_index_write(idx));
@@ -284,7 +284,7 @@ static void add_submodule_with_commit(const char *name)
void test_submodule_lookup__just_added(void)
{
git_submodule *sm;
- git_buf snap1 = GIT_BUF_INIT, snap2 = GIT_BUF_INIT;
+ git_str snap1 = GIT_STR_INIT, snap2 = GIT_STR_INIT;
git_reference *original_head = NULL;
refute_submodule_exists(g_repo, "sm_just_added", GIT_ENOTFOUND);
@@ -333,7 +333,7 @@ void test_submodule_lookup__just_added(void)
baseline_tests();
cl_git_rewritefile("submod2/.gitmodules", snap2.ptr);
- git_buf_dispose(&snap2);
+ git_str_dispose(&snap2);
refute_submodule_exists(g_repo, "mismatch_name", GIT_ENOTFOUND);
refute_submodule_exists(g_repo, "mismatch_path", GIT_ENOTFOUND);
@@ -344,7 +344,7 @@ void test_submodule_lookup__just_added(void)
baseline_tests();
cl_git_rewritefile("submod2/.gitmodules", snap1.ptr);
- git_buf_dispose(&snap1);
+ git_str_dispose(&snap1);
refute_submodule_exists(g_repo, "mismatch_name", GIT_ENOTFOUND);
refute_submodule_exists(g_repo, "mismatch_path", GIT_ENOTFOUND);
diff --git a/tests/submodule/modify.c b/tests/submodule/modify.c
index 654f677e6..fd3b0f80b 100644
--- a/tests/submodule/modify.c
+++ b/tests/submodule/modify.c
@@ -213,7 +213,7 @@ void test_submodule_modify__set_url(void)
void test_submodule_modify__set_relative_url(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_repository *repo;
git_submodule *sm;
@@ -222,12 +222,12 @@ void test_submodule_modify__set_relative_url(void)
cl_git_pass(git_submodule_sync(sm));
cl_git_pass(git_submodule_open(&repo, sm));
- cl_git_pass(git_buf_joinpath(&path, clar_sandbox_path(), "relative-url"));
+ cl_git_pass(git_str_joinpath(&path, clar_sandbox_path(), "relative-url"));
assert_config_entry_value(g_repo, "submodule."SM1".url", path.ptr);
assert_config_entry_value(repo, "remote.origin.url", path.ptr);
git_repository_free(repo);
git_submodule_free(sm);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
diff --git a/tests/submodule/nosubs.c b/tests/submodule/nosubs.c
index e47ee3983..e82230e87 100644
--- a/tests/submodule/nosubs.c
+++ b/tests/submodule/nosubs.c
@@ -69,7 +69,7 @@ void test_submodule_nosubs__add_and_delete(void)
{
git_repository *repo = cl_git_sandbox_init("status");
git_submodule *sm;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
cl_git_fail(git_submodule_lookup(NULL, repo, "libgit2"));
cl_git_fail(git_submodule_lookup(NULL, repo, "submodules/libgit2"));
@@ -85,7 +85,7 @@ void test_submodule_nosubs__add_and_delete(void)
cl_git_pass(git_futils_readbuffer(&buf, "status/.gitmodules"));
cl_assert(strstr(buf.ptr, "[submodule \"submodules/libgit2\"]") != NULL);
cl_assert(strstr(buf.ptr, "path = submodules/libgit2") != NULL);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
/* lookup */
diff --git a/tests/submodule/open.c b/tests/submodule/open.c
index a8a5dccc3..4f31feedf 100644
--- a/tests/submodule/open.c
+++ b/tests/submodule/open.c
@@ -23,33 +23,33 @@ void test_submodule_open__cleanup(void)
static void assert_sm_valid(git_repository *parent, git_repository *child, const char *sm_name)
{
- git_buf expected = GIT_BUF_INIT, actual = GIT_BUF_INIT;
+ git_str expected = GIT_STR_INIT, actual = GIT_STR_INIT;
/* assert working directory */
- cl_git_pass(git_buf_joinpath(&expected, git_repository_workdir(parent), sm_name));
+ cl_git_pass(git_str_joinpath(&expected, git_repository_workdir(parent), sm_name));
cl_git_pass(git_path_prettify_dir(&expected, expected.ptr, NULL));
- cl_git_pass(git_buf_sets(&actual, git_repository_workdir(child)));
+ cl_git_pass(git_str_sets(&actual, git_repository_workdir(child)));
cl_git_pass(git_path_prettify_dir(&actual, actual.ptr, NULL));
cl_assert_equal_s(expected.ptr, actual.ptr);
- git_buf_clear(&expected);
- git_buf_clear(&actual);
+ git_str_clear(&expected);
+ git_str_clear(&actual);
/* assert common directory */
- cl_git_pass(git_buf_joinpath(&expected, git_repository_commondir(parent), "modules"));
- cl_git_pass(git_buf_joinpath(&expected, expected.ptr, sm_name));
+ cl_git_pass(git_str_joinpath(&expected, git_repository_commondir(parent), "modules"));
+ cl_git_pass(git_str_joinpath(&expected, expected.ptr, sm_name));
cl_git_pass(git_path_prettify_dir(&expected, expected.ptr, NULL));
- cl_git_pass(git_buf_sets(&actual, git_repository_commondir(child)));
+ cl_git_pass(git_str_sets(&actual, git_repository_commondir(child)));
cl_git_pass(git_path_prettify_dir(&actual, actual.ptr, NULL));
cl_assert_equal_s(expected.ptr, actual.ptr);
/* assert git directory */
- cl_git_pass(git_buf_sets(&actual, git_repository_path(child)));
+ cl_git_pass(git_str_sets(&actual, git_repository_path(child)));
cl_git_pass(git_path_prettify_dir(&actual, actual.ptr, NULL));
cl_assert_equal_s(expected.ptr, actual.ptr);
- git_buf_dispose(&expected);
- git_buf_dispose(&actual);
+ git_str_dispose(&expected);
+ git_str_dispose(&actual);
}
void test_submodule_open__opening_via_lookup_succeeds(void)
@@ -61,18 +61,18 @@ void test_submodule_open__opening_via_lookup_succeeds(void)
void test_submodule_open__direct_open_succeeds(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_parent), "sm_unchanged"));
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_parent), "sm_unchanged"));
cl_git_pass(git_repository_open(&g_child, path.ptr));
assert_sm_valid(g_parent, g_child, "sm_unchanged");
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_submodule_open__direct_open_succeeds_for_broken_sm_with_gitdir(void)
{
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
/*
* This is actually not a valid submodule, but we
@@ -82,9 +82,9 @@ void test_submodule_open__direct_open_succeeds_for_broken_sm_with_gitdir(void)
* add a test for this.
*/
cl_git_mkfile("submod2/.git/modules/sm_unchanged/gitdir", ".git");
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_parent), "sm_unchanged"));
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_parent), "sm_unchanged"));
cl_git_pass(git_repository_open(&g_child, path.ptr));
assert_sm_valid(g_parent, g_child, "sm_unchanged");
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
diff --git a/tests/submodule/repository_init.c b/tests/submodule/repository_init.c
index 9962af311..3927afc2e 100644
--- a/tests/submodule/repository_init.c
+++ b/tests/submodule/repository_init.c
@@ -11,7 +11,7 @@ void test_submodule_repository_init__basic(void)
{
git_submodule *sm;
git_repository *repo;
- git_buf dot_git_content = GIT_BUF_INIT;
+ git_str dot_git_content = GIT_STR_INIT;
g_repo = setup_fixture_submod2();
@@ -34,5 +34,5 @@ void test_submodule_repository_init__basic(void)
git_submodule_free(sm);
git_repository_free(repo);
- git_buf_dispose(&dot_git_content);
+ git_str_dispose(&dot_git_content);
}
diff --git a/tests/submodule/status.c b/tests/submodule/status.c
index 06595cc9a..1d41337b7 100644
--- a/tests/submodule/status.c
+++ b/tests/submodule/status.c
@@ -31,10 +31,10 @@ void test_submodule_status__unchanged(void)
static void rm_submodule(const char *name)
{
- git_buf path = GIT_BUF_INIT;
- cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), name));
+ git_str path = GIT_STR_INIT;
+ cl_git_pass(git_str_joinpath(&path, git_repository_workdir(g_repo), name));
cl_git_pass(git_futils_rmdir_r(path.ptr, NULL, GIT_RMDIR_REMOVE_FILES));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
static void add_submodule_to_index(const char *name)
diff --git a/tests/submodule/submodule_helpers.c b/tests/submodule/submodule_helpers.c
index 1d4759616..95d20a009 100644
--- a/tests/submodule/submodule_helpers.c
+++ b/tests/submodule/submodule_helpers.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "path.h"
#include "util.h"
#include "posix.h"
@@ -12,12 +11,12 @@
*/
void rewrite_gitmodules(const char *workdir)
{
- git_buf in_f = GIT_BUF_INIT, out_f = GIT_BUF_INIT, path = GIT_BUF_INIT;
+ git_str in_f = GIT_STR_INIT, out_f = GIT_STR_INIT, path = GIT_STR_INIT;
FILE *in, *out;
char line[256];
- cl_git_pass(git_buf_joinpath(&in_f, workdir, "gitmodules"));
- cl_git_pass(git_buf_joinpath(&out_f, workdir, ".gitmodules"));
+ cl_git_pass(git_str_joinpath(&in_f, workdir, "gitmodules"));
+ cl_git_pass(git_str_joinpath(&out_f, workdir, ".gitmodules"));
cl_assert((in = fopen(in_f.ptr, "rb")) != NULL);
cl_assert((out = fopen(out_f.ptr, "wb")) != NULL);
@@ -32,16 +31,16 @@ void rewrite_gitmodules(const char *workdir)
scan += strlen("path =");
while (*scan == ' ') scan++;
- git_buf_joinpath(&path, workdir, scan);
- git_buf_rtrim(&path);
- git_buf_joinpath(&path, path.ptr, ".gitted");
+ git_str_joinpath(&path, workdir, scan);
+ git_str_rtrim(&path);
+ git_str_joinpath(&path, path.ptr, ".gitted");
- if (!git_buf_oom(&path) && p_access(path.ptr, F_OK) == 0) {
- git_buf_joinpath(&out_f, workdir, scan);
- git_buf_rtrim(&out_f);
- git_buf_joinpath(&out_f, out_f.ptr, ".git");
+ if (!git_str_oom(&path) && p_access(path.ptr, F_OK) == 0) {
+ git_str_joinpath(&out_f, workdir, scan);
+ git_str_rtrim(&out_f);
+ git_str_joinpath(&out_f, out_f.ptr, ".git");
- if (!git_buf_oom(&out_f))
+ if (!git_str_oom(&out_f))
p_rename(path.ptr, out_f.ptr);
}
}
@@ -57,18 +56,18 @@ void rewrite_gitmodules(const char *workdir)
while (*scan == ' ') scan++;
if (*scan == '.') {
- git_buf_joinpath(&path, workdir, scan);
- git_buf_rtrim(&path);
+ git_str_joinpath(&path, workdir, scan);
+ git_str_rtrim(&path);
} else if (!*scan || *scan == '\n') {
- git_buf_joinpath(&path, workdir, "../testrepo.git");
+ git_str_joinpath(&path, workdir, "../testrepo.git");
} else {
fputs(line, out);
continue;
}
git_path_prettify(&path, path.ptr, NULL);
- git_buf_putc(&path, '\n');
- cl_assert(!git_buf_oom(&path));
+ git_str_putc(&path, '\n');
+ cl_assert(!git_str_oom(&path));
fwrite(line, scan - line, sizeof(char), out);
fputs(path.ptr, out);
@@ -79,9 +78,9 @@ void rewrite_gitmodules(const char *workdir)
cl_must_pass(p_unlink(in_f.ptr));
- git_buf_dispose(&in_f);
- git_buf_dispose(&out_f);
- git_buf_dispose(&path);
+ git_str_dispose(&in_f);
+ git_str_dispose(&out_f);
+ git_str_dispose(&path);
}
static void cleanup_fixture_submodules(void *payload)
diff --git a/tests/valgrind-supp-mac.txt b/tests/valgrind-supp-mac.txt
index a104199e2..3298abee6 100644
--- a/tests/valgrind-supp-mac.txt
+++ b/tests/valgrind-supp-mac.txt
@@ -3,9 +3,9 @@
Memcheck:Leak
...
fun:git__realloc
- fun:git_buf_try_grow
- fun:git_buf_grow
- fun:git_buf_vprintf
+ fun:git_str_try_grow
+ fun:git_str_grow
+ fun:git_str_vprintf
fun:git_error_set
}
{
diff --git a/tests/win32/forbidden.c b/tests/win32/forbidden.c
index e02f41179..5c007987b 100644
--- a/tests/win32/forbidden.c
+++ b/tests/win32/forbidden.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "repository.h"
-#include "buffer.h"
#include "submodule.h"
static const char *repo_name = "win32-forbidden";
diff --git a/tests/win32/longpath.c b/tests/win32/longpath.c
index f8b8c4b0a..4be86db5a 100644
--- a/tests/win32/longpath.c
+++ b/tests/win32/longpath.c
@@ -2,11 +2,10 @@
#include "git2/clone.h"
#include "clone.h"
-#include "buffer.h"
#include "futils.h"
#include "repository.h"
-static git_buf path = GIT_BUF_INIT;
+static git_str path = GIT_STR_INIT;
#define LONG_FILENAME "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.txt"
@@ -18,20 +17,20 @@ void test_win32_longpath__initialize(void)
size_t remain = MAX_PATH - base_len;
size_t i;
- git_buf_clear(&path);
- git_buf_puts(&path, base);
- git_buf_putc(&path, '/');
+ git_str_clear(&path);
+ git_str_puts(&path, base);
+ git_str_putc(&path, '/');
cl_assert(remain < (MAX_PATH - 5));
for (i = 0; i < (remain - 5); i++)
- git_buf_putc(&path, 'a');
+ git_str_putc(&path, 'a');
#endif
}
void test_win32_longpath__cleanup(void)
{
- git_buf_dispose(&path);
+ git_str_dispose(&path);
cl_git_sandbox_cleanup();
}
@@ -49,7 +48,7 @@ void test_win32_longpath__workdir_path_validated(void)
{
#ifdef GIT_WIN32
git_repository *repo = cl_git_sandbox_init("testrepo");
- git_buf out = GIT_BUF_INIT;
+ git_str out = GIT_STR_INIT;
cl_git_pass(git_repository_workdir_path(&out, repo, "a.txt"));
@@ -60,7 +59,7 @@ void test_win32_longpath__workdir_path_validated(void)
cl_repo_set_bool(repo, "core.longpaths", true);
cl_git_pass(git_repository_workdir_path(&out, repo, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.txt"));
cl_git_pass(git_repository_workdir_path(&out, repo, LONG_FILENAME));
- git_buf_dispose(&out);
+ git_str_dispose(&out);
#endif
}
@@ -68,7 +67,7 @@ void test_win32_longpath__workdir_path_validated(void)
static void assert_longpath_status_and_add(git_repository *repo, const char *wddata, const char *repodata) {
git_index *index;
git_blob *blob;
- git_buf out = GIT_BUF_INIT;
+ git_str out = GIT_STR_INIT;
const git_index_entry *entry;
unsigned int status_flags;
@@ -91,7 +90,7 @@ static void assert_longpath_status_and_add(git_repository *repo, const char *wdd
git_blob_free(blob);
git_index_free(index);
- git_buf_dispose(&out);
+ git_str_dispose(&out);
}
#endif
diff --git a/tests/worktree/merge.c b/tests/worktree/merge.c
index 2a1206032..8bb95d1f7 100644
--- a/tests/worktree/merge.c
+++ b/tests/worktree/merge.c
@@ -57,7 +57,7 @@ void test_worktree_merge__merge_setup(void)
{
git_reference *ours_ref, *theirs_ref;
git_annotated_commit *ours, *theirs;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
unsigned i;
cl_git_pass(git_reference_lookup(&ours_ref, fixture.worktree, MASTER_BRANCH));
@@ -70,13 +70,13 @@ void test_worktree_merge__merge_setup(void)
ours, (const git_annotated_commit **)&theirs, 1));
for (i = 0; i < ARRAY_SIZE(merge_files); i++) {
- cl_git_pass(git_buf_joinpath(&path,
+ cl_git_pass(git_str_joinpath(&path,
fixture.worktree->gitdir,
merge_files[i]));
cl_assert(git_path_exists(path.ptr));
}
- git_buf_dispose(&path);
+ git_str_dispose(&path);
git_reference_free(ours_ref);
git_reference_free(theirs_ref);
git_annotated_commit_free(ours);
@@ -85,7 +85,7 @@ void test_worktree_merge__merge_setup(void)
void test_worktree_merge__merge_conflict(void)
{
- git_buf path = GIT_BUF_INIT, buf = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT, buf = GIT_STR_INIT;
git_reference *theirs_ref;
git_annotated_commit *theirs;
git_index *index;
@@ -111,11 +111,11 @@ void test_worktree_merge__merge_conflict(void)
git_annotated_commit_free(theirs);
git_index_free(index);
- cl_git_pass(git_buf_joinpath(&path, fixture.worktree->workdir, "branch_file.txt"));
+ cl_git_pass(git_str_joinpath(&path, fixture.worktree->workdir, "branch_file.txt"));
cl_git_pass(git_futils_readbuffer(&buf, path.ptr));
cl_assert_equal_s(buf.ptr, CONFLICT_BRANCH_FILE_TXT);
- git_buf_dispose(&path);
- git_buf_dispose(&buf);
+ git_str_dispose(&path);
+ git_str_dispose(&buf);
}
diff --git a/tests/worktree/open.c b/tests/worktree/open.c
index 52d47334c..0c3fdc173 100644
--- a/tests/worktree/open.c
+++ b/tests/worktree/open.c
@@ -55,17 +55,17 @@ void test_worktree_open__repository_through_gitlink(void)
void test_worktree_open__repository_through_gitdir(void)
{
- git_buf gitdir_path = GIT_BUF_INIT;
+ git_str gitdir_path = GIT_STR_INIT;
git_repository *wt;
- cl_git_pass(git_buf_joinpath(&gitdir_path, COMMON_REPO, ".git"));
- cl_git_pass(git_buf_joinpath(&gitdir_path, gitdir_path.ptr, "worktrees"));
- cl_git_pass(git_buf_joinpath(&gitdir_path, gitdir_path.ptr, "testrepo-worktree"));
+ cl_git_pass(git_str_joinpath(&gitdir_path, COMMON_REPO, ".git"));
+ cl_git_pass(git_str_joinpath(&gitdir_path, gitdir_path.ptr, "worktrees"));
+ cl_git_pass(git_str_joinpath(&gitdir_path, gitdir_path.ptr, "testrepo-worktree"));
cl_git_pass(git_repository_open(&wt, gitdir_path.ptr));
assert_worktree_valid(wt, COMMON_REPO, WORKTREE_REPO);
- git_buf_dispose(&gitdir_path);
+ git_str_dispose(&gitdir_path);
git_repository_free(wt);
}
diff --git a/tests/worktree/refs.c b/tests/worktree/refs.c
index 27dc667ea..5ae17ca19 100644
--- a/tests/worktree/refs.c
+++ b/tests/worktree/refs.c
@@ -177,9 +177,9 @@ void test_worktree_refs__creating_refs_uses_commondir(void)
{
git_reference *head, *branch, *lookup;
git_commit *commit;
- git_buf refpath = GIT_BUF_INIT;
+ git_str refpath = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&refpath,
+ cl_git_pass(git_str_joinpath(&refpath,
git_repository_commondir(fixture.worktree), "refs/heads/testbranch"));
cl_assert(!git_path_exists(refpath.ptr));
@@ -194,5 +194,5 @@ void test_worktree_refs__creating_refs_uses_commondir(void)
git_reference_free(branch);
git_reference_free(head);
git_commit_free(commit);
- git_buf_dispose(&refpath);
+ git_str_dispose(&refpath);
}
diff --git a/tests/worktree/submodule.c b/tests/worktree/submodule.c
index 2e62c039c..4c6c657d3 100644
--- a/tests/worktree/submodule.c
+++ b/tests/worktree/submodule.c
@@ -61,14 +61,14 @@ void test_worktree_submodule__open_discovered_submodule_worktree(void)
void test_worktree_submodule__resolve_relative_url(void)
{
- git_buf wt_path = GIT_BUF_INIT;
+ git_str wt_path = GIT_STR_INIT;
git_buf sm_relative_path = GIT_BUF_INIT, wt_relative_path = GIT_BUF_INIT;
git_repository *repo;
git_worktree *wt;
cl_git_pass(git_futils_mkdir("subdir", 0755, GIT_MKDIR_PATH));
cl_git_pass(git_path_prettify_dir(&wt_path, "subdir", NULL));
- cl_git_pass(git_buf_joinpath(&wt_path, wt_path.ptr, "wt"));
+ cl_git_pass(git_str_joinpath(&wt_path, wt_path.ptr, "wt"));
/* Open child repository, which is a submodule */
cl_git_pass(git_repository_open(&child.repo, WORKTREE_CHILD));
@@ -86,7 +86,7 @@ void test_worktree_submodule__resolve_relative_url(void)
git_worktree_free(wt);
git_repository_free(repo);
- git_buf_dispose(&wt_path);
+ git_str_dispose(&wt_path);
git_buf_dispose(&sm_relative_path);
git_buf_dispose(&wt_relative_path);
}
diff --git a/tests/worktree/worktree.c b/tests/worktree/worktree.c
index 9b87bfae6..a9a50fbf1 100644
--- a/tests/worktree/worktree.c
+++ b/tests/worktree/worktree.c
@@ -40,11 +40,11 @@ void test_worktree_worktree__list_with_invalid_worktree_dirs(void)
{ "gitdir", "HEAD" },
{ "HEAD", "commondir" },
};
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_strarray wts;
size_t i, j, len;
- cl_git_pass(git_buf_joinpath(&path,
+ cl_git_pass(git_str_joinpath(&path,
fixture.repo->commondir,
"worktrees/invalid"));
cl_git_pass(p_mkdir(path.ptr, 0755));
@@ -54,8 +54,8 @@ void test_worktree_worktree__list_with_invalid_worktree_dirs(void)
for (i = 0; i < ARRAY_SIZE(filesets); i++) {
for (j = 0; j < ARRAY_SIZE(filesets[i]); j++) {
- git_buf_truncate(&path, len);
- cl_git_pass(git_buf_joinpath(&path, path.ptr, filesets[i][j]));
+ git_str_truncate(&path, len);
+ cl_git_pass(git_str_joinpath(&path, path.ptr, filesets[i][j]));
cl_git_pass(p_close(p_creat(path.ptr, 0644)));
}
@@ -65,13 +65,13 @@ void test_worktree_worktree__list_with_invalid_worktree_dirs(void)
git_strarray_dispose(&wts);
for (j = 0; j < ARRAY_SIZE(filesets[i]); j++) {
- git_buf_truncate(&path, len);
- cl_git_pass(git_buf_joinpath(&path, path.ptr, filesets[i][j]));
+ git_str_truncate(&path, len);
+ cl_git_pass(git_str_joinpath(&path, path.ptr, filesets[i][j]));
p_unlink(path.ptr);
}
}
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_worktree_worktree__list_in_worktree_repo(void)
@@ -100,11 +100,11 @@ void test_worktree_worktree__list_without_worktrees(void)
void test_worktree_worktree__lookup(void)
{
git_worktree *wt;
- git_buf gitdir_path = GIT_BUF_INIT;
+ git_str gitdir_path = GIT_STR_INIT;
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
- cl_git_pass(git_buf_joinpath(&gitdir_path, fixture.repo->commondir, "worktrees/testrepo-worktree/"));
+ cl_git_pass(git_str_joinpath(&gitdir_path, fixture.repo->commondir, "worktrees/testrepo-worktree/"));
cl_assert_equal_s(wt->gitdir_path, gitdir_path.ptr);
cl_assert_equal_s(wt->parent_path, fixture.repo->workdir);
@@ -112,7 +112,7 @@ void test_worktree_worktree__lookup(void)
cl_assert_equal_s(wt->commondir_path, fixture.repo->gitdir);
cl_assert_equal_s(wt->commondir_path, fixture.repo->commondir);
- git_buf_dispose(&gitdir_path);
+ git_str_dispose(&gitdir_path);
git_worktree_free(wt);
}
@@ -143,10 +143,10 @@ void test_worktree_worktree__open_invalid_commondir(void)
{
git_worktree *wt;
git_repository *repo;
- git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT, path = GIT_STR_INIT;
- cl_git_pass(git_buf_sets(&buf, "/path/to/nonexistent/commondir"));
- cl_git_pass(git_buf_joinpath(&path,
+ cl_git_pass(git_str_sets(&buf, "/path/to/nonexistent/commondir"));
+ cl_git_pass(git_str_joinpath(&path,
fixture.repo->commondir,
"worktrees/testrepo-worktree/commondir"));
cl_git_pass(git_futils_writebuffer(&buf, path.ptr, O_RDWR, 0644));
@@ -154,8 +154,8 @@ void test_worktree_worktree__open_invalid_commondir(void)
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
cl_git_fail(git_repository_open_from_worktree(&repo, wt));
- git_buf_dispose(&buf);
- git_buf_dispose(&path);
+ git_str_dispose(&buf);
+ git_str_dispose(&path);
git_worktree_free(wt);
}
@@ -163,10 +163,10 @@ void test_worktree_worktree__open_invalid_gitdir(void)
{
git_worktree *wt;
git_repository *repo;
- git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT, path = GIT_STR_INIT;
- cl_git_pass(git_buf_sets(&buf, "/path/to/nonexistent/gitdir"));
- cl_git_pass(git_buf_joinpath(&path,
+ cl_git_pass(git_str_sets(&buf, "/path/to/nonexistent/gitdir"));
+ cl_git_pass(git_str_joinpath(&path,
fixture.repo->commondir,
"worktrees/testrepo-worktree/gitdir"));
cl_git_pass(git_futils_writebuffer(&buf, path.ptr, O_RDWR, 0644));
@@ -174,8 +174,8 @@ void test_worktree_worktree__open_invalid_gitdir(void)
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
cl_git_fail(git_repository_open_from_worktree(&repo, wt));
- git_buf_dispose(&buf);
- git_buf_dispose(&path);
+ git_str_dispose(&buf);
+ git_str_dispose(&path);
git_worktree_free(wt);
}
@@ -183,16 +183,16 @@ void test_worktree_worktree__open_invalid_parent(void)
{
git_worktree *wt;
git_repository *repo;
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_sets(&buf, "/path/to/nonexistent/gitdir"));
+ cl_git_pass(git_str_sets(&buf, "/path/to/nonexistent/gitdir"));
cl_git_pass(git_futils_writebuffer(&buf,
fixture.worktree->gitlink, O_RDWR, 0644));
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
cl_git_fail(git_repository_open_from_worktree(&repo, wt));
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
git_worktree_free(wt);
}
@@ -201,9 +201,9 @@ void test_worktree_worktree__init(void)
git_worktree *wt;
git_repository *repo;
git_reference *branch;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&path, fixture.repo->workdir, "../worktree-new"));
+ cl_git_pass(git_str_joinpath(&path, fixture.repo->workdir, "../worktree-new"));
cl_git_pass(git_worktree_add(&wt, fixture.repo, "worktree-new", path.ptr, NULL));
/* Open and verify created repo */
@@ -211,7 +211,7 @@ void test_worktree_worktree__init(void)
cl_assert(git__suffixcmp(git_repository_workdir(repo), "worktree-new/") == 0);
cl_git_pass(git_branch_lookup(&branch, repo, "worktree-new", GIT_BRANCH_LOCAL));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
git_worktree_free(wt);
git_reference_free(branch);
git_repository_free(repo);
@@ -222,12 +222,12 @@ void test_worktree_worktree__add_locked(void)
git_worktree *wt;
git_repository *repo;
git_reference *branch;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_worktree_add_options opts = GIT_WORKTREE_ADD_OPTIONS_INIT;
opts.lock = 1;
- cl_git_pass(git_buf_joinpath(&path, fixture.repo->workdir, "../worktree-locked"));
+ cl_git_pass(git_str_joinpath(&path, fixture.repo->workdir, "../worktree-locked"));
cl_git_pass(git_worktree_add(&wt, fixture.repo, "worktree-locked", path.ptr, &opts));
/* Open and verify created repo */
@@ -236,7 +236,7 @@ void test_worktree_worktree__add_locked(void)
cl_assert(git__suffixcmp(git_repository_workdir(repo), "worktree-locked/") == 0);
cl_git_pass(git_branch_lookup(&branch, repo, "worktree-locked", GIT_BRANCH_LOCAL));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
git_worktree_free(wt);
git_reference_free(branch);
git_repository_free(repo);
@@ -247,16 +247,16 @@ void test_worktree_worktree__init_existing_branch(void)
git_reference *head, *branch;
git_commit *commit;
git_worktree *wt;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cl_git_pass(git_repository_head(&head, fixture.repo));
cl_git_pass(git_commit_lookup(&commit, fixture.repo, &head->target.oid));
cl_git_pass(git_branch_create(&branch, fixture.repo, "worktree-new", commit, false));
- cl_git_pass(git_buf_joinpath(&path, fixture.repo->workdir, "../worktree-new"));
+ cl_git_pass(git_str_joinpath(&path, fixture.repo->workdir, "../worktree-new"));
cl_git_fail(git_worktree_add(&wt, fixture.repo, "worktree-new", path.ptr, NULL));
- git_buf_dispose(&path);
+ git_str_dispose(&path);
git_commit_free(commit);
git_reference_free(head);
git_reference_free(branch);
@@ -268,7 +268,7 @@ void test_worktree_worktree__add_with_explicit_branch(void)
git_commit *commit;
git_worktree *wt;
git_repository *wtrepo;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
git_worktree_add_options opts = GIT_WORKTREE_ADD_OPTIONS_INIT;
cl_git_pass(git_repository_head(&head, fixture.repo));
@@ -277,13 +277,13 @@ void test_worktree_worktree__add_with_explicit_branch(void)
opts.ref = branch;
- cl_git_pass(git_buf_joinpath(&path, fixture.repo->workdir, "../worktree-with-different-name"));
+ cl_git_pass(git_str_joinpath(&path, fixture.repo->workdir, "../worktree-with-different-name"));
cl_git_pass(git_worktree_add(&wt, fixture.repo, "worktree-with-different-name", path.ptr, &opts));
cl_git_pass(git_repository_open_from_worktree(&wtrepo, wt));
cl_git_pass(git_repository_head(&wthead, wtrepo));
cl_assert_equal_s(git_reference_name(wthead), "refs/heads/worktree-with-ref");
- git_buf_dispose(&path);
+ git_str_dispose(&path);
git_commit_free(commit);
git_reference_free(head);
git_reference_free(branch);
@@ -296,15 +296,15 @@ void test_worktree_worktree__add_with_explicit_branch(void)
void test_worktree_worktree__init_existing_worktree(void)
{
git_worktree *wt;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&path, fixture.repo->workdir, "../worktree-new"));
+ cl_git_pass(git_str_joinpath(&path, fixture.repo->workdir, "../worktree-new"));
cl_git_fail(git_worktree_add(&wt, fixture.repo, "testrepo-worktree", path.ptr, NULL));
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
cl_assert_equal_s(wt->gitlink_path, fixture.worktree->gitlink);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
git_worktree_free(wt);
}
@@ -312,42 +312,42 @@ void test_worktree_worktree__init_existing_path(void)
{
const char *wtfiles[] = { "HEAD", "commondir", "gitdir", "index" };
git_worktree *wt;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
unsigned i;
/* Delete files to verify they have not been created by
* the init call */
for (i = 0; i < ARRAY_SIZE(wtfiles); i++) {
- cl_git_pass(git_buf_joinpath(&path,
+ cl_git_pass(git_str_joinpath(&path,
fixture.worktree->gitdir, wtfiles[i]));
cl_git_pass(p_unlink(path.ptr));
}
- cl_git_pass(git_buf_joinpath(&path, fixture.repo->workdir, "../testrepo-worktree"));
+ cl_git_pass(git_str_joinpath(&path, fixture.repo->workdir, "../testrepo-worktree"));
cl_git_fail(git_worktree_add(&wt, fixture.repo, "worktree-new", path.ptr, NULL));
/* Verify files have not been re-created */
for (i = 0; i < ARRAY_SIZE(wtfiles); i++) {
- cl_git_pass(git_buf_joinpath(&path,
+ cl_git_pass(git_str_joinpath(&path,
fixture.worktree->gitdir, wtfiles[i]));
cl_assert(!git_path_exists(path.ptr));
}
- git_buf_dispose(&path);
+ git_str_dispose(&path);
}
void test_worktree_worktree__init_submodule(void)
{
git_repository *repo, *sm, *wt;
git_worktree *worktree;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
cleanup_fixture_worktree(&fixture);
repo = setup_fixture_submod2();
- cl_git_pass(git_buf_joinpath(&path, repo->workdir, "sm_unchanged"));
+ cl_git_pass(git_str_joinpath(&path, repo->workdir, "sm_unchanged"));
cl_git_pass(git_repository_open(&sm, path.ptr));
- cl_git_pass(git_buf_joinpath(&path, repo->workdir, "../worktree/"));
+ cl_git_pass(git_str_joinpath(&path, repo->workdir, "../worktree/"));
cl_git_pass(git_worktree_add(&worktree, sm, "repo-worktree", path.ptr, NULL));
cl_git_pass(git_repository_open_from_worktree(&wt, worktree));
@@ -356,10 +356,10 @@ void test_worktree_worktree__init_submodule(void)
cl_git_pass(git_path_prettify_dir(&path, sm->commondir, NULL));
cl_assert_equal_s(sm->commondir, wt->commondir);
- cl_git_pass(git_buf_joinpath(&path, sm->gitdir, "worktrees/repo-worktree/"));
+ cl_git_pass(git_str_joinpath(&path, sm->gitdir, "worktrees/repo-worktree/"));
cl_assert_equal_s(path.ptr, wt->gitdir);
- git_buf_dispose(&path);
+ git_str_dispose(&path);
git_worktree_free(worktree);
git_repository_free(sm);
git_repository_free(wt);
@@ -388,13 +388,13 @@ void test_worktree_worktree__name(void)
void test_worktree_worktree__path(void)
{
git_worktree *wt;
- git_buf expected_path = GIT_BUF_INIT;
+ git_str expected_path = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&expected_path, clar_sandbox_path(), "testrepo-worktree"));
+ cl_git_pass(git_str_joinpath(&expected_path, clar_sandbox_path(), "testrepo-worktree"));
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
cl_assert_equal_s(git_worktree_path(wt), expected_path.ptr);
- git_buf_dispose(&expected_path);
+ git_str_dispose(&expected_path);
git_worktree_free(wt);
}