]> git.ipfire.org Git - thirdparty/git.git/commitdiff
correct error messages for NULL packet_read_line()
authorJeff King <peff@peff.net>
Thu, 8 Feb 2018 18:47:49 +0000 (13:47 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Feb 2018 20:37:30 +0000 (12:37 -0800)
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>
builtin/archive.c
fetch-pack.c

index f863465a0fa137f3446071a0ec1653adad536fdc..73971d0dd20e7233d6cb1e6c16986ede25526939 100644 (file)
@@ -55,7 +55,7 @@ static int run_remote_archiver(int argc, const char **argv,
 
        buf = packet_read_line(fd[0], NULL);
        if (!buf)
-               die(_("git archive: expected ACK/NAK, got EOF"));
+               die(_("git archive: expected ACK/NAK, got a flush packet"));
        if (strcmp(buf, "ACK")) {
                if (starts_with(buf, "NACK "))
                        die(_("git archive: NACK %s"), buf + 5);
index 9f6b07ad91f8c2c17e85004a0e71a8b69752d120..54acb421ae17c1ed03d8889b4aa4176a338c7d20 100644 (file)
@@ -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)) {