diff options
author | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-08-04 13:07:55 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-08-18 02:34:08 +0200 |
commit | e1d88030687b2ccd652cfedd97714fb37367bbf9 (patch) | |
tree | 57b33e70540666ebc38e12a16b7de7ff23cb00ab /src/fetch.c | |
parent | 44daec422950e0227a863021b6bf4fb8554b6c9c (diff) | |
download | libgit2-e1d88030687b2ccd652cfedd97714fb37367bbf9.tar.gz |
Don't expose the fetch code to the user
Move the generation of the want-list to be done from the negotiate
function, and keep the filtered references inside the remote
structure.
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'src/fetch.c')
-rw-r--r-- | src/fetch.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/fetch.c b/src/fetch.c index 5dc044065..b1da7a19f 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -32,6 +32,7 @@ #include "transport.h" #include "remote.h" #include "refspec.h" +#include "fetch.h" /* * Don't forget that this depends on the enum being correctly set @@ -44,11 +45,7 @@ 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, we also want to be called from _negotiate - */ -int git_fetch_list_want(git_headarray *whn_list, git_remote *remote) +int filter_wants(git_remote *remote) { git_vector list; git_headarray refs; @@ -122,8 +119,8 @@ int git_fetch_list_want(git_headarray *whn_list, git_remote *remote) } git_vector_sort(&list); - whn_list->len = list.length; - whn_list->heads = (git_remote_head **) list.contents; + remote->refs.len = list.length; + remote->refs.heads = (git_remote_head **) list.contents; return GIT_SUCCESS; @@ -137,19 +134,24 @@ cleanup: * them out. When we get an ACK we hide that commit and continue * traversing until we're done */ -int git_fetch_negotiate(git_headarray *list, git_remote *remote) +int git_fetch_negotiate(git_remote *remote) { git_revwalk *walk; int error; unsigned int i; git_reference *ref; git_strarray refs; + git_headarray *list = &remote->refs; git_repository *repo = remote->repo; git_oid oid; + error = filter_wants(remote); + if (error < GIT_SUCCESS) + 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) - return GIT_EINVALIDARGS; + return GIT_SUCCESS; /* * Now we have everything set up so we can start tell the server |