]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pkt-line: add options argument to read_packetized_to_strbuf()
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 15 Mar 2021 21:08:21 +0000 (21:08 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Mar 2021 21:32:50 +0000 (14:32 -0700)
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>
convert.c
pkt-line.c
pkt-line.h

index 976d4905cb3a1f3377ac134a23ad5b48b1cb778e..516f1095b06eea7c0d99891ba6dfa1e234acfe63 100644 (file)
--- 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;
 
index 457ac4e151bb651e45a255da029b6e7769c49434..0194137528c3ce909ab76f55200e2ed31ce742f7 100644 (file)
@@ -444,7 +444,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;
 
@@ -460,7 +460,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);
                if (packet_len <= 0)
                        break;
                sb_out->len += packet_len;
index 80ce0187e2ea7e903d28692c4df29ba2729ff485..5af5f456876841744f22bc67b8359e0a330ddc11 100644 (file)
@@ -136,7 +136,7 @@ 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.
  */
-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.