diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2020-05-25 19:58:53 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-05-27 10:07:06 -0700 |
commit | 1349ffed6dfa8ddcf9f48ede3b9cfd16fdde16fc (patch) | |
tree | fe70306528f6b06e38caf41274d38aab65db4d49 | |
parent | connect: add function to parse multiple v1 capability values (diff) | |
download | tgif-1349ffed6dfa8ddcf9f48ede3b9cfd16fdde16fc.tar.xz |
connect: add function to fetch value of a v2 server capability
So far in protocol v2, all of our server capabilities that have values
have not had values that we've been interested in parsing. For example,
we receive but ignore the agent value.
However, in a future commit, we're going to want to parse out the value
of a server capability. To make this easy, add a function,
server_feature_v2, that can fetch the value provided as part of the
server capability.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | connect.c | 15 | ||||
-rw-r--r-- | connect.h | 1 |
2 files changed, 16 insertions, 0 deletions
@@ -84,6 +84,21 @@ int server_supports_v2(const char *c, int die_on_error) return 0; } +int server_feature_v2(const char *c, const char **v) +{ + int i; + + for (i = 0; i < server_capabilities_v2.argc; i++) { + const char *out; + if (skip_prefix(server_capabilities_v2.argv[i], c, &out) && + (*out == '=')) { + *v = out + 1; + return 1; + } + } + return 0; +} + int server_supports_feature(const char *c, const char *feature, int die_on_error) { @@ -19,6 +19,7 @@ struct packet_reader; enum protocol_version discover_version(struct packet_reader *reader); int server_supports_v2(const char *c, int die_on_error); +int server_feature_v2(const char *c, const char **v); int server_supports_feature(const char *c, const char *feature, int die_on_error); |