summaryrefslogtreecommitdiff
path: root/tests/diff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-09-07 17:53:49 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2021-10-17 09:49:01 -0400
commitf0e693b18afbe1de37d7da5b5a8967b6c87d8e53 (patch)
treebe5e1cdbfa218ba81ec06bf45e45cfeb7f79a2a5 /tests/diff
parent5346be3ddd3bcf19779c5d62e71f8442a0171133 (diff)
downloadlibgit2-ethomson/gitstr.tar.gz
str: introduce `git_str` for internal, `git_buf` is externalethomson/gitstr
libgit2 has two distinct requirements that were previously solved by `git_buf`. We require: 1. A general purpose string class that provides a number of utility APIs for manipulating data (eg, concatenating, truncating, etc). 2. A structure that we can use to return strings to callers that they can take ownership of. By using a single class (`git_buf`) for both of these purposes, we have confused the API to the point that refactorings are difficult and reasoning about correctness is also difficult. Move the utility class `git_buf` to be called `git_str`: this represents its general purpose, as an internal string buffer class. The name also is an homage to Junio Hamano ("gitstr"). The public API remains `git_buf`, and has a much smaller footprint. It is generally only used as an "out" param with strict requirements that follow the documentation. (Exceptions exist for some legacy APIs to avoid breaking callers unnecessarily.) Utility functions exist to convert a user-specified `git_buf` to a `git_str` so that we can call internal functions, then converting it back again.
Diffstat (limited to 'tests/diff')
-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
10 files changed, 139 insertions, 142 deletions
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);