diff options
author | John Alden <john.alden@gitkraken.com> | 2022-06-22 09:22:50 -0700 |
---|---|---|
committer | John Alden <john.alden@gitkraken.com> | 2022-06-22 09:22:50 -0700 |
commit | f887fd60783ff989d4325de70c2c9fbc2ad73994 (patch) | |
tree | 2ef2d07f22d0e0ff51dbacfcabbc6e958bc3c364 | |
parent | e0a8b4e87e7fa07dd3817755df1937da8dc12623 (diff) | |
download | libgit2-f887fd60783ff989d4325de70c2c9fbc2ad73994.tar.gz |
copy back git_buf after callback
-rw-r--r-- | src/libgit2/filter.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/libgit2/filter.c b/src/libgit2/filter.c index 788ed9cb5..80a3cae67 100644 --- a/src/libgit2/filter.c +++ b/src/libgit2/filter.c @@ -893,6 +893,17 @@ static int buffered_stream_write( return git_str_put(&buffered_stream->input, buffer, len); } +#ifndef GIT_DEPRECATE_HARD +# define BUF_TO_STRUCT(b, s) \ + (b)->ptr = (s)->ptr; \ + (b)->size = (s)->size; \ + (b)->reserved = (s)->asize; +# define STRUCT_TO_BUF(s, b) \ + (s)->ptr = (b)->ptr; \ + (s)->size = (b)->size; \ + (s)->asize = (b)->reserved; +#endif + static int buffered_stream_close(git_writestream *s) { struct buffered_stream *buffered_stream = (struct buffered_stream *)s; @@ -907,12 +918,8 @@ static int buffered_stream_close(git_writestream *s) git_buf legacy_output = GIT_BUF_INIT, legacy_input = GIT_BUF_INIT; - legacy_output.ptr = buffered_stream->output->ptr; - legacy_output.size = buffered_stream->output->size; - legacy_output.reserved = buffered_stream->output->asize; - legacy_input.ptr = buffered_stream->input.ptr; - legacy_input.size = buffered_stream->input.size; - legacy_input.reserved = buffered_stream->input.asize; + BUF_TO_STRUCT(&legacy_output, buffered_stream->output); + BUF_TO_STRUCT(&legacy_input, &buffered_stream->input); error = buffered_stream->legacy_write_fn( buffered_stream->filter, @@ -920,6 +927,9 @@ static int buffered_stream_close(git_writestream *s) &legacy_output, &legacy_input, buffered_stream->source); + + STRUCT_TO_BUF(buffered_stream->output, &legacy_output); + STRUCT_TO_BUF(&buffered_stream->input, &legacy_input); } else #endif error = buffered_stream->write_fn( |