summaryrefslogtreecommitdiff
path: root/examples/network/ls-remote.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/network/ls-remote.c')
-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);