filter: deprecate git_filter_list_stream_data `git_filter_list_stream_data` takes user input in a `git_buf`. `git_buf` should only be used when libgit2 itself needs to allocate data and returned to a user that they can free when they wish. Replace it with `git_filter_list_stream_buffer` that takes a data buffer and length.
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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
diff --git a/include/git2/deprecated.h b/include/git2/deprecated.h
index 37857f8..a519509 100644
--- a/include/git2/deprecated.h
+++ b/include/git2/deprecated.h
@@ -18,6 +18,7 @@
#include "describe.h"
#include "diff.h"
#include "errors.h"
+#include "filter.h"
#include "index.h"
#include "indexer.h"
#include "merge.h"
@@ -119,6 +120,29 @@ GIT_EXTERN(int) git_blob_filtered_content(
/**@}*/
+/** @name Deprecated Filter Functions
+ *
+ * These functions are retained for backward compatibility. The
+ * newer versions of these functions should be preferred in all
+ * new code.
+ *
+ * There is no plan to remove these backward compatibility values at
+ * this time.
+ */
+/**@{*/
+
+/** Deprecated in favor of `git_filter_list_stream_buffer`.
+ *
+ * @deprecated Use git_filter_list_stream_buffer
+ * @see Use git_filter_list_stream_buffer
+ */
+GIT_EXTERN(int) git_filter_list_stream_data(
+ git_filter_list *filters,
+ git_buf *data,
+ git_writestream *target);
+
+/**@}*/
+
/** @name Deprecated Tree Functions
*
* These functions are retained for backward compatibility. The
diff --git a/include/git2/filter.h b/include/git2/filter.h
index 8860590..641391b 100644
--- a/include/git2/filter.h
+++ b/include/git2/filter.h
@@ -175,12 +175,14 @@ GIT_EXTERN(int) git_filter_list_apply_to_blob(
* Apply a filter list to an arbitrary buffer as a stream
*
* @param filters the list of filters to apply
- * @param data the buffer to filter
+ * @param buffer the buffer to filter
+ * @param len the size of the buffer
* @param target the stream into which the data will be written
*/
-GIT_EXTERN(int) git_filter_list_stream_data(
+GIT_EXTERN(int) git_filter_list_stream_buffer(
git_filter_list *filters,
- git_buf *data,
+ const char *buffer,
+ size_t len,
git_writestream *target);
/**
diff --git a/src/filter.c b/src/filter.c
index b82becd..f2ad837 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -737,8 +737,8 @@ int git_filter_list_apply_to_data(
buf_stream_init(&writer, tgt);
- if ((error = git_filter_list_stream_data(filters, src,
- &writer.parent)) < 0)
+ if ((error = git_filter_list_stream_buffer(filters,
+ src->ptr, src->size, &writer.parent)) < 0)
return error;
GIT_ASSERT(writer.complete);
@@ -1002,24 +1002,21 @@ done:
return error;
}
-int git_filter_list_stream_data(
+int git_filter_list_stream_buffer(
git_filter_list *filters,
- git_buf *data,
+ const char *buffer,
+ size_t len,
git_writestream *target)
{
git_vector filter_streams = GIT_VECTOR_INIT;
git_writestream *stream_start;
int error, initialized = 0;
- if ((error = git_buf_sanitize(data)) < 0)
- return error;
-
if ((error = stream_list_init(&stream_start, &filter_streams, filters, target)) < 0)
goto out;
initialized = 1;
- if ((error = stream_start->write(
- stream_start, data->ptr, data->size)) < 0)
+ if ((error = stream_start->write(stream_start, buffer, len)) < 0)
goto out;
out:
@@ -1043,7 +1040,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_buffer(filters, in.ptr, in.size, target);
}
int git_filter_init(git_filter *filter, unsigned int version)
@@ -1051,3 +1048,20 @@ int git_filter_init(git_filter *filter, unsigned int version)
GIT_INIT_STRUCTURE_FROM_TEMPLATE(filter, version, git_filter, GIT_FILTER_INIT);
return 0;
}
+
+#ifndef GIT_DEPRECATE_HARD
+
+int git_filter_list_stream_data(
+ git_filter_list *filters,
+ git_buf *data,
+ git_writestream *target)
+{
+ int error;
+
+ if ((error = git_buf_sanitize(data)) < 0)
+ return error;
+
+ return git_filter_list_stream_buffer(filters, data->ptr, data->size, target);
+}
+
+#endif