Message ID | 6a389a3533512acedfa1769c64296c1e19b16221.1612208747.git.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Simple IPC Mechanism | expand |
On Mon, Feb 01, 2021 at 07:45:39PM +0000, Johannes Schindelin via GitGitGadget wrote: > diff --git a/pkt-line.c b/pkt-line.c > index 528493bca21..f090fc56eef 100644 > --- a/pkt-line.c > +++ b/pkt-line.c > @@ -461,7 +461,7 @@ char *packet_read_line_buf(char **src, size_t *src_len, int *dst_len) > return packet_read_line_generic(-1, src, src_len, dst_len); > } > > -ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out) > +ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out, int options) > { > int packet_len; > > @@ -477,7 +477,7 @@ ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out) > * that there is already room for the extra byte. > */ > sb_out->buf + sb_out->len, LARGE_PACKET_DATA_MAX+1, > - PACKET_READ_GENTLE_ON_EOF); > + options | PACKET_READ_GENTLE_ON_EOF); This feels a little magical to me. Since read_packetized_to_strbuf only has the one caller you mention, why not have the caller pass all of the options (including PACKET_READ_GENTLE_ON_EOF)? > if (packet_len <= 0) > break; > sb_out->len += packet_len; > diff --git a/pkt-line.h b/pkt-line.h > index 7f31c892165..150319a6f00 100644 > --- a/pkt-line.h > +++ b/pkt-line.h > @@ -145,8 +145,12 @@ char *packet_read_line_buf(char **src_buf, size_t *src_len, int *size); > > /* > * Reads a stream of variable sized packets until a flush packet is detected. > + * > + * The options are augmented by PACKET_READ_GENTLE_ON_EOF and passed to > + * packet_read. Obviously this comment will need updating if you take my suggestion. Thanks, Taylor
diff --git a/convert.c b/convert.c index 3f396a9b288..175c5cd51d5 100644 --- a/convert.c +++ b/convert.c @@ -903,7 +903,7 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len if (err) goto done; - err = read_packetized_to_strbuf(process->out, &nbuf) < 0; + err = read_packetized_to_strbuf(process->out, &nbuf, 0) < 0; if (err) goto done; diff --git a/pkt-line.c b/pkt-line.c index 528493bca21..f090fc56eef 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -461,7 +461,7 @@ char *packet_read_line_buf(char **src, size_t *src_len, int *dst_len) return packet_read_line_generic(-1, src, src_len, dst_len); } -ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out) +ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out, int options) { int packet_len; @@ -477,7 +477,7 @@ ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out) * that there is already room for the extra byte. */ sb_out->buf + sb_out->len, LARGE_PACKET_DATA_MAX+1, - PACKET_READ_GENTLE_ON_EOF); + options | PACKET_READ_GENTLE_ON_EOF); if (packet_len <= 0) break; sb_out->len += packet_len; diff --git a/pkt-line.h b/pkt-line.h index 7f31c892165..150319a6f00 100644 --- a/pkt-line.h +++ b/pkt-line.h @@ -145,8 +145,12 @@ char *packet_read_line_buf(char **src_buf, size_t *src_len, int *size); /* * Reads a stream of variable sized packets until a flush packet is detected. + * + * The options are augmented by PACKET_READ_GENTLE_ON_EOF and passed to + * packet_read. */ -ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out); +ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out, + int options); /* * Receive multiplexed output stream over git native protocol.