summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-05-28 00:12:47 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2020-05-29 11:33:58 +0100
commit5d012010943d324386ca9d443102748a7763a6d1 (patch)
tree4b9e116c1a17c1a6c68bf0454c8781c11c5470e7
parentc6da855966f5f7a577c6edcc570977d4200e031c (diff)
downloadlibgit2-5d012010943d324386ca9d443102748a7763a6d1.tar.gz
filter: user-facing functions write to a userbuf
-rw-r--r--include/git2/filter.h12
-rw-r--r--include/git2/sys/filter.h8
-rw-r--r--include/git2/userbuf.h7
-rw-r--r--src/blob.c4
-rw-r--r--src/checkout.c2
-rw-r--r--src/crlf.c10
-rw-r--r--src/diff_file.c2
-rw-r--r--src/filter.c29
-rw-r--r--src/ident.c10
-rw-r--r--src/odb.c6
-rw-r--r--src/reader.c2
-rw-r--r--tests/filter/crlf.c24
-rw-r--r--tests/filter/custom.c18
-rw-r--r--tests/filter/custom_helpers.c20
-rw-r--r--tests/filter/file.c6
-rw-r--r--tests/filter/ident.c4
-rw-r--r--tests/filter/wildcard.c36
-rw-r--r--tests/object/blob/filter.c6
18 files changed, 104 insertions, 102 deletions
diff --git a/include/git2/filter.h b/include/git2/filter.h
index 886059051..01a8e86a8 100644
--- a/include/git2/filter.h
+++ b/include/git2/filter.h
@@ -122,7 +122,7 @@ GIT_EXTERN(int) git_filter_list_contains(
/**
* Apply filter list to a data buffer.
*
- * See `git2/buffer.h` for background on `git_buf` objects.
+ * See `git2/userbuf.h` for background on `git_userbuf` objects.
*
* If the `in` buffer holds data allocated by libgit2 (i.e. `in->asize` is
* not zero), then it will be overwritten when applying the filters. If
@@ -140,9 +140,9 @@ GIT_EXTERN(int) git_filter_list_contains(
* @return 0 on success, an error code otherwise
*/
GIT_EXTERN(int) git_filter_list_apply_to_data(
- git_buf *out,
+ git_userbuf *out,
git_filter_list *filters,
- git_buf *in);
+ git_userbuf *in);
/**
* Apply a filter list to the contents of a file on disk
@@ -154,7 +154,7 @@ GIT_EXTERN(int) git_filter_list_apply_to_data(
* taken as relative to the workdir
*/
GIT_EXTERN(int) git_filter_list_apply_to_file(
- git_buf *out,
+ git_userbuf *out,
git_filter_list *filters,
git_repository *repo,
const char *path);
@@ -167,7 +167,7 @@ GIT_EXTERN(int) git_filter_list_apply_to_file(
* @param blob the blob to filter
*/
GIT_EXTERN(int) git_filter_list_apply_to_blob(
- git_buf *out,
+ git_userbuf *out,
git_filter_list *filters,
git_blob *blob);
@@ -180,7 +180,7 @@ GIT_EXTERN(int) git_filter_list_apply_to_blob(
*/
GIT_EXTERN(int) git_filter_list_stream_data(
git_filter_list *filters,
- git_buf *data,
+ git_userbuf *data,
git_writestream *target);
/**
diff --git a/include/git2/sys/filter.h b/include/git2/sys/filter.h
index e43fde55c..7ad2945aa 100644
--- a/include/git2/sys/filter.h
+++ b/include/git2/sys/filter.h
@@ -191,10 +191,10 @@ typedef int GIT_CALLBACK(git_filter_check_fn)(
* `check` callback. It may be read from or written to as needed.
*/
typedef int GIT_CALLBACK(git_filter_apply_fn)(
- git_filter *self,
- void **payload, /* may be read and/or set */
- git_buf *to,
- const git_buf *from,
+ git_filter *self,
+ void **payload, /* may be read and/or set */
+ git_userbuf *to,
+ const git_userbuf *from,
const git_filter_source *src);
typedef int GIT_CALLBACK(git_filter_stream_fn)(
diff --git a/include/git2/userbuf.h b/include/git2/userbuf.h
index 2e6c72799..4fe8ccf47 100644
--- a/include/git2/userbuf.h
+++ b/include/git2/userbuf.h
@@ -18,11 +18,12 @@
*/
GIT_BEGIN_DECL
-/**
- * An optional initialization macro for `git_userbuf` objects.
- */
+/** An optional initialization macro for `git_userbuf` objects. */
#define GIT_USERBUF_INIT { NULL, 0, 0 }
+/** A constant initialization macro for `git_userbuf` objects. */
+#define GIT_USERBUF_CONST(str, len) { (char *)(str), 0, (size_t)(len) }
+
/**
* A data buffer for exporting data from libgit2.
*
diff --git a/src/blob.c b/src/blob.c
index fa8a2aaf9..17f861a50 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -138,7 +138,7 @@ static int write_file_filtered(
int error;
git_buf tgt = GIT_BUF_INIT;
- error = git_filter_list_apply_to_file(&tgt, fl, NULL, full_path);
+ error = git_filter_list_apply_to_file((git_userbuf *)&tgt, fl, NULL, full_path);
/* Write the file to disk if it was properly filtered */
if (!error) {
@@ -434,7 +434,7 @@ static int git_blob__filter(
&fl, git_blob_owner(blob), blob, path,
GIT_FILTER_TO_WORKTREE, flags))) {
- error = git_filter_list_apply_to_blob(out, fl, blob);
+ error = git_filter_list_apply_to_blob((git_userbuf *)out, fl, blob);
git_filter_list_free(fl);
}
diff --git a/src/checkout.c b/src/checkout.c
index 272bd3789..8c517dbbd 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -2156,7 +2156,7 @@ static int checkout_write_merge(
if ((error = git_filter_list__load_ext(
&fl, data->repo, NULL, git_buf_cstr(&path_workdir),
GIT_FILTER_TO_WORKTREE, &filter_opts)) < 0 ||
- (error = git_filter_list_apply_to_data(&out_data, fl, &in_data)) < 0)
+ (error = git_filter_list_apply_to_data((git_userbuf *)&out_data, fl, (git_userbuf *)&in_data)) < 0)
goto done;
} else {
out_data.ptr = (char *)result.ptr;
diff --git a/src/crlf.c b/src/crlf.c
index 81b5216bc..f89325762 100644
--- a/src/crlf.c
+++ b/src/crlf.c
@@ -247,7 +247,7 @@ static int crlf_apply_to_odb(
return GIT_PASSTHROUGH;
/* Actually drop the carriage returns */
- return git_buf_text_crlf_to_lf(to, from);
+ return git_buf_text_crlf_to_lf((git_buf *)to, from);
}
static int crlf_apply_to_workdir(
@@ -369,8 +369,8 @@ static int crlf_check(
static int crlf_apply(
git_filter *self,
void **payload, /* may be read and/or set */
- git_buf *to,
- const git_buf *from,
+ git_userbuf *to,
+ const git_userbuf *from,
const git_filter_source *src)
{
/* initialize payload in case `check` was bypassed */
@@ -382,9 +382,9 @@ static int crlf_apply(
}
if (git_filter_source_mode(src) == GIT_FILTER_SMUDGE)
- return crlf_apply_to_workdir(*payload, to, from);
+ return crlf_apply_to_workdir(*payload, (git_buf *)to, (git_buf *)from);
else
- return crlf_apply_to_odb(*payload, to, from, src);
+ return crlf_apply_to_odb(*payload, (git_buf *)to, (git_buf *)from, src);
}
static void crlf_cleanup(
diff --git a/src/diff_file.c b/src/diff_file.c
index 621bff556..0ec6aa238 100644
--- a/src/diff_file.c
+++ b/src/diff_file.c
@@ -360,7 +360,7 @@ static int diff_file_content_load_workdir_file(
if (!(error = git_futils_readbuffer_fd(&raw, fd, (size_t)fc->file->size))) {
git_buf out = GIT_BUF_INIT;
- error = git_filter_list_apply_to_data(&out, fl, &raw);
+ error = git_filter_list_apply_to_data((git_userbuf *)&out, fl, (git_userbuf *)&raw);
if (out.ptr != raw.ptr)
git_buf_dispose(&raw);
diff --git a/src/filter.c b/src/filter.c
index bb9d66ad6..49dedf55c 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -17,6 +17,7 @@
#include "blob.h"
#include "attr_file.h"
#include "array.h"
+#include "userbuf.h"
struct git_filter_source {
git_repository *repo;
@@ -720,20 +721,20 @@ static void buf_stream_init(struct buf_stream *writer, git_buf *target)
}
int git_filter_list_apply_to_data(
- git_buf *tgt, git_filter_list *filters, git_buf *src)
+ git_userbuf *tgt, git_filter_list *filters, git_userbuf *src)
{
struct buf_stream writer;
int error;
- git_buf_sanitize(tgt);
- git_buf_sanitize(src);
+ git_userbuf_sanitize(tgt);
+ git_userbuf_sanitize(src);
if (!filters) {
- git_buf_attach_notowned(tgt, src->ptr, src->size);
+ git_buf_attach_notowned((git_buf *)tgt, src->ptr, src->size);
return 0;
}
- buf_stream_init(&writer, tgt);
+ buf_stream_init(&writer, (git_buf *)tgt);
if ((error = git_filter_list_stream_data(filters, src,
&writer.parent)) < 0)
@@ -744,7 +745,7 @@ int git_filter_list_apply_to_data(
}
int git_filter_list_apply_to_file(
- git_buf *out,
+ git_userbuf *out,
git_filter_list *filters,
git_repository *repo,
const char *path)
@@ -752,7 +753,7 @@ int git_filter_list_apply_to_file(
struct buf_stream writer;
int error;
- buf_stream_init(&writer, out);
+ buf_stream_init(&writer, (git_buf *)out);
if ((error = git_filter_list_stream_file(
filters, repo, path, &writer.parent)) < 0)
@@ -776,14 +777,14 @@ static int buf_from_blob(git_buf *out, git_blob *blob)
}
int git_filter_list_apply_to_blob(
- git_buf *out,
+ git_userbuf *out,
git_filter_list *filters,
git_blob *blob)
{
struct buf_stream writer;
int error;
- buf_stream_init(&writer, out);
+ buf_stream_init(&writer, (git_buf *)out);
if ((error = git_filter_list_stream_blob(
filters, blob, &writer.parent)) < 0)
@@ -825,8 +826,8 @@ static int proxy_stream_close(git_writestream *s)
error = proxy_stream->filter->apply(
proxy_stream->filter,
proxy_stream->payload,
- proxy_stream->output,
- &proxy_stream->input,
+ (git_userbuf *)proxy_stream->output,
+ (git_userbuf *)&proxy_stream->input,
proxy_stream->source);
if (error == GIT_PASSTHROUGH) {
@@ -997,14 +998,14 @@ done:
int git_filter_list_stream_data(
git_filter_list *filters,
- git_buf *data,
+ git_userbuf *data,
git_writestream *target)
{
git_vector filter_streams = GIT_VECTOR_INIT;
git_writestream *stream_start;
int error, initialized = 0;
- git_buf_sanitize(data);
+ git_userbuf_sanitize(data);
if ((error = stream_list_init(&stream_start, &filter_streams, filters, target)) < 0)
goto out;
@@ -1035,7 +1036,7 @@ int git_filter_list_stream_blob(
if (filters)
git_oid_cpy(&filters->source.oid, git_blob_id(blob));
- return git_filter_list_stream_data(filters, &in, target);
+ return git_filter_list_stream_data(filters, (git_userbuf *)&in, target);
}
int git_filter_init(git_filter *filter, unsigned int version)
diff --git a/src/ident.c b/src/ident.c
index 7eccf9a43..521e93ae7 100644
--- a/src/ident.c
+++ b/src/ident.c
@@ -98,20 +98,20 @@ static int ident_remove_id(
static int ident_apply(
git_filter *self,
void **payload,
- git_buf *to,
- const git_buf *from,
+ git_userbuf *to,
+ const git_userbuf *from,
const git_filter_source *src)
{
GIT_UNUSED(self); GIT_UNUSED(payload);
/* Don't filter binary files */
- if (git_buf_text_is_binary(from))
+ if (git_buf_text_is_binary((git_buf *)from))
return GIT_PASSTHROUGH;
if (git_filter_source_mode(src) == GIT_FILTER_SMUDGE)
- return ident_insert_id(to, from, src);
+ return ident_insert_id((git_buf *)to, (git_buf *)from, src);
else
- return ident_remove_id(to, from);
+ return ident_remove_id((git_buf *)to, (git_buf *)from);
}
git_filter *git_ident_filter_new(void)
diff --git a/src/odb.c b/src/odb.c
index 68d9a9a3f..87d9c9555 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -257,16 +257,16 @@ int git_odb__hashfd_filtered(
*/
if (!(error = git_futils_readbuffer_fd(&raw, fd, size))) {
- git_buf post = GIT_BUF_INIT;
+ git_userbuf post = GIT_BUF_INIT;
- error = git_filter_list_apply_to_data(&post, fl, &raw);
+ error = git_filter_list_apply_to_data(&post, fl, (git_userbuf *)&raw);
git_buf_dispose(&raw);
if (!error)
error = git_odb_hash(out, post.ptr, post.size, type);
- git_buf_dispose(&post);
+ git_userbuf_dispose(&post);
}
return error;
diff --git a/src/reader.c b/src/reader.c
index 90f700a00..543c20e74 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -120,7 +120,7 @@ static int workdir_reader_read(
GIT_FILTER_TO_ODB, GIT_FILTER_DEFAULT)) < 0)
goto done;
- if ((error = git_filter_list_apply_to_file(out,
+ if ((error = git_filter_list_apply_to_file((git_userbuf *)out,
filters, reader->repo, path.ptr)) < 0)
goto done;
diff --git a/tests/filter/crlf.c b/tests/filter/crlf.c
index a266005d4..867655c5c 100644
--- a/tests/filter/crlf.c
+++ b/tests/filter/crlf.c
@@ -23,7 +23,7 @@ void test_filter_crlf__to_worktree(void)
{
git_filter_list *fl;
git_filter *crlf;
- git_buf in = { 0 }, out = { 0 };
+ git_userbuf in = GIT_USERBUF_INIT, out = GIT_USERBUF_INIT;
cl_git_pass(git_filter_list_new(
&fl, g_repo, GIT_FILTER_TO_WORKTREE, 0));
@@ -41,14 +41,14 @@ void test_filter_crlf__to_worktree(void)
cl_assert_equal_s("Some text\r\nRight here\r\n", out.ptr);
git_filter_list_free(fl);
- git_buf_dispose(&out);
+ git_userbuf_dispose(&out);
}
void test_filter_crlf__to_odb(void)
{
git_filter_list *fl;
git_filter *crlf;
- git_buf in = { 0 }, out = { 0 };
+ git_userbuf in = GIT_USERBUF_INIT, out = GIT_USERBUF_INIT;
cl_git_pass(git_filter_list_new(
&fl, g_repo, GIT_FILTER_TO_ODB, 0));
@@ -66,14 +66,14 @@ void test_filter_crlf__to_odb(void)
cl_assert_equal_s("Some text\nRight here\n", out.ptr);
git_filter_list_free(fl);
- git_buf_dispose(&out);
+ git_userbuf_dispose(&out);
}
void test_filter_crlf__with_safecrlf(void)
{
git_filter_list *fl;
git_filter *crlf;
- git_buf in = {0}, out = GIT_BUF_INIT;
+ git_userbuf in = GIT_USERBUF_INIT, out = GIT_USERBUF_INIT;
cl_repo_set_bool(g_repo, "core.safecrlf", true);
@@ -114,14 +114,14 @@ void test_filter_crlf__with_safecrlf(void)
cl_assert_equal_s("Normal\nCR only\rand some more\nline-endings.\n", out.ptr);
git_filter_list_free(fl);
- git_buf_dispose(&out);
+ git_userbuf_dispose(&out);
}
void test_filter_crlf__with_safecrlf_and_unsafe_allowed(void)
{
git_filter_list *fl;
git_filter *crlf;
- git_buf in = {0}, out = GIT_BUF_INIT;
+ git_userbuf in = GIT_USERBUF_INIT, out = GIT_USERBUF_INIT;
cl_repo_set_bool(g_repo, "core.safecrlf", true);
@@ -157,14 +157,14 @@ void test_filter_crlf__with_safecrlf_and_unsafe_allowed(void)
cl_assert_equal_s("Normal\nLF\nonly\nline-endings.\n", out.ptr);
git_filter_list_free(fl);
- git_buf_dispose(&out);
+ git_userbuf_dispose(&out);
}
void test_filter_crlf__no_safecrlf(void)
{
git_filter_list *fl;
git_filter *crlf;
- git_buf in = {0}, out = GIT_BUF_INIT;
+ git_userbuf in = GIT_USERBUF_INIT, out = GIT_USERBUF_INIT;
cl_git_pass(git_filter_list_new(
&fl, g_repo, GIT_FILTER_TO_ODB, 0));
@@ -196,14 +196,14 @@ void test_filter_crlf__no_safecrlf(void)
cl_assert_equal_s("Normal\nLF\nonly\nline-endings.\n", out.ptr);
git_filter_list_free(fl);
- git_buf_dispose(&out);
+ git_userbuf_dispose(&out);
}
void test_filter_crlf__safecrlf_warn(void)
{
git_filter_list *fl;
git_filter *crlf;
- git_buf in = {0}, out = GIT_BUF_INIT;
+ git_userbuf in = GIT_USERBUF_INIT, out = GIT_USERBUF_INIT;
cl_repo_set_string(g_repo, "core.safecrlf", "warn");
@@ -238,5 +238,5 @@ void test_filter_crlf__safecrlf_warn(void)
cl_assert_equal_s(in.ptr, out.ptr);
git_filter_list_free(fl);
- git_buf_dispose(&out);
+ git_userbuf_dispose(&out);
}
diff --git a/tests/filter/custom.c b/tests/filter/custom.c
index e5471be4f..152c2281e 100644
--- a/tests/filter/custom.c
+++ b/tests/filter/custom.c
@@ -95,8 +95,8 @@ static void register_custom_filters(void)
void test_filter_custom__to_odb(void)
{
git_filter_list *fl;
- git_buf out = { 0 };
- git_buf in = GIT_BUF_INIT_CONST(workdir_data, strlen(workdir_data));
+ git_userbuf out = GIT_USERBUF_INIT;
+ git_userbuf in = GIT_USERBUF_CONST(workdir_data, strlen(workdir_data));
cl_git_pass(git_filter_list_load(
&fl, g_repo, NULL, "herofile", GIT_FILTER_TO_ODB, 0));
@@ -109,14 +109,14 @@ void test_filter_custom__to_odb(void)
0, memcmp(bitflipped_and_reversed_data, out.ptr, out.size));
git_filter_list_free(fl);
- git_buf_dispose(&out);
+ git_userbuf_dispose(&out);
}
void test_filter_custom__to_workdir(void)
{
git_filter_list *fl;
- git_buf out = { 0 };
- git_buf in = GIT_BUF_INIT_CONST(
+ git_userbuf out = GIT_USERBUF_INIT;
+ git_userbuf in = GIT_USERBUF_CONST(
bitflipped_and_reversed_data, BITFLIPPED_AND_REVERSED_DATA_LEN);
cl_git_pass(git_filter_list_load(
@@ -130,7 +130,7 @@ void test_filter_custom__to_workdir(void)
0, memcmp(workdir_data, out.ptr, out.size));
git_filter_list_free(fl);
- git_buf_dispose(&out);
+ git_userbuf_dispose(&out);
}
void test_filter_custom__can_register_a_custom_filter_in_the_repository(void)
@@ -245,8 +245,8 @@ void test_filter_custom__filter_registry_failure_cases(void)
void test_filter_custom__erroneous_filter_fails(void)
{
git_filter_list *filters;
- git_buf out = GIT_BUF_INIT;
- git_buf in = GIT_BUF_INIT_CONST(workdir_data, strlen(workdir_data));
+ git_userbuf out = GIT_USERBUF_INIT;
+ git_userbuf in = GIT_USERBUF_CONST(workdir_data, strlen(workdir_data));
cl_git_pass(git_filter_list_load(
&filters, g_repo, NULL, "villain", GIT_FILTER_TO_WORKTREE, 0));
@@ -254,5 +254,5 @@ void test_filter_custom__erroneous_filter_fails(void)
cl_git_fail(git_filter_list_apply_to_data(&out, filters, &in));
git_filter_list_free(filters);
- git_buf_dispose(&out);
+ git_userbuf_dispose(&out);
}
diff --git a/tests/filter/custom_helpers.c b/tests/filter/custom_helpers.c
index d7f2afe7a..c4b282a84 100644
--- a/tests/filter/custom_helpers.c
+++ b/tests/filter/custom_helpers.c
@@ -7,10 +7,10 @@
#define VERY_SECURE_ENCRYPTION(b) ((b) ^ 0xff)
int bitflip_filter_apply(
- git_filter *self,
- void **payload,
- git_buf *to,
- const git_buf *from,
+ git_filter *self,
+ void **payload,
+ git_userbuf *to,
+ const git_userbuf *from,
const git_filter_source *source)
{
const unsigned char *src = (const unsigned char *)from->ptr;
@@ -26,7 +26,7 @@ int bitflip_filter_apply(
if (!from->size)
return 0;
- cl_git_pass(git_buf_grow(to, from->size));
+ cl_git_pass(git_buf_grow((git_buf *)to, from->size));
dst = (unsigned char *)to->ptr;
@@ -58,10 +58,10 @@ git_filter *create_bitflip_filter(void)
int reverse_filter_apply(
- git_filter *self,
- void **payload,
- git_buf *to,
- const git_buf *from,
+ git_filter *self,
+ void **payload,
+ git_userbuf *to,
+ const git_userbuf *from,
const git_filter_source *source)
{
const unsigned char *src = (const unsigned char *)from->ptr;
@@ -77,7 +77,7 @@ int reverse_filter_apply(
if (!from->size)
return 0;
- cl_git_pass(git_buf_grow(to, from->size));
+ cl_git_pass(git_buf_grow((git_buf *)to, from->size));
dst = (unsigned char *)to->ptr + from->size - 1;
diff --git a/tests/filter/file.c b/tests/filter/file.c
index 521c01c02..c4a33cc35 100644
--- a/tests/filter/file.c
+++ b/tests/filter/file.c
@@ -34,7 +34,7 @@ void test_filter_file__apply(void)
{
git_filter_list *fl;
git_filter *crlf;
- git_buf buf = GIT_BUF_INIT;
+ git_userbuf buf = GIT_USERBUF_INIT;
cl_git_pass(git_filter_list_new(
&fl, g_repo, GIT_FILTER_TO_ODB, 0));
@@ -44,10 +44,10 @@ void test_filter_file__apply(void)
cl_git_pass(git_filter_list_push(fl, crlf, NULL));
- cl_git_pass(git_filter_list_apply_to_file(&buf, fl, g_repo, "all-crlf"));
+ cl_git_pass(git_filter_list_apply_to_file((git_userbuf *)&buf, fl, g_repo, "all-crlf"));
cl_assert_equal_s("crlf\ncrlf\ncrlf\ncrlf\n", buf.ptr);
- git_buf_dispose(&buf);
+ git_userbuf_dispose(&buf);
git_filter_list_free(fl);
}
diff --git a/tests/filter/ident.c b/tests/filter/ident.c
index ed2e4677f..0218db89f 100644
--- a/tests/filter/ident.c
+++ b/tests/filter/ident.c
@@ -20,7 +20,7 @@ static void add_blob_and_filter(
{
git_oid id;
git_blob *blob;
- git_buf out = { 0 };
+ git_userbuf out = GIT_USERBUF_INIT;
cl_git_mkfile("crlf/identtest", data);
cl_git_pass(git_blob_create_from_workdir(&id, g_repo, "identtest"));
@@ -31,7 +31,7 @@ static void add_blob_and_filter(
cl_assert_equal_s(expected, out.ptr);
git_blob_free(blob);
- git_buf_dispose(&out);
+ git_userbuf_dispose(&out);
}
void test_filter_ident__to_worktree(void)
diff --git a/tests/filter/wildcard.c b/tests/filter/wildcard.c
index 3c25ea266..bc2e7aab8 100644
--- a/tests/filter/wildcard.c
+++ b/tests/filter/wildcard.c
@@ -77,18 +77,18 @@ static int wildcard_filter_check(
}
static int wildcard_filter_apply(
- git_filter *self,
- void **payload,
- git_buf *to,
- const git_buf *from,
+ git_filter *self,
+ void **payload,
+ git_userbuf *to,
+ const git_userbuf *from,
const git_filter_source *source)
{
const char *filtername = *payload;
if (filtername && strcmp(filtername, "wcflip") == 0)
- return bitflip_filter_apply(self, payload, to, from, source);
+ return bitflip_filter_apply(self, payload, (git_buf *)to, (git_buf *)from, source);
else if (filtername && strcmp(filtername, "wcreverse") == 0)
- return reverse_filter_apply(self, payload, to, from, source);
+ return reverse_filter_apply(self, payload, (git_buf *)to, (git_buf *)from, source);
cl_fail("Unexpected attribute");
return GIT_PASSTHROUGH;
@@ -123,12 +123,12 @@ static git_filter *create_wildcard_filter(void)
void test_filter_wildcard__reverse(void)
{
git_filter_list *fl;
- git_buf in = GIT_BUF_INIT, out = GIT_BUF_INIT;
+ git_userbuf in = GIT_USERBUF_INIT, out = GIT_USERBUF_INIT;
cl_git_pass(git_filter_list_load(
&fl, g_repo, NULL, "hero-reverse-foo", GIT_FILTER_TO_ODB, 0));
- cl_git_pass(git_buf_put(&in, (char *)input, DATA_LEN));
+ cl_git_pass(git_buf_put((git_buf *)&in, (char *)input, DATA_LEN));
cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
cl_assert_equal_i(DATA_LEN, out.size);
@@ -137,19 +137,19 @@ void test_filter_wildcard__reverse(void)
0, memcmp(reversed, out.ptr, out.size));
git_filter_list_free(fl);
- git_buf_dispose(&out);
- git_buf_dispose(&in);
+ git_userbuf_dispose(&out);
+ git_userbuf_dispose(&in);
}
void test_filter_wildcard__flip(void)
{
git_filter_list *fl;
- git_buf in = GIT_BUF_INIT, out = GIT_BUF_INIT;
+ git_userbuf in = GIT_USERBUF_INIT, out = GIT_USERBUF_INIT;
cl_git_pass(git_filter_list_load(
&fl, g_repo, NULL, "hero-flip-foo", GIT_FILTER_TO_ODB, 0));
- cl_git_pass(git_buf_put(&in, (char *)input, DATA_LEN));
+ cl_git_pass(git_buf_put((git_buf *)&in, (char *)input, DATA_LEN));
cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
cl_assert_equal_i(DATA_LEN, out.size);
@@ -158,19 +158,19 @@ void test_filter_wildcard__flip(void)
0, memcmp(flipped, out.ptr, out.size));
git_filter_list_free(fl);
- git_buf_dispose(&out);
- git_buf_dispose(&in);
+ git_userbuf_dispose(&out);
+ git_userbuf_dispose(&in);
}
void test_filter_wildcard__none(void)
{
git_filter_list *fl;
- git_buf in = GIT_BUF_INIT, out = GIT_BUF_INIT;
+ git_userbuf in = GIT_USERBUF_INIT, out = GIT_USERBUF_INIT;
cl_git_pass(git_filter_list_load(
&fl, g_repo, NULL, "none-foo", GIT_FILTER_TO_ODB, 0));
- cl_git_pass(git_buf_put(&in, (char *)input, DATA_LEN));
+ cl_git_pass(git_buf_put((git_buf *)&in, (char *)input, DATA_LEN));
cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
cl_assert_equal_i(DATA_LEN, out.size);
@@ -179,6 +179,6 @@ void test_filter_wildcard__none(void)
0, memcmp(input, out.ptr, out.size));
git_filter_list_free(fl);
- git_buf_dispose(&out);
- git_buf_dispose(&in);
+ git_userbuf_dispose(&out);
+ git_userbuf_dispose(&in);
}
diff --git a/tests/object/blob/filter.c b/tests/object/blob/filter.c
index 0f0f4845f..a73abeeda 100644
--- a/tests/object/blob/filter.c
+++ b/tests/object/blob/filter.c
@@ -112,7 +112,7 @@ void test_object_blob_filter__to_odb(void)
git_config *cfg;
int i;
git_blob *blob;
- git_buf out = GIT_BUF_INIT, zeroed;
+ git_userbuf out = GIT_USERBUF_INIT, zeroed = GIT_USERBUF_INIT;
cl_git_pass(git_repository_config(&cfg, g_repo));
cl_assert(cfg);
@@ -139,12 +139,12 @@ void test_object_blob_filter__to_odb(void)
cl_assert_equal_sz(g_crlf_filtered[i].size, zeroed.size);
cl_assert_equal_i(
0, memcmp(zeroed.ptr, g_crlf_filtered[i].ptr, zeroed.size));
- git_buf_dispose(&zeroed);
+ git_userbuf_dispose(&zeroed);
git_blob_free(blob);
}
git_filter_list_free(fl);
- git_buf_dispose(&out);
+ git_userbuf_dispose(&out);
git_config_free(cfg);
}