copy back git_buf after callback

parent e0a8b4e8
...@@ -893,6 +893,17 @@ static int buffered_stream_write( ...@@ -893,6 +893,17 @@ static int buffered_stream_write(
return git_str_put(&buffered_stream->input, buffer, len); 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) static int buffered_stream_close(git_writestream *s)
{ {
struct buffered_stream *buffered_stream = (struct buffered_stream *)s; struct buffered_stream *buffered_stream = (struct buffered_stream *)s;
...@@ -907,12 +918,8 @@ static int buffered_stream_close(git_writestream *s) ...@@ -907,12 +918,8 @@ static int buffered_stream_close(git_writestream *s)
git_buf legacy_output = GIT_BUF_INIT, git_buf legacy_output = GIT_BUF_INIT,
legacy_input = GIT_BUF_INIT; legacy_input = GIT_BUF_INIT;
legacy_output.ptr = buffered_stream->output->ptr; BUF_TO_STRUCT(&legacy_output, buffered_stream->output);
legacy_output.size = buffered_stream->output->size; BUF_TO_STRUCT(&legacy_input, &buffered_stream->input);
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;
error = buffered_stream->legacy_write_fn( error = buffered_stream->legacy_write_fn(
buffered_stream->filter, buffered_stream->filter,
...@@ -920,6 +927,9 @@ static int buffered_stream_close(git_writestream *s) ...@@ -920,6 +927,9 @@ static int buffered_stream_close(git_writestream *s)
&legacy_output, &legacy_output,
&legacy_input, &legacy_input,
buffered_stream->source); buffered_stream->source);
STRUCT_TO_BUF(buffered_stream->output, &legacy_output);
STRUCT_TO_BUF(&buffered_stream->input, &legacy_input);
} else } else
#endif #endif
error = buffered_stream->write_fn( error = buffered_stream->write_fn(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment