X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=connect.c;h=912cddeea8c4f09ec523ce19e677358c84eda9b7;hb=cb2ed324fc917db0b79d7b1f3756575ffa5f70d5;hp=2ea5c3c0fbedb89e4189d32a455f289398ce106b;hpb=5de89d3abfca98b0dfd0280d28576940c913d60d;p=git.git diff --git a/connect.c b/connect.c index 2ea5c3c0f..912cddeea 100644 --- a/connect.c +++ b/connect.c @@ -101,8 +101,27 @@ struct ref **get_remote_heads(int in, struct ref **list, int server_supports(const char *feature) { - return server_capabilities && - strstr(server_capabilities, feature) != NULL; + return !!parse_feature_request(server_capabilities, feature); +} + +const char *parse_feature_request(const char *feature_list, const char *feature) +{ + int len; + + if (!feature_list) + return NULL; + + len = strlen(feature); + while (*feature_list) { + const char *found = strstr(feature_list, feature); + if (!found) + return NULL; + if ((feature_list == found || isspace(found[-1])) && + (!found[len] || isspace(found[len]) || found[len] == '=')) + return found; + feature_list = found + 1; + } + return NULL; } enum protocol {