transport: don't have an extra send-wants step It's a bit awkward to run it as an extra step, and HTTP may need to send the wants list several times. 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 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
diff --git a/src/fetch.c b/src/fetch.c
index cc3744b..8602cd7 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -103,7 +103,6 @@ cleanup:
int git_fetch_negotiate(git_remote *remote)
{
int error;
- git_headarray *list = &remote->refs;
git_transport *t = remote->transport;
error = filter_wants(remote);
@@ -111,7 +110,7 @@ int git_fetch_negotiate(git_remote *remote)
return git__rethrow(error, "Failed to filter the reference list for wants");
/* Don't try to negotiate when we don't want anything */
- if (list->len == 0)
+ if (remote->refs.len == 0)
return GIT_SUCCESS;
if (!remote->need_pack)
return GIT_SUCCESS;
@@ -120,10 +119,6 @@ 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 = t->send_wants(t, list);
- if (error < GIT_SUCCESS)
- return git__rethrow(error, "Failed to send want list");
-
return t->negotiate_fetch(t, remote->repo, &remote->refs);
}
diff --git a/src/transport-http.c b/src/transport-http.c
index 109c9ee..54f5df6 100644
--- a/src/transport-http.c
+++ b/src/transport-http.c
@@ -341,12 +341,20 @@ static int http_ls(git_transport *transport, git_headarray *array)
return GIT_SUCCESS;
}
-static int http_send_wants(git_transport *transport, git_headarray *array)
+static int http_negotiate_fetch(git_transport *transport, git_repository *repo, git_headarray *wants)
{
transport_http *t = (transport_http *) transport;
+ GIT_UNUSED_ARG(list);
+ int error;
+ unsigned int i;
+ char buff[128];
+ gitno_buffer buf;
+ git_strarray refs;
+ git_revwalk *walk;
+ git_reference *ref;
+ git_oid oid;
const char *prefix = "http://", *url = t->parent.url;
git_buf request = GIT_BUF_INIT;
- int error;
/* TODO: Store url in the transport */
if (!git__prefixcmp(url, prefix))
@@ -364,21 +372,9 @@ static int http_send_wants(git_transport *transport, git_headarray *array)
if (error < GIT_SUCCESS)
return git__rethrow(error, "Failed to send request");
- return git_pkt_send_wants(array, &t->caps, t->socket, 1);
-}
-
-static int http_negotiate_fetch(git_transport *transport, git_repository *repo, git_headarray *GIT_UNUSED(list))
-{
- transport_http *t = (transport_http *) transport;
- GIT_UNUSED_ARG(list);
- int error;
- unsigned int i;
- char buff[128];
- gitno_buffer buf;
- git_strarray refs;
- git_revwalk *walk;
- git_reference *ref;
- git_oid oid;
+ error = git_pkt_send_wants(wants, &t->caps, t->socket, 1);
+ if (error < GIT_SUCCESS)
+ return git__rethrow(error, "Failed to send wants");
gitno_buffer_setup(&buf, buff, sizeof(buff), t->socket);
@@ -481,7 +477,6 @@ int git_transport_http(git_transport **out)
t->parent.connect = http_connect;
t->parent.ls = http_ls;
- t->parent.send_wants = http_send_wants;
t->parent.negotiate_fetch = http_negotiate_fetch;
t->parent.close = http_close;
t->parent.free = http_free;
diff --git a/src/transport.h b/src/transport.h
index eaa50d6..23b83b6 100644
--- a/src/transport.h
+++ b/src/transport.h
@@ -67,14 +67,6 @@ struct git_transport {
*/
int (*push)(struct git_transport *transport);
/**
- * Send the list of 'want' refs
- */
- int (*send_wants)(struct git_transport *transport, git_headarray *list);
- /**
- * Send the list of 'have' refs
- */
- int (*send_have)(struct git_transport *transport, git_oid *oid);
- /**
* Send a 'done' message
*/
int (*send_done)(struct git_transport *transport);
diff --git a/src/transport_git.c b/src/transport_git.c
index d3d5747..e4c5a07 100644
--- a/src/transport_git.c
+++ b/src/transport_git.c
@@ -265,21 +265,7 @@ static int git_ls(git_transport *transport, git_headarray *array)
return GIT_SUCCESS;
}
-static int git_send_wants(git_transport *transport, git_headarray *array)
-{
- transport_git *t = (transport_git *) transport;
-
- return git_pkt_send_wants(array, &t->caps, t->socket, 0);
-}
-
-static int git_send_have(git_transport *transport, git_oid *oid)
-{
- transport_git *t = (transport_git *) transport;
-
- return git_pkt_send_have(oid, t->socket, 0);
-}
-
-static int git_negotiate_fetch(git_transport *transport, git_repository *repo, git_headarray *GIT_UNUSED(list))
+static int git_negotiate_fetch(git_transport *transport, git_repository *repo, git_headarray *wants)
{
transport_git *t = (transport_git *) transport;
git_revwalk *walk;
@@ -290,7 +276,10 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, g
unsigned int i;
char buff[128];
gitno_buffer buf;
- GIT_UNUSED_ARG(list);
+
+ error = git_pkt_send_wants(wants, &t->caps, t->socket, 0);
+ if (error < GIT_SUCCESS)
+ return git__rethrow(error, "Failed to send wants list");
gitno_buffer_setup(&buf, buff, sizeof(buff), t->socket);
@@ -548,8 +537,6 @@ int git_transport_git(git_transport **out)
t->parent.connect = git_connect;
t->parent.ls = git_ls;
- t->parent.send_wants = git_send_wants;
- t->parent.send_have = git_send_have;
t->parent.negotiate_fetch = git_negotiate_fetch;
t->parent.send_flush = git_send_flush;
t->parent.send_done = git_send_done;
diff --git a/src/transport_local.c b/src/transport_local.c
index 7e932f8..3f47e9b 100644
--- a/src/transport_local.c
+++ b/src/transport_local.c
@@ -19,7 +19,6 @@ typedef struct {
git_transport parent;
git_repository *repo;
git_vector *refs;
- git_headarray wants_list;
} transport_local;
/*
@@ -173,22 +172,6 @@ static int local_ls(git_transport *transport, git_headarray *array)
return error;
}
-static int local_send_wants(git_transport *transport, git_headarray *array)
-{
- transport_local *t = (transport_local *) transport;
- git_headarray *wants = &t->wants_list;
-
- /*
- * We need to store the list of wanted references so we can figure
- * out what to transmit later.
- */
- wants->len = array->len;
- wants->heads = array->heads;
-
- /* We're local anyway, so we don't need this */
- return GIT_SUCCESS;
-}
-
static int local_close(git_transport *GIT_UNUSED(transport))
{
/* Nothing to do */
@@ -235,7 +218,6 @@ int git_transport_local(git_transport **out)
t->parent.connect = local_connect;
t->parent.ls = local_ls;
- t->parent.send_wants = local_send_wants;
t->parent.close = local_close;
t->parent.free = local_free;