{"thread":{"id":"2252","subject":"[PATCH 6/8] Support receiving server capabilities","startedAt":"2005-10-28T02:48:54Z","lastAt":"2005-10-28T02:48:54Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"10739","messageId":"Pine.LNX.4.63.0510280448330.20516@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2252","inReplyTo":null,"subject":"[PATCH 6/8] Support receiving server capabilities","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-28T02:48:54Z","receivedAt":"2005-10-28T02:48:54Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nOn Thu, 27 Oct 2005, Sergey Vlasov wrote:\n\n> Actually, there is another way to pass some data from the server\n> which would be ignored by older clients - at the first stage,\n> when upload-pack sends the list of refs to the client:\n>\n>       packet_write(1, \"%s %s%c%s\\n\", sha1_to_hex(sha1), refname, '\\0',\n>                    server_capabilities);\n\nThis patch implements the client side of it. server_capabilities is supposed\nto be a string containing space separated features of the server.\n\nAfter get_remote_heads(), check if the server supports the feature like\n\n\tif (server_supports(\"multi_ack\"))\n\t\tdo_something();\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n cache.h   |    1 +\n connect.c |   16 +++++++++++++++-\n 2 files changed, 16 insertions(+), 1 deletions(-)\n\napplies-to: 755b5d7a6bb3861a284381a8adb26c2241217355\n883ea2e2bf664c78a7bee5b29ad9584339085310\ndiff --git a/cache.h b/cache.h\nindex 2e36cc5..677c6ac 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -340,6 +340,7 @@ extern int match_refs(struct ref *src, s\n \t\t      int nr_refspec, char **refspec, int all);\n extern int get_ack(int fd, unsigned char *result_sha1);\n extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match, int ignore_funny);\n+extern int server_supports(const char *feature);\n \n extern struct packed_git *parse_pack_index(unsigned char *sha1);\n extern struct packed_git *parse_pack_index_file(const unsigned char *sha1,\ndiff --git a/connect.c b/connect.c\nindex b171c5d..5cc49f9 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -8,6 +8,8 @@\n #include <arpa/inet.h>\n #include <netdb.h>\n \n+static char *server_capabilities = \"\";\n+\n /*\n  * Read all the refs from the other end\n  */\n@@ -20,7 +22,7 @@ struct ref **get_remote_heads(int in, st\n \t\tunsigned char old_sha1[20];\n \t\tstatic char buffer[1000];\n \t\tchar *name;\n-\t\tint len;\n+\t\tint len, name_len;\n \n \t\tlen = packet_read_line(in, buffer, sizeof(buffer));\n \t\tif (!len)\n@@ -36,6 +38,13 @@ struct ref **get_remote_heads(int in, st\n \t\t    check_ref_format(name + 5))\n \t\t\tcontinue;\n \n+\t\tname_len = strlen(name);\n+\t\tif (len != name_len + 41) {\n+\t\t\tif (server_capabilities)\n+\t\t\t\tfree(server_capabilities);\n+\t\t\tserver_capabilities = strdup(name + name_len + 1);\n+\t\t}\n+\n \t\tif (nr_match && !path_match(name, nr_match, match))\n \t\t\tcontinue;\n \t\tref = xcalloc(1, sizeof(*ref) + len - 40);\n@@ -47,6 +56,11 @@ struct ref **get_remote_heads(int in, st\n \treturn list;\n }\n \n+int server_supports(const char *feature)\n+{\n+\treturn strstr(feature, server_capabilities) != NULL;\n+}\n+\n int get_ack(int fd, unsigned char *result_sha1)\n {\n \tstatic char line[1000];\n---\n0.99.8.GIT\n"}]}