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/clone.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/clone.c')
-rw-r--r--src/clone.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/clone.c b/src/clone.c
index f9338b746..23aacd478 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -176,25 +176,20 @@ static int update_head_to_new_branch(
return error;
}
-static int get_head_callback(git_remote_head *head, void *payload)
-{
- git_remote_head **destination = (git_remote_head **)payload;
-
- /* Save the first entry, and terminate the enumeration */
- *destination = head;
- return 1;
-}
-
static int update_head_to_remote(git_repository *repo, git_remote *remote)
{
int retcode = -1;
+ size_t refs_len;
git_refspec dummy_spec;
- git_remote_head *remote_head;
+ const git_remote_head *remote_head, **refs;
struct head_info head_info;
git_buf remote_master_name = GIT_BUF_INIT;
+ if (git_remote_ls(&refs, &refs_len, remote) < 0)
+ return -1;
+
/* Did we just clone an empty repository? */
- if (remote->refs.length == 0) {
+ if (refs_len == 0) {
return setup_tracking_config(
repo,
"master",
@@ -202,12 +197,8 @@ static int update_head_to_remote(git_repository *repo, git_remote *remote)
GIT_REFS_HEADS_MASTER_FILE);
}
- /* Get the remote's HEAD. This is always the first ref in remote->refs. */
- remote_head = NULL;
-
- if (!remote->transport->ls(remote->transport, get_head_callback, &remote_head))
- return -1;
-
+ /* Get the remote's HEAD. This is always the first ref in the list. */
+ remote_head = refs[0];
assert(remote_head);
git_oid_cpy(&head_info.remote_head_oid, &remote_head->oid);