diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-08-10 20:49:43 +0200 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-08-18 02:34:10 +0200 |
| commit | 22f65b9e730cd14275897a07b61e338e25099b19 (patch) | |
| tree | 54172423e8c18782012a4f9430d2a15384b1ee56 /src/fetch.c | |
| parent | 79e9c3eca29e31dff873a99e33c452c8d5d5b6ac (diff) | |
| download | libgit2-22f65b9e730cd14275897a07b61e338e25099b19.tar.gz | |
Move negotiation to the transport
There are many ways how a transport might negotiate with the server,
so instead of making it fit into the smart protocol model, let the
transport do its thing. For now, the git protocol limits itself to
send only 160 "have" lines so we don't flood the server.
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'src/fetch.c')
| -rw-r--r-- | src/fetch.c | 50 |
1 files changed, 4 insertions, 46 deletions
diff --git a/src/fetch.c b/src/fetch.c index 044d4c9cc..03febe279 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -98,14 +98,8 @@ cleanup: */ 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) @@ -119,47 +113,11 @@ int git_fetch_negotiate(git_remote *remote) * what we want and what we have. */ remote->need_pack = 1; - git_transport_send_wants(remote->transport, list); - - error = git_reference_listall(&refs, repo, GIT_REF_LISTALL); - if (error < GIT_ERROR) - return git__rethrow(error, "Failed to list all references"); - - error = git_revwalk_new(&walk, repo); - if (error < GIT_ERROR) { - error = git__rethrow(error, "Failed to list all references"); - goto cleanup; - } - git_revwalk_sorting(walk, GIT_SORT_TIME); - - for (i = 0; i < refs.count; ++i) { - error = git_reference_lookup(&ref, repo, refs.strings[i]); - if (error < GIT_ERROR) { - error = git__rethrow(error, "Failed to lookup %s", refs.strings[i]); - goto cleanup; - } - - error = git_revwalk_push(walk, git_reference_oid(ref)); - if (error < GIT_ERROR) { - error = git__rethrow(error, "Failed to push %s", refs.strings[i]); - goto cleanup; - } - } - git_strarray_free(&refs); - - while ((error = git_revwalk_next(&oid, walk)) == GIT_SUCCESS) { - git_transport_send_have(remote->transport, &oid); - } - if (error == GIT_EREVWALKOVER) - error = GIT_SUCCESS; - - /* TODO: git_pkt_send_flush(fd), or git_transport_flush() */ - git_transport_send_flush(remote->transport); - git_transport_send_done(remote->transport); + error = git_transport_send_wants(remote->transport, list); + if (error < GIT_SUCCESS) + return git__rethrow(error, "Failed to send want list"); -cleanup: - git_revwalk_free(walk); - return error; + return git_transport_negotiate_fetch(remote->transport, remote->repo, &remote->refs); } int git_fetch_download_pack(char **out, git_remote *remote) |
