summaryrefslogtreecommitdiff
path: root/tests/merge
diff options
context:
space:
mode:
Diffstat (limited to 'tests/merge')
-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
16 files changed, 126 insertions, 127 deletions
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]);