path: root/fetch-pack.c
diff options
authorJeff King <>2019-03-05 04:11:39 (GMT)
committerJunio C Hamano <>2019-03-05 06:02:01 (GMT)
commit37c80012f1415bc4ff23def735a87cbd395bca31 (patch)
treee0bc7f5f016e97443f5ae9753cc52701123bdacd /fetch-pack.c
parent0d0ac3826a3bbb9247e39e12623bbcfdd722f24c (diff)
fetch: avoid calling write_or_die()
The write_or_die() function has one quirk that a caller might not expect: when it sees EPIPE from the write() call, it translates that into a death by SIGPIPE. This doesn't change the overall behavior (the program exits either way), but it does potentially confuse test scripts looking for a non-signal exit code. Let's switch away from using write_or_die() in a few code paths, which will give us more consistent exit codes. It also gives us the opportunity to write more descriptive error messages, since we have context that write_or_die() does not. Note that this won't do much by itself, since we'd typically be killed by SIGPIPE before write_or_die() even gets a chance to do its thing. That will be addressed in the next patch. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'fetch-pack.c')
1 files changed, 6 insertions, 3 deletions
diff --git a/fetch-pack.c b/fetch-pack.c
index 9691046..1dcb0f7 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -189,8 +189,10 @@ static void send_request(struct fetch_pack_args *args,
if (args->stateless_rpc) {
send_sideband(fd, -1, buf->buf, buf->len, LARGE_PACKET_MAX);
- } else
- write_or_die(fd, buf->buf, buf->len);
+ } else {
+ if (write_in_full(fd, buf->buf, buf->len) < 0)
+ die_errno(_("unable to write to remote"));
+ }
static void insert_one_alternate_object(struct fetch_negotiator *negotiator,
@@ -1178,7 +1180,8 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out,
/* Send request */
- write_or_die(fd_out, req_buf.buf, req_buf.len);
+ if (write_in_full(fd_out, req_buf.buf, req_buf.len) < 0)
+ die_errno(_("unable to write request to remote"));
return ret;