From 3a63c6a48c0588a237b3133fe785d6e734dedbb5 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 15 Mar 2021 21:08:19 +0000 Subject: pkt-line: do not issue flush packets in write_packetized_*() Remove the `packet_flush_gently()` call in `write_packetized_from_buf() and `write_packetized_from_fd()` and require the caller to call it if desired. Rename both functions to `write_packetized_from_*_no_flush()` to prevent later merge accidents. `write_packetized_from_buf()` currently only has one caller: `apply_multi_file_filter()` in `convert.c`. It always wants a flush packet to be written after writing the payload. However, we are about to introduce a caller that wants to write many packets before a final flush packet, so let's make the caller responsible for emitting the flush packet. Signed-off-by: Jeff Hostetler Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- convert.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'convert.c') diff --git a/convert.c b/convert.c index ee360c2f07..976d4905cb 100644 --- a/convert.c +++ b/convert.c @@ -884,9 +884,13 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len goto done; if (fd >= 0) - err = write_packetized_from_fd(fd, process->in); + err = write_packetized_from_fd_no_flush(fd, process->in); else - err = write_packetized_from_buf(src, len, process->in); + err = write_packetized_from_buf_no_flush(src, len, process->in); + if (err) + goto done; + + err = packet_flush_gently(process->in); if (err) goto done; -- cgit v1.2.3 From 8c2efa5d7671567975add8c4e493da65c968c376 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 15 Mar 2021 21:08:21 +0000 Subject: pkt-line: add options argument to read_packetized_to_strbuf() Update the calling sequence of `read_packetized_to_strbuf()` to take an options argument and not assume a fixed set of options. Update the only existing caller accordingly to explicitly pass the formerly-assumed flags. The `read_packetized_to_strbuf()` function calls `packet_read()` with a fixed set of assumed options (`PACKET_READ_GENTLE_ON_EOF`). This assumption has been fine for the single existing caller `apply_multi_file_filter()` in `convert.c`. In a later commit we would like to add other callers to `read_packetized_to_strbuf()` that need a different set of options. Signed-off-by: Johannes Schindelin Signed-off-by: Jeff Hostetler Signed-off-by: Junio C Hamano --- convert.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'convert.c') diff --git a/convert.c b/convert.c index 976d4905cb..516f1095b0 100644 --- a/convert.c +++ b/convert.c @@ -907,7 +907,8 @@ 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, + PACKET_READ_GENTLE_ON_EOF) < 0; if (err) goto done; -- cgit v1.2.3