Skip to content

Commit 5d2124b

Browse files
bmwillgitster
authored andcommitted
pkt-line: add packet_write function
Add a function which can be used to write the contents of an arbitrary buffer. This makes it easy to build up data in a buffer before writing the packet instead of formatting the entire contents of the packet using 'packet_write_fmt()'. Signed-off-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0cd8328 commit 5d2124b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pkt-line.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ static int packet_write_gently(const int fd_out, const char *buf, size_t size)
188188
return 0;
189189
}
190190

191+
void packet_write(int fd_out, const char *buf, size_t size)
192+
{
193+
if (packet_write_gently(fd_out, buf, size))
194+
die_errno("packet write failed");
195+
}
196+
191197
void packet_buf_write(struct strbuf *buf, const char *fmt, ...)
192198
{
193199
va_list args;

pkt-line.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
void packet_flush(int fd);
2323
void packet_write_fmt(int fd, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
2424
void packet_buf_flush(struct strbuf *buf);
25+
void packet_write(int fd_out, const char *buf, size_t size);
2526
void packet_buf_write(struct strbuf *buf, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
2627
int packet_flush_gently(int fd);
2728
int packet_write_fmt_gently(int fd, const char *fmt, ...) __attribute__((format (printf, 2, 3)));

0 commit comments

Comments
 (0)