diff options
author | Jeff King <peff@peff.net> | 2018-02-08 13:47:49 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-02-08 12:37:30 -0800 |
commit | bc9d4dc5b07c05c7b26a4e781b7538db7c775fc3 (patch) | |
tree | f4d1f0c00e6c5b463fd6e548ae4f53ec0f55f37f /fetch-pack.c | |
parent | Git 2.16.1 (diff) | |
download | tgif-bc9d4dc5b07c05c7b26a4e781b7538db7c775fc3.tar.xz |
correct error messages for NULL packet_read_line()
The packet_read_line() function dies if it gets an
unexpected EOF. It only returns NULL if we get a flush
packet (or technically, a zero-length "0004" packet, but
nobody is supposed to send those, and they are
indistinguishable from a flush in this interface).
Let's correct error messages which claim an unexpected EOF;
it's really an unexpected flush packet.
While we're here, let's also check "!line" instead of
"!len" in the second case. The two events should always
coincide, but checking "!line" makes it more obvious that we
are not about to dereference NULL.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fetch-pack.c')
-rw-r--r-- | fetch-pack.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fetch-pack.c b/fetch-pack.c index 9f6b07ad91..54acb421ae 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -260,8 +260,8 @@ static enum ack_type get_ack(int fd, struct object_id *result_oid) char *line = packet_read_line(fd, &len); const char *arg; - if (!len) - die(_("git fetch-pack: expected ACK/NAK, got EOF")); + if (!line) + die(_("git fetch-pack: expected ACK/NAK, got a flush packet")); if (!strcmp(line, "NAK")) return NAK; if (skip_prefix(line, "ACK ", &arg)) { |