Subject: [PATCH 07/12] connect.c: replace some use of starts_with() with skip_prefix()

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Wed, 18 Dec 2013 21:53:52 +0700

"name" will be reset unconditionally soon after skip_prefix() returns
NULL.

Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
---
 connect.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/connect.c b/connect.c
index c763eed..1bb70aa 100644
--- a/connect.c
+++ b/connect.c
@@ -131,7 +131,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
 	for (;;) {
 		struct ref *ref;
 		unsigned char old_sha1[20];
-		char *name;
+		const char *name;
 		int len, name_len;
 		char *buffer = packet_buffer;
 
@@ -145,8 +145,8 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
 		if (!len)
 			break;
 
-		if (len > 4 && starts_with(buffer, "ERR "))
-			die("remote error: %s", buffer + 4);
+		if ((name = skip_prefix(buffer, "ERR ")) != NULL)
+			die("remote error: %s", name);
 
 		if (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')
 			die("protocol error: expected sha/ref, got '%s'", buffer);
-- 
1.8.5.1.208.g019362e