]> git.ipfire.org Git - thirdparty/git.git/commitdiff
connect: add function to fetch value of a v2 server capability
authorbrian m. carlson <sandals@crustytoothpaste.net>
Mon, 25 May 2020 19:58:53 +0000 (19:58 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 May 2020 17:07:06 +0000 (10:07 -0700)
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>
connect.c
connect.h

index 2b55a32d4dc10d0184dc757cd0843a299d58a0f4..ad0e4e8e564a3c2c04219f9f5a69d8515fb34f9c 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -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)
 {
index 5f2382e01868042757901a419b5e5f34ad8bb279..4d76a6017deafab2a3c250de2b56f1a8d423f3a7 100644 (file)
--- a/connect.h
+++ b/connect.h
@@ -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);