Skip to content

Commit c089d5a

Browse files
committed
filter: use streaming filters in tests
1 parent f593fa9 commit c089d5a

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

tests/filter/custom_helpers.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ int bitflip_filter_apply(
3737
return 0;
3838
}
3939

40+
static int bitflip_filter_stream(
41+
git_writestream **out,
42+
git_filter *self,
43+
void **payload,
44+
const git_filter_source *src,
45+
git_writestream *next)
46+
{
47+
return git_filter_buffered_stream_new(out,
48+
self, bitflip_filter_apply, NULL, payload, src, next);
49+
}
50+
4051
static void bitflip_filter_free(git_filter *f)
4152
{
4253
git__free(f);
@@ -50,7 +61,7 @@ git_filter *create_bitflip_filter(void)
5061
filter->version = GIT_FILTER_VERSION;
5162
filter->attributes = "+bitflip";
5263
filter->shutdown = bitflip_filter_free;
53-
filter->apply = bitflip_filter_apply;
64+
filter->stream = bitflip_filter_stream;
5465

5566
return filter;
5667
}
@@ -88,6 +99,17 @@ int reverse_filter_apply(
8899
return 0;
89100
}
90101

102+
static int reverse_filter_stream(
103+
git_writestream **out,
104+
git_filter *self,
105+
void **payload,
106+
const git_filter_source *src,
107+
git_writestream *next)
108+
{
109+
return git_filter_buffered_stream_new(out,
110+
self, reverse_filter_apply, NULL, payload, src, next);
111+
}
112+
91113
static void reverse_filter_free(git_filter *f)
92114
{
93115
git__free(f);
@@ -101,7 +123,7 @@ git_filter *create_reverse_filter(const char *attrs)
101123
filter->version = GIT_FILTER_VERSION;
102124
filter->attributes = attrs;
103125
filter->shutdown = reverse_filter_free;
104-
filter->apply = reverse_filter_apply;
126+
filter->stream = reverse_filter_stream;
105127

106128
return filter;
107129
}

tests/filter/wildcard.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ static int wildcard_filter_apply(
9393
return GIT_PASSTHROUGH;
9494
}
9595

96+
static int wildcard_filter_stream(
97+
git_writestream **out,
98+
git_filter *self,
99+
void **payload,
100+
const git_filter_source *src,
101+
git_writestream *next)
102+
{
103+
return git_filter_buffered_stream_new(out,
104+
self, wildcard_filter_apply, NULL, payload, src, next);
105+
}
106+
96107
static void wildcard_filter_cleanup(git_filter *self, void *payload)
97108
{
98109
GIT_UNUSED(self);
@@ -112,7 +123,7 @@ static git_filter *create_wildcard_filter(void)
112123
filter->version = GIT_FILTER_VERSION;
113124
filter->attributes = "filter=*";
114125
filter->check = wildcard_filter_check;
115-
filter->apply = wildcard_filter_apply;
126+
filter->stream = wildcard_filter_stream;
116127
filter->cleanup = wildcard_filter_cleanup;
117128
filter->shutdown = wildcard_filter_free;
118129

0 commit comments

Comments
 (0)