diff options
author | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-04-14 20:34:50 +0400 |
---|---|---|
committer | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-04-25 14:44:27 +0400 |
commit | dee5515a237b2d4182e454986025199064193376 (patch) | |
tree | bf44e2a0b6d0c9977e3b1aeab7290361dec802d8 /src/fetch.c | |
parent | db0f96a6aff33612d88ab5d9263bcad9daf6b11a (diff) |
transports: buffer the git requests before sending them
Trying to send every single line immediately won't give us any speed
improvement and duplicates the code we need for other transports. Make
the git transport use the same buffer functions as HTTP.
Diffstat (limited to 'src/fetch.c')
-rw-r--r-- | src/fetch.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/fetch.c b/src/fetch.c index 8da4fd8cd..6fe1b5676 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -161,3 +161,44 @@ on_error: git_indexer_stream_free(idx); return -1; } + +int git_fetch_setup_walk(git_revwalk **out, git_repository *repo) +{ + git_revwalk *walk; + git_strarray refs; + unsigned int i; + git_reference *ref; + + if (git_reference_listall(&refs, repo, GIT_REF_LISTALL) < 0) + return -1; + + if (git_revwalk_new(&walk, repo) < 0) + return -1; + + git_revwalk_sorting(walk, GIT_SORT_TIME); + + for (i = 0; i < refs.count; ++i) { + /* No tags */ + if (!git__prefixcmp(refs.strings[i], GIT_REFS_TAGS_DIR)) + continue; + + if (git_reference_lookup(&ref, repo, refs.strings[i]) < 0) + goto on_error; + + if (git_reference_type(ref) == GIT_REF_SYMBOLIC) + continue; + if (git_revwalk_push(walk, git_reference_oid(ref)) < 0) + goto on_error; + + git_reference_free(ref); + } + + git_strarray_free(&refs); + *out = walk; + return 0; + +on_error: + git_reference_free(ref); + git_strarray_free(&refs); + return -1; +} |