X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=connect.c;h=c2badc71aa2ccf63fa6d9ef02a5ee76feb54e5c9;hb=90279074ca5cc336a8bfffd47d19d089b291b432;hp=b171c5dbc8c9ecc32f6738d17c339858cbbf76f1;hpb=af2d3aa4d84fd3475d9b676f669eab3c4227189f;p=git.git diff --git a/connect.c b/connect.c index b171c5db..c2badc71 100644 --- a/connect.c +++ b/connect.c @@ -8,6 +8,8 @@ #include #include +static char *server_capabilities = NULL; + /* * Read all the refs from the other end */ @@ -20,7 +22,7 @@ struct ref **get_remote_heads(int in, struct ref **list, unsigned char old_sha1[20]; static char buffer[1000]; char *name; - int len; + int len, name_len; len = packet_read_line(in, buffer, sizeof(buffer)); if (!len) @@ -36,6 +38,13 @@ struct ref **get_remote_heads(int in, struct ref **list, check_ref_format(name + 5)) continue; + name_len = strlen(name); + if (len != name_len + 41) { + if (server_capabilities) + free(server_capabilities); + server_capabilities = strdup(name + name_len + 1); + } + if (nr_match && !path_match(name, nr_match, match)) continue; ref = xcalloc(1, sizeof(*ref) + len - 40); @@ -47,6 +56,12 @@ struct ref **get_remote_heads(int in, struct ref **list, return list; } +int server_supports(const char *feature) +{ + return server_capabilities && + strstr(server_capabilities, feature) != NULL; +} + int get_ack(int fd, unsigned char *result_sha1) { static char line[1000]; @@ -59,8 +74,11 @@ int get_ack(int fd, unsigned char *result_sha1) if (!strcmp(line, "NAK")) return 0; if (!strncmp(line, "ACK ", 3)) { - if (!get_sha1_hex(line+4, result_sha1)) + if (!get_sha1_hex(line+4, result_sha1)) { + if (strstr(line+45, "continue")) + return 2; return 1; + } } die("git-fetch_pack: expected ACK/NAK, got '%s'", line); }