Add a generic send_wants 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
diff --git a/src/fetch.c b/src/fetch.c
index b9ddaf1..59beb1e 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -44,7 +44,10 @@ static int whn_cmp(const void *a, const void *b)
return headb->type - heada->type;
}
-/* FIXME: we assume that the transport has been connected, enforce that somehow */
+/*
+ * FIXME: we assume that the transport has been connected, enforce
+ * that somehow, we also want to be called from _negotiate
+ */
int git_fetch_list_want(git_headarray *whn_list, git_repository *repo, git_remote *remote)
{
git_vector list;
@@ -179,7 +182,7 @@ int git_fetch_negotiate(git_headarray *list, git_repository *repo, git_remote *r
* Now we have everything set up so we can start tell the server
* what we want and what we have.
*/
- git_pkt_send_wants(list);
+ git_remote_send_wants(remote, list);
cleanup:
diff --git a/src/remote.c b/src/remote.c
index 2812f5d..997da00 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -31,6 +31,11 @@
#include "repository.h"
#include "remote.h"
+int git_remote_send_wants(git_remote *remote, git_headarray *list)
+{
+ return git_transport_send_wants(remote->transport, list);
+}
+
static int refspec_parse(git_refspec *refspec, const char *str)
{
char *delim;
diff --git a/src/remote.h b/src/remote.h
index fdd6cd5..e0c3fbf 100644
--- a/src/remote.h
+++ b/src/remote.h
@@ -13,4 +13,6 @@ struct git_remote {
git_transport *transport;
};
+int git_remote_send_wants(git_remote *remote, git_headarray *list);
+
#endif
diff --git a/src/transport.c b/src/transport.c
index 204ef17..96b79dd 100644
--- a/src/transport.c
+++ b/src/transport.c
@@ -80,6 +80,11 @@ 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_close(git_transport *transport)
{
return transport->close(transport);
diff --git a/src/transport.h b/src/transport.h
index b17d9a9..9105ea4 100644
--- a/src/transport.h
+++ b/src/transport.h
@@ -57,6 +57,10 @@ 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);
+ /**
* Fetch the changes
*/
int (*fetch)(struct git_transport *transport);
@@ -74,4 +78,6 @@ 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);
+
#endif
diff --git a/src/transport_git.c b/src/transport_git.c
index b07b986..41b95ec 100644
--- a/src/transport_git.c
+++ b/src/transport_git.c
@@ -274,6 +274,13 @@ 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->socket);
+}
+
static int git_close(git_transport *transport)
{
transport_git *t = (transport_git*) transport;
@@ -318,6 +325,7 @@ 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.close = git_close;
t->parent.free = git_free;
diff --git a/src/transport_local.c b/src/transport_local.c
index 4e0ac6f..b38679a 100644
--- a/src/transport_local.c
+++ b/src/transport_local.c
@@ -165,6 +165,15 @@ static int local_ls(git_transport *transport, git_headarray *array)
return error;
}
+static int local_send_wants(git_transport *GIT_UNUSED(transport), git_headarray *GIT_UNUSED(array))
+{
+ GIT_UNUSED_ARG(tranport);
+ GIT_UNUSED_ARG(array);
+
+ /* 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 */