Commit 895a668e19dc596e7b12ea27724ceb7b68556106

Nelson Elhage 2018-06-28T05:27:36

Small style tweak, and set an error

diff --git a/src/transports/smart_pkt.c b/src/transports/smart_pkt.c
index df35a60..07701ab 100644
--- a/src/transports/smart_pkt.c
+++ b/src/transports/smart_pkt.c
@@ -394,7 +394,17 @@ int git_pkt_parse_line(
 
 	len = parse_len(line);
 	if (len < 0) {
-		return GIT_ERROR;
+		/*
+		 * If we fail to parse the length, it might be because the
+		 * server is trying to send us the packfile already.
+		 */
+		if (bufflen >= 4 && !git__prefixcmp(line, "PACK")) {
+			giterr_set(GITERR_NET, "unexpected pack file");
+		} else {
+			giterr_set(GITERR_NET, "bad packet length");
+		}
+
+		return -1;
 	}
 
 	/*