diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2021-05-06 02:19:49 +0100 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2021-05-06 15:06:41 +0100 |
| commit | 9869f1e5a30e735d3958c1fed3f6b0979d7f80de (patch) | |
| tree | 2ea65693677648a1cec4d014294c10e40a804d7d /src | |
| parent | 4bd172087c30e09e7720a7df11cace47ee002256 (diff) | |
| download | libgit2-9869f1e5a30e735d3958c1fed3f6b0979d7f80de.tar.gz | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/filter.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/filter.c b/src/filter.c index b82becdf3..f2ad837d1 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 |
