summaryrefslogtreecommitdiff
path: root/src/fetch.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2012-04-14 18:34:50 +0200
committerCarlos Martín Nieto <carlos@cmartin.tk>2012-04-25 12:44:27 +0200
commitdee5515a237b2d4182e454986025199064193376 (patch)
treebf44e2a0b6d0c9977e3b1aeab7290361dec802d8 /src/fetch.c
parentdb0f96a6aff33612d88ab5d9263bcad9daf6b11a (diff)
downloadlibgit2-dee5515a237b2d4182e454986025199064193376.tar.gz
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.c41
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;
+}