Don't hide the transport details Transports shouldn't get used outside of the library, so don't expose accessor functions. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
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/transport.h b/include/git2/transport.h
index 982b081..d19eb8a 100644
--- a/include/git2/transport.h
+++ b/include/git2/transport.h
@@ -45,14 +45,6 @@ GIT_BEGIN_DECL
*/
GIT_EXTERN(int) git_transport_new(git_transport **transport, const char *url);
-GIT_EXTERN(int) git_transport_connect(git_transport *transport, int direction);
-
-GIT_EXTERN(int) git_transport_ls(git_transport *transport, git_headarray *array);
-GIT_EXTERN(int) git_transport_close(git_transport *transport);
-GIT_EXTERN(void) git_transport_free(git_transport *transport);
-
-GIT_EXTERN(int) git_transport_add(git_transport *transport, const char *prefix);
-
/** @} */
GIT_END_DECL
#endif
diff --git a/src/fetch.c b/src/fetch.c
index 0dce875..74c93da 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -48,7 +48,7 @@ static int filter_wants(git_remote *remote)
if (error < GIT_SUCCESS)
return error;
- error = git_transport_ls(t, &refs);
+ error = t->ls(t, &refs);
if (error < GIT_SUCCESS) {
error = git__rethrow(error, "Failed to get remote ref list");
goto cleanup;
@@ -102,6 +102,7 @@ int git_fetch_negotiate(git_remote *remote)
{
int error;
git_headarray *list = &remote->refs;
+ git_transport *t = remote->transport;
error = filter_wants(remote);
if (error < GIT_SUCCESS)
@@ -117,11 +118,11 @@ int git_fetch_negotiate(git_remote *remote)
* Now we have everything set up so we can start tell the server
* what we want and what we have.
*/
- error = git_transport_send_wants(remote->transport, list);
+ error = t->send_wants(t, list);
if (error < GIT_SUCCESS)
return git__rethrow(error, "Failed to send want list");
- return git_transport_negotiate_fetch(remote->transport, remote->repo, &remote->refs);
+ return t->negotiate_fetch(t, remote->repo, &remote->refs);
}
int git_fetch_download_pack(char **out, git_remote *remote)
@@ -131,5 +132,5 @@ int git_fetch_download_pack(char **out, git_remote *remote)
return GIT_SUCCESS;
}
- return git_transport_download_pack(out, remote->transport, remote->repo);
+ return remote->transport->download_pack(out, remote->transport, remote->repo);
}
diff --git a/src/remote.c b/src/remote.c
index 74c5afa..765e938 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -184,7 +184,7 @@ int git_remote_connect(git_remote *remote, int direction)
if (error < GIT_SUCCESS)
return git__rethrow(error, "Failed to create transport");
- error = git_transport_connect(t, direction);
+ error = t->connect(t, direction);
if (error < GIT_SUCCESS) {
error = git__rethrow(error, "Failed to connect the transport");
goto cleanup;
@@ -194,14 +194,14 @@ int git_remote_connect(git_remote *remote, int direction)
cleanup:
if (error < GIT_SUCCESS)
- git_transport_free(t);
+ t->free(t);
return error;
}
int git_remote_ls(git_remote *remote, git_headarray *refs)
{
- return git_transport_ls(remote->transport, refs);
+ return remote->transport->ls(remote->transport, refs);
}
int git_remote_negotiate(git_remote *remote)
@@ -255,8 +255,9 @@ void git_remote_free(git_remote *remote)
free(remote->name);
if (remote->transport != NULL) {
if (remote->transport->connected)
- git_transport_close(remote->transport);
- git_transport_free(remote->transport);
+ remote->transport->close(remote->transport);
+
+ remote->transport->free(remote->transport);
}
free(remote);
}
diff --git a/src/transport.c b/src/transport.c
index 91723df..91f621c 100644
--- a/src/transport.c
+++ b/src/transport.c
@@ -69,53 +69,3 @@ int git_transport_new(git_transport **out, const char *url)
return GIT_SUCCESS;
}
-
-int git_transport_connect(git_transport *transport, int direction)
-{
- return transport->connect(transport, direction);
-}
-
-int git_transport_ls(git_transport *transport, git_headarray *array)
-{
- return transport->ls(transport, array);
-}
-
-int git_transport_send_wants(struct git_transport *transport, git_headarray *array)
-{
- return transport->send_wants(transport, array);
-}
-
-int git_transport_send_have(struct git_transport *transport, git_oid *oid)
-{
- return transport->send_have(transport, oid);
-}
-
-int git_transport_negotiate_fetch(struct git_transport *transport, git_repository *repo, git_headarray *list)
-{
- return transport->negotiate_fetch(transport, repo, list);
-}
-
-int git_transport_send_flush(struct git_transport *transport)
-{
- return transport->send_flush(transport);
-}
-
-int git_transport_send_done(struct git_transport *transport)
-{
- return transport->send_done(transport);
-}
-
-int git_transport_download_pack(char **out, git_transport *transport, git_repository *repo)
-{
- return transport->download_pack(out, transport, repo);
-}
-
-int git_transport_close(git_transport *transport)
-{
- return transport->close(transport);
-}
-
-void git_transport_free(git_transport *transport)
-{
- transport->free(transport);
-}
diff --git a/src/transport.h b/src/transport.h
index 94f88c4..9489ac8 100644
--- a/src/transport.h
+++ b/src/transport.h
@@ -103,11 +103,4 @@ int git_transport_local(struct git_transport **transport);
int git_transport_git(struct git_transport **transport);
int git_transport_dummy(struct git_transport **transport);
-int git_transport_send_wants(struct git_transport *transport, git_headarray *array);
-int git_transport_negotiate_fetch(struct git_transport *transport, git_repository *repo, git_headarray *array);
-int git_transport_send_have(struct git_transport *transport, git_oid *oid);
-int git_transport_send_done(struct git_transport *transport);
-int git_transport_send_flush(struct git_transport *transport);
-int git_transport_download_pack(char **out, git_transport *transport, git_repository *repo);
-
#endif