@matheusbsbs / matheus-bagliano / commits / 211b5f9e62
Fork 0

Support receiving server capabilities

This patch implements the client side of backward compatible upload-pack protocol extension, <20051027141619.0e8029f2.vsu@altlinux.ru> by Sergey. The updated server can append "server_capabilities" which is supposed to be a string containing space separated features of the server, after one of elements in the initial list of SHA1-refname line, hidden with an embedded NUL. After get_remote_heads(), check if the server supports the feature like if (server_supports("multi_ack")) do_something(); Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Oct 28, 2005 at 04:48 UTC 211b5f9e62cc961acda59392fbf5a3efa8106c97
2 files changed +16 -1
cache.h
+1
@@ -340,6 +340,7 @@ extern int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
340 int nr_refspec, char **refspec, int all);
341 extern int get_ack(int fd, unsigned char *result_sha1);
342 extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match, int ignore_funny);
343 +extern int server_supports(const char *feature);
344
345 extern struct packed_git *parse_pack_index(unsigned char *sha1);
346 extern struct packed_git *parse_pack_index_file(const unsigned char *sha1,
connect.c
+15 -1
@@ -8,6 +8,8 @@
8 #include <arpa/inet.h>
9 #include <netdb.h>
10
11 +static char *server_capabilities = "";
12 +
13 /*
14 * Read all the refs from the other end
15 */
@@ -20,7 +22,7 @@ struct ref **get_remote_heads(int in, struct ref **list,
22 unsigned char old_sha1[20];
23 static char buffer[1000];
24 char *name;
23 - int len;
25 + int len, name_len;
26
27 len = packet_read_line(in, buffer, sizeof(buffer));
28 if (!len)
@@ -36,6 +38,13 @@ struct ref **get_remote_heads(int in, struct ref **list,
38 check_ref_format(name + 5))
39 continue;
40
41 + name_len = strlen(name);
42 + if (len != name_len + 41) {
43 + if (server_capabilities)
44 + free(server_capabilities);
45 + server_capabilities = strdup(name + name_len + 1);
46 + }
47 +
48 if (nr_match && !path_match(name, nr_match, match))
49 continue;
50 ref = xcalloc(1, sizeof(*ref) + len - 40);
@@ -47,6 +56,11 @@ struct ref **get_remote_heads(int in, struct ref **list,
56 return list;
57 }
58
59 +int server_supports(const char *feature)
60 +{
61 + return strstr(feature, server_capabilities) != NULL;
62 +}
63 +
64 int get_ack(int fd, unsigned char *result_sha1)
65 {
66 static char line[1000];