Commit 32586d5e1002536fc3b4eee5ee40f2efb0038e91

Etienne Samson 2018-04-11T19:03:57

smart: separate error handling from pkt handling

diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 2dab615..a1b56da 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -397,10 +397,10 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
 				if ((error = store_common(t)) < 0)
 					goto on_error;
 			} else {
-				error = recv_pkt(NULL, &pkt_type, buf);
-				if (error < 0) {
+				if ((error = recv_pkt(NULL, &pkt_type, buf)) < 0)
 					goto on_error;
-				} else if (pkt_type == GIT_PKT_ACK) {
+
+				if (pkt_type == GIT_PKT_ACK) {
 					break;
 				} else if (pkt_type == GIT_PKT_NAK) {
 					continue;
@@ -469,11 +469,10 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
 
 	/* Now let's eat up whatever the server gives us */
 	if (!t->caps.multi_ack && !t->caps.multi_ack_detailed) {
-		error = recv_pkt(NULL, &pkt_type, buf);
-
-		if (error < 0) {
+		if ((error = recv_pkt(NULL, &pkt_type, buf)) < 0)
 			return error;
-		} else if (pkt_type != GIT_PKT_ACK && pkt_type != GIT_PKT_NAK) {
+
+		if (pkt_type != GIT_PKT_ACK && pkt_type != GIT_PKT_NAK) {
 			giterr_set(GITERR_NET, "Unexpected pkt type");
 			return -1;
 		}