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:
authorVicent Martí <vicent@github.com>2013-11-11 18:47:15 +0400
committerVicent Martí <vicent@github.com>2013-11-11 18:47:15 +0400
commit6414fd338df89eaa5bd4c64f7ab310fb7d5758bb (patch)
tree4af0ea37b387c791bd89e73edea10e3353c54423 /examples
parent5e1281f873e7eb5b51569ef33218dd20b69ff707 (diff)
parenta6192d7c98976edb0ce4fd10438ac7a19c283598 (diff)
Merge pull request #1956 from libgit2/cmn/fetch-default-head
Remote revamp (director's cut)
Diffstat (limited to 'examples')
-rw-r--r--examples/network/ls-remote.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/examples/network/ls-remote.c b/examples/network/ls-remote.c
index 18cd02367..1e08b293e 100644
--- a/examples/network/ls-remote.c
+++ b/examples/network/ls-remote.c
@@ -4,21 +4,12 @@
#include <string.h>
#include "common.h"
-/** Callback to show each item */
-static int show_ref__cb(git_remote_head *head, void *payload)
-{
- char oid[GIT_OID_HEXSZ + 1] = {0};
-
- (void)payload;
- git_oid_fmt(oid, &head->oid);
- printf("%s\t%s\n", oid, head->name);
- return 0;
-}
-
static int use_remote(git_repository *repo, char *name)
{
git_remote *remote = NULL;
int error;
+ const git_remote_head **refs;
+ size_t refs_len, i;
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
// Find the remote by name
@@ -40,7 +31,18 @@ static int use_remote(git_repository *repo, char *name)
if (error < 0)
goto cleanup;
- error = git_remote_ls(remote, &show_ref__cb, NULL);
+ /**
+ * Get the list of references on the remote and print out
+ * their name next to what they point to.
+ */
+ if (git_remote_ls(&refs, &refs_len, remote) < 0)
+ goto cleanup;
+
+ for (i = 0; i < refs_len; i++) {
+ char oid[GIT_OID_HEXSZ + 1] = {0};
+ git_oid_fmt(oid, &refs[i]->oid);
+ printf("%s\t%s\n", oid, refs[i]->name);
+ }
cleanup:
git_remote_free(remote);