mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-03 05:30:40 +00:00
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>
This commit is contained in:
parent
747bf5f14c
commit
1636ba5a0d
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -66,14 +66,6 @@ struct git_transport {
|
||||
* Push the changes over
|
||||
*/
|
||||
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
|
||||
*/
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user