Commit 5309b4654e5a387d18fe5181e376305332188eca

Edward Thomson 2021-05-06T15:24:30

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`.

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,