filter: deprecate apply function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
diff --git a/include/git2/sys/filter.h b/include/git2/sys/filter.h
index 098f8f7..b375941 100644
--- a/include/git2/sys/filter.h
+++ b/include/git2/sys/filter.h
@@ -178,6 +178,7 @@ typedef int GIT_CALLBACK(git_filter_check_fn)(
const git_filter_source *src,
const char **attr_values);
+#ifndef GIT_DEPRECATE_HARD
/**
* Callback to actually perform the data filtering
*
@@ -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
* `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)(
git_filter *self,
@@ -196,6 +199,7 @@ typedef int GIT_CALLBACK(git_filter_apply_fn)(
git_buf *to,
const git_buf *from,
const git_filter_source *src);
+#endif
/**
* Callback to perform the data filtering.
@@ -263,12 +267,16 @@ struct git_filter {
*/
git_filter_check_fn check;
+#ifdef GIT_DEPRECATE_HARD
+ void *reserved;
+#else
/**
* Provided for backward compatibility; this will apply the
* filter to the given contents in a `git_buf`. Callers should
* provide a `stream` function instead.
*/
git_filter_apply_fn apply;
+#endif
/**
* Called to apply the filter, this function will provide a
diff --git a/src/filter.c b/src/filter.c
index 21ae271..f1d9614 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -939,6 +939,32 @@ int git_filter_buffered_stream_new(
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(
git_writestream **out,
git_vector *streams,
@@ -960,22 +986,11 @@ static int stream_list_init(
for (i = 0; i < git_array_size(filters->filters); ++i) {
size_t filter_idx = (filters->source.mode == GIT_FILTER_TO_WORKTREE) ?
git_array_size(filters->filters) - 1 - i : i;
+
git_filter_entry *fe = git_array_get(filters->filters, filter_idx);
git_writestream *filter_stream;
- GIT_ASSERT(fe->filter->stream || fe->filter->apply);
-
- /* 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);
+ error = setup_stream(&filter_stream, fe, filters, last_stream);
if (error < 0)
goto out;