Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2013-11-02 03:05:32 +0400
committerCarlos Martín Nieto <cmn@dwim.me>2013-11-11 18:35:51 +0400
commit359dce726d215be65aee719c7316b43e3851c031 (patch)
tree7a4a0c0af01d2d02683a3aed27eca8315f1f9ca0 /src/push.c
parent266af6d81960144334c16e061f1d30f94f8a1b46 (diff)
remote: make _ls return the list directly
The callback-based method of listing remote references dates back to the beginning of the network code's lifetime, when we didn't know any better. We need to keep the list around for update_tips() after disconnect() so let's make use of this to simply give the user a pointer to the array so they can write straightforward code instead of having to go through a callback.
Diffstat (limited to 'src/push.c')
-rw-r--r--src/push.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/push.c b/src/push.c
index a799db8d0..4f442c6a2 100644
--- a/src/push.c
+++ b/src/push.c
@@ -616,16 +616,22 @@ on_error:
return error;
}
-static int cb_filter_refs(git_remote_head *ref, void *data)
-{
- git_remote *remote = (git_remote *) data;
- return git_vector_insert(&remote->refs, ref);
-}
-
static int filter_refs(git_remote *remote)
{
+ const git_remote_head **heads;
+ size_t heads_len, i;
+
git_vector_clear(&remote->refs);
- return git_remote_ls(remote, cb_filter_refs, remote);
+
+ if (git_remote_ls(&heads, &heads_len, remote) < 0)
+ return -1;
+
+ for (i = 0; i < heads_len; i++) {
+ if (git_vector_insert(&remote->refs, heads[i]) < 0)
+ return -1;
+ }
+
+ return 0;
}
int git_push_finish(git_push *push)