Commit 5bcef522 by Edward Thomson

filter: deprecate apply function

parent c089d5ac
...@@ -178,6 +178,7 @@ typedef int GIT_CALLBACK(git_filter_check_fn)( ...@@ -178,6 +178,7 @@ typedef int GIT_CALLBACK(git_filter_check_fn)(
const git_filter_source *src, const git_filter_source *src,
const char **attr_values); const char **attr_values);
#ifndef GIT_DEPRECATE_HARD
/** /**
* Callback to actually perform the data filtering * Callback to actually perform the data filtering
* *
...@@ -189,6 +190,8 @@ typedef int GIT_CALLBACK(git_filter_check_fn)( ...@@ -189,6 +190,8 @@ typedef int GIT_CALLBACK(git_filter_check_fn)(
* *
* The `payload` value will refer to any payload that was set by the * The `payload` value will refer to any payload that was set by the
* `check` callback. It may be read from or written to as needed. * `check` callback. It may be read from or written to as needed.
*
* @deprecated use git_filter_stream_fn
*/ */
typedef int GIT_CALLBACK(git_filter_apply_fn)( typedef int GIT_CALLBACK(git_filter_apply_fn)(
git_filter *self, git_filter *self,
...@@ -196,6 +199,7 @@ typedef int GIT_CALLBACK(git_filter_apply_fn)( ...@@ -196,6 +199,7 @@ typedef int GIT_CALLBACK(git_filter_apply_fn)(
git_buf *to, git_buf *to,
const git_buf *from, const git_buf *from,
const git_filter_source *src); const git_filter_source *src);
#endif
/** /**
* Callback to perform the data filtering. * Callback to perform the data filtering.
...@@ -263,12 +267,16 @@ struct git_filter { ...@@ -263,12 +267,16 @@ struct git_filter {
*/ */
git_filter_check_fn check; git_filter_check_fn check;
#ifdef GIT_DEPRECATE_HARD
void *reserved;
#else
/** /**
* Provided for backward compatibility; this will apply the * Provided for backward compatibility; this will apply the
* filter to the given contents in a `git_buf`. Callers should * filter to the given contents in a `git_buf`. Callers should
* provide a `stream` function instead. * provide a `stream` function instead.
*/ */
git_filter_apply_fn apply; git_filter_apply_fn apply;
#endif
/** /**
* Called to apply the filter, this function will provide a * Called to apply the filter, this function will provide a
......
...@@ -939,6 +939,32 @@ int git_filter_buffered_stream_new( ...@@ -939,6 +939,32 @@ int git_filter_buffered_stream_new(
return 0; return 0;
} }
static int setup_stream(
git_writestream **out,
git_filter_entry *fe,
git_filter_list *filters,
git_writestream *last_stream)
{
#ifndef GIT_DEPRECATE_HARD
GIT_ASSERT(fe->filter->stream || fe->filter->apply);
/*
* If necessary, create a stream that proxies the traditional
* application.
*/
if (!fe->filter->stream) {
/* Create a stream that proxies the one-shot apply */
return git_filter_buffered_stream_new(out,
fe->filter, fe->filter->apply, filters->temp_buf,
&fe->payload, &filters->source, last_stream);
}
#endif
GIT_ASSERT(fe->filter->stream);
return fe->filter->stream(out, fe->filter,
&fe->payload, &filters->source, last_stream);
}
static int stream_list_init( static int stream_list_init(
git_writestream **out, git_writestream **out,
git_vector *streams, git_vector *streams,
...@@ -960,22 +986,11 @@ static int stream_list_init( ...@@ -960,22 +986,11 @@ static int stream_list_init(
for (i = 0; i < git_array_size(filters->filters); ++i) { for (i = 0; i < git_array_size(filters->filters); ++i) {
size_t filter_idx = (filters->source.mode == GIT_FILTER_TO_WORKTREE) ? size_t filter_idx = (filters->source.mode == GIT_FILTER_TO_WORKTREE) ?
git_array_size(filters->filters) - 1 - i : i; git_array_size(filters->filters) - 1 - i : i;
git_filter_entry *fe = git_array_get(filters->filters, filter_idx); git_filter_entry *fe = git_array_get(filters->filters, filter_idx);
git_writestream *filter_stream; git_writestream *filter_stream;
GIT_ASSERT(fe->filter->stream || fe->filter->apply); error = setup_stream(&filter_stream, fe, filters, last_stream);
/* If necessary, create a stream that proxies the traditional
* application.
*/
if (fe->filter->stream)
error = fe->filter->stream(&filter_stream, fe->filter,
&fe->payload, &filters->source, last_stream);
else
/* Create a stream that proxies the one-shot apply */
error = git_filter_buffered_stream_new(&filter_stream,
fe->filter, fe->filter->apply, filters->temp_buf,
&fe->payload, &filters->source, last_stream);
if (error < 0) if (error < 0)
goto out; goto out;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment