[PATCH] fix multi_ack, was Re: [PATCH 8/8] git-fetch-pack: Support multi_ack extension

From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Date: 2005-10-28 13:56:41
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---

	I was already half asleep when I realized that

		printf("%s", "\0multi_ack");

	could not work. All the more astounding, that my tests
	said that the server has multi_ack capability. But that
	was my mixing up arguments to strstr().

	Aargh.

	On Fri, 28 Oct 2005, Johannes Schindelin wrote:

	> never mind patch 7 and 8. I succeeded in fscking up again.
	> Will patch tomorrow.

	Well, I could not sleep with such silly a bug.

 connect.c     |    5 +++--
 upload-pack.c |   10 +++++++---
 2 files changed, 10 insertions(+), 5 deletions(-)

applies-to: c45879487343238adc4e926abf0e6280a3f4291c
2c3e9bb8ab663976132315c970c0feea5176fb81
diff --git a/connect.c b/connect.c
index b8aea35..c2badc7 100644
--- a/connect.c
+++ b/connect.c
@@ -8,7 +8,7 @@
 #include <arpa/inet.h>
 #include <netdb.h>
 
-static char *server_capabilities = "";
+static char *server_capabilities = NULL;
 
 /*
  * Read all the refs from the other end
@@ -58,7 +58,8 @@ struct ref **get_remote_heads(int in, st
 
 int server_supports(const char *feature)
 {
-	return strstr(feature, server_capabilities) != NULL;
+	return server_capabilities &&
+		strstr(server_capabilities, feature) != NULL;
 }
 
 int get_ack(int fd, unsigned char *result_sha1)
diff --git a/upload-pack.c b/upload-pack.c
index 686445e..c5eff21 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -212,11 +212,15 @@ static int receive_needs(void)
 
 static int send_ref(const char *refname, const unsigned char *sha1)
 {
-	static char *capabilities = "\0multi_ack";
+	static char *capabilities = "multi_ack";
 	struct object *o = parse_object(sha1);
 
-	packet_write(1, "%s %s%s\n", sha1_to_hex(sha1), refname, capabilities);
-	capabilities = "";
+	if (capabilities)
+		packet_write(1, "%s %s%c%s\n", sha1_to_hex(sha1), refname,
+			0, capabilities);
+	else
+		packet_write(1, "%s %s\n", sha1_to_hex(sha1), refname);
+	capabilities = NULL;
 	if (!(o->flags & OUR_REF)) {
 		o->flags |= OUR_REF;
 		nr_our_refs++;
---
0.99.8.GIT
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Fri Oct 28 13:58:17 2005

This archive was generated by hypermail 2.1.8 : 2005-10-28 13:58:21 EST