Commit 7a00adcc68ed84fb1f7f9403bfaf7a0a4503e310

Edward Thomson 2022-02-06T14:58:33

remote: introduce git_remote_capabilities Provide a mechanism for (internal) users to determine a remote's capabilities from the transport.

diff --git a/src/remote.c b/src/remote.c
index fd47036..b588864 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -1012,6 +1012,20 @@ int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote
 	return remote->transport->ls(out, size, remote->transport);
 }
 
+int git_remote_capabilities(unsigned int *out, git_remote *remote)
+{
+	GIT_ASSERT_ARG(remote);
+
+	*out = 0;
+
+	if (!remote->transport) {
+		git_error_set(GIT_ERROR_NET, "this remote has never connected");
+		return -1;
+	}
+
+	return remote->transport->capabilities(out, remote->transport);
+}
+
 static int lookup_config(char **out, git_config *cfg, const char *name)
 {
 	git_config_entry *ce = NULL;
diff --git a/src/remote.h b/src/remote.h
index 3cf0fd9..0952c7c 100644
--- a/src/remote.h
+++ b/src/remote.h
@@ -54,4 +54,6 @@ int git_remote_connect_options_normalize(
 	const git_remote_connect_options *src);
 void git_remote_connect_options_dispose(git_remote_connect_options *opts);
 
+int git_remote_capabilities(unsigned int *out, git_remote *remote);
+
 #endif