filter: introduce git_filter_list_apply_to_buffer Provide a filter application mechanism that takes a user-provided string and length, instead of a `git_buf`.
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
diff --git a/include/git2/filter.h b/include/git2/filter.h
index 45aa6c5..3e84877 100644
--- a/include/git2/filter.h
+++ b/include/git2/filter.h
@@ -125,6 +125,21 @@ GIT_EXTERN(int) git_filter_list_contains(
* @param out Buffer to store the result of the filtering
* @param filters A loaded git_filter_list (or NULL)
* @param in Buffer containing the data to filter
+ * @param in_len The length of the input buffer
+ * @return 0 on success, an error code otherwise
+ */
+GIT_EXTERN(int) git_filter_list_apply_to_buffer(
+ git_buf *out,
+ git_filter_list *filters,
+ const char *in,
+ size_t in_len);
+
+/**
+ * Apply filter list to a data buffer.
+ *
+ * @param out Buffer to store the result of the filtering
+ * @param filters A loaded git_filter_list (or NULL)
+ * @param in Buffer containing the data to filter
* @return 0 on success, an error code otherwise
*/
GIT_EXTERN(int) git_filter_list_apply_to_data(
diff --git a/src/filter.c b/src/filter.c
index 72a426e..2ba0f1e 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -720,7 +720,7 @@ static void buf_stream_init(struct buf_stream *writer, git_buf *target)
git_buf_clear(target);
}
-static int git_filter_list_apply_to_buffer(
+int git_filter_list_apply_to_buffer(
git_buf *out,
git_filter_list *filters,
const char *in,