Add a custom param to git_smart_subtransport_definition The smart transport has already take the payload param. For the sub transport a payload param is useful for the implementer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
diff --git a/include/git2/sys/transport.h b/include/git2/sys/transport.h
index 69d4e15..2cb1a97 100644
--- a/include/git2/sys/transport.h
+++ b/include/git2/sys/transport.h
@@ -289,7 +289,8 @@ struct git_smart_subtransport {
/* A function which creates a new subtransport for the smart transport */
typedef int (*git_smart_subtransport_cb)(
git_smart_subtransport **out,
- git_transport* owner);
+ git_transport* owner,
+ void* param);
/**
* Definition for a "subtransport"
@@ -306,6 +307,10 @@ typedef struct git_smart_subtransport_definition {
* http:// is stateless, but git:// is not.
*/
unsigned rpc;
+
+ /** Param of the callback
+ */
+ void* param;
} git_smart_subtransport_definition;
/* Smart transport subtransports that come with libgit2 */
@@ -321,7 +326,8 @@ typedef struct git_smart_subtransport_definition {
*/
GIT_EXTERN(int) git_smart_subtransport_http(
git_smart_subtransport **out,
- git_transport* owner);
+ git_transport* owner,
+ void *param);
/**
* Create an instance of the git subtransport.
@@ -332,7 +338,8 @@ GIT_EXTERN(int) git_smart_subtransport_http(
*/
GIT_EXTERN(int) git_smart_subtransport_git(
git_smart_subtransport **out,
- git_transport* owner);
+ git_transport* owner,
+ void *param);
/**
* Create an instance of the ssh subtransport.
@@ -343,7 +350,8 @@ GIT_EXTERN(int) git_smart_subtransport_git(
*/
GIT_EXTERN(int) git_smart_subtransport_ssh(
git_smart_subtransport **out,
- git_transport* owner);
+ git_transport* owner,
+ void *param);
/**
* Sets a custom transport factory for the remote. The caller can use this
diff --git a/src/transport.c b/src/transport.c
index a41ea0a..fc9c692 100644
--- a/src/transport.c
+++ b/src/transport.c
@@ -18,10 +18,10 @@ typedef struct transport_definition {
void *param;
} transport_definition;
-static git_smart_subtransport_definition http_subtransport_definition = { git_smart_subtransport_http, 1 };
-static git_smart_subtransport_definition git_subtransport_definition = { git_smart_subtransport_git, 0 };
+static git_smart_subtransport_definition http_subtransport_definition = { git_smart_subtransport_http, 1, NULL };
+static git_smart_subtransport_definition git_subtransport_definition = { git_smart_subtransport_git, 0, NULL };
#ifdef GIT_SSH
-static git_smart_subtransport_definition ssh_subtransport_definition = { git_smart_subtransport_ssh, 0 };
+static git_smart_subtransport_definition ssh_subtransport_definition = { git_smart_subtransport_ssh, 0, NULL };
#endif
static transport_definition local_transport_definition = { "file://", git_transport_local, NULL };
diff --git a/src/transports/git.c b/src/transports/git.c
index 5ec98d8..ea95ed1 100644
--- a/src/transports/git.c
+++ b/src/transports/git.c
@@ -340,10 +340,12 @@ static void _git_free(git_smart_subtransport *subtransport)
git__free(t);
}
-int git_smart_subtransport_git(git_smart_subtransport **out, git_transport *owner)
+int git_smart_subtransport_git(git_smart_subtransport **out, git_transport *owner, void *param)
{
git_subtransport *t;
+ GIT_UNUSED(param);
+
if (!out)
return -1;
diff --git a/src/transports/http.c b/src/transports/http.c
index 0907afa..c442465 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -1007,10 +1007,12 @@ static void http_free(git_smart_subtransport *subtransport)
git__free(t);
}
-int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *owner)
+int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *owner, void *param)
{
http_subtransport *t;
+ GIT_UNUSED(param);
+
if (!out)
return -1;
diff --git a/src/transports/smart.c b/src/transports/smart.c
index 69b9d22..85a49e5 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -409,7 +409,7 @@ int git_transport_smart(git_transport **out, git_remote *owner, void *param)
return -1;
}
- if (definition->callback(&t->wrapped, &t->parent) < 0) {
+ if (definition->callback(&t->wrapped, &t->parent, definition->param) < 0) {
git__free(t);
return -1;
}
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index 33d0898..c5b0811 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -754,13 +754,15 @@ static int list_auth_methods(int *out, LIBSSH2_SESSION *session, const char *use
#endif
int git_smart_subtransport_ssh(
- git_smart_subtransport **out, git_transport *owner)
+ git_smart_subtransport **out, git_transport *owner, void *param)
{
#ifdef GIT_SSH
ssh_subtransport *t;
assert(out);
+ GIT_UNUSED(param);
+
t = git__calloc(sizeof(ssh_subtransport), 1);
GITERR_CHECK_ALLOC(t);
@@ -773,6 +775,7 @@ int git_smart_subtransport_ssh(
return 0;
#else
GIT_UNUSED(owner);
+ GIT_UNUSED(param);
assert(out);
*out = NULL;
@@ -793,6 +796,7 @@ int git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *p
git_smart_subtransport_definition ssh_definition = {
git_smart_subtransport_ssh,
0, /* no RPC */
+ NULL,
};
if (paths->count != 2) {
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c
index 278ef22..a993bc9 100644
--- a/src/transports/winhttp.c
+++ b/src/transports/winhttp.c
@@ -1322,10 +1322,12 @@ static void winhttp_free(git_smart_subtransport *subtransport)
git__free(t);
}
-int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *owner)
+int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *owner, void *param)
{
winhttp_subtransport *t;
+ GIT_UNUSED(param);
+
if (!out)
return -1;