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 <johannes.schindelin@gmx.de> Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Mar 15, 2021 at 21:08 UTC 8c2efa5d7671567975add8c4e493da65c968c376
3 files changed +5 -4
convert.c
+2 -1
@@ -907,7 +907,8 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
907 if (err)
908 goto done;
909
910 - err = read_packetized_to_strbuf(process->out, &nbuf) < 0;
910 + err = read_packetized_to_strbuf(process->out, &nbuf,
911 + PACKET_READ_GENTLE_ON_EOF) < 0;
912 if (err)
913 goto done;
914
pkt-line.c
+2 -2
@@ -444,7 +444,7 @@ char *packet_read_line_buf(char **src, size_t *src_len, int *dst_len)
444 return packet_read_line_generic(-1, src, src_len, dst_len);
445 }
446
447 -ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out)
447 +ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out, int options)
448 {
449 int packet_len;
450
@@ -460,7 +460,7 @@ ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out)
460 * that there is already room for the extra byte.
461 */
462 sb_out->buf + sb_out->len, LARGE_PACKET_DATA_MAX+1,
463 - PACKET_READ_GENTLE_ON_EOF);
463 + options);
464 if (packet_len <= 0)
465 break;
466 sb_out->len += packet_len;
pkt-line.h
+1 -1
@@ -136,7 +136,7 @@ char *packet_read_line_buf(char **src_buf, size_t *src_len, int *size);
136 /*
137 * Reads a stream of variable sized packets until a flush packet is detected.
138 */
139 -ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out);
139 +ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out, int options);
140
141 /*
142 * Receive multiplexed output stream over git native protocol.