diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2021-08-27 16:51:38 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2021-08-27 16:51:38 -0400 |
commit | c089d5ac6145e4498167c9a3157835e416084d18 (patch) | |
tree | fc9c2505d26ab1052e13cecea1d07eeb55d658a4 | |
parent | f593fa979319d628295cf7a4d57051e68caa4823 (diff) | |
download | libgit2-c089d5ac6145e4498167c9a3157835e416084d18.tar.gz |
filter: use streaming filters in tests
-rw-r--r-- | tests/filter/custom_helpers.c | 26 | ||||
-rw-r--r-- | tests/filter/wildcard.c | 13 |
2 files changed, 36 insertions, 3 deletions
diff --git a/tests/filter/custom_helpers.c b/tests/filter/custom_helpers.c index 233ba3219..ee3b6353b 100644 --- a/tests/filter/custom_helpers.c +++ b/tests/filter/custom_helpers.c @@ -37,6 +37,17 @@ int bitflip_filter_apply( return 0; } +static int bitflip_filter_stream( + git_writestream **out, + git_filter *self, + void **payload, + const git_filter_source *src, + git_writestream *next) +{ + return git_filter_buffered_stream_new(out, + self, bitflip_filter_apply, NULL, payload, src, next); +} + static void bitflip_filter_free(git_filter *f) { git__free(f); @@ -50,7 +61,7 @@ git_filter *create_bitflip_filter(void) filter->version = GIT_FILTER_VERSION; filter->attributes = "+bitflip"; filter->shutdown = bitflip_filter_free; - filter->apply = bitflip_filter_apply; + filter->stream = bitflip_filter_stream; return filter; } @@ -88,6 +99,17 @@ int reverse_filter_apply( return 0; } +static int reverse_filter_stream( + git_writestream **out, + git_filter *self, + void **payload, + const git_filter_source *src, + git_writestream *next) +{ + return git_filter_buffered_stream_new(out, + self, reverse_filter_apply, NULL, payload, src, next); +} + static void reverse_filter_free(git_filter *f) { git__free(f); @@ -101,7 +123,7 @@ git_filter *create_reverse_filter(const char *attrs) filter->version = GIT_FILTER_VERSION; filter->attributes = attrs; filter->shutdown = reverse_filter_free; - filter->apply = reverse_filter_apply; + filter->stream = reverse_filter_stream; return filter; } diff --git a/tests/filter/wildcard.c b/tests/filter/wildcard.c index ca1ba1a28..0c9c13b1e 100644 --- a/tests/filter/wildcard.c +++ b/tests/filter/wildcard.c @@ -93,6 +93,17 @@ static int wildcard_filter_apply( return GIT_PASSTHROUGH; } +static int wildcard_filter_stream( + git_writestream **out, + git_filter *self, + void **payload, + const git_filter_source *src, + git_writestream *next) +{ + return git_filter_buffered_stream_new(out, + self, wildcard_filter_apply, NULL, payload, src, next); +} + static void wildcard_filter_cleanup(git_filter *self, void *payload) { GIT_UNUSED(self); @@ -112,7 +123,7 @@ static git_filter *create_wildcard_filter(void) filter->version = GIT_FILTER_VERSION; filter->attributes = "filter=*"; filter->check = wildcard_filter_check; - filter->apply = wildcard_filter_apply; + filter->stream = wildcard_filter_stream; filter->cleanup = wildcard_filter_cleanup; filter->shutdown = wildcard_filter_free; |