diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2015-07-22 12:16:51 +0200 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2015-07-24 12:37:42 -0400 |
commit | 133fb5ffdcba36342b10050b8e443060dd437d60 (patch) | |
tree | a9a18d43a4e72f6ca60679de48d1b16dda6aaaff /src/ostree/ot-remote-builtin-refs.c | |
parent | a917c96976147595ff39c7524678331776ad3127 (diff) | |
download | ostree-133fb5ffdcba36342b10050b8e443060dd437d60.tar.gz |
libostree: new API ostree_repo_remote_list_refs
The new API permits to query a remote repository summary file and
retrieve the list of available refs.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'src/ostree/ot-remote-builtin-refs.c')
-rw-r--r-- | src/ostree/ot-remote-builtin-refs.c | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/src/ostree/ot-remote-builtin-refs.c b/src/ostree/ot-remote-builtin-refs.c index c3dbbf23..c1730bfa 100644 --- a/src/ostree/ot-remote-builtin-refs.c +++ b/src/ostree/ot-remote-builtin-refs.c @@ -34,8 +34,8 @@ ot_remote_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError GOptionContext *context; glnx_unref_object OstreeRepo *repo = NULL; const char *remote_name; - g_autoptr(GBytes) summary_bytes = NULL; gboolean ret = FALSE; + g_autoptr(GHashTable) refs = NULL; context = g_option_context_new ("NAME - List remote refs"); @@ -51,39 +51,19 @@ ot_remote_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError remote_name = argv[1]; - if (!ostree_repo_remote_fetch_summary (repo, remote_name, - &summary_bytes, NULL, - cancellable, error)) + if (!ostree_repo_remote_list_refs (repo, remote_name, &refs, cancellable, error)) goto out; - - if (summary_bytes == NULL) - { - g_print ("Remote refs not available; server has no summary file\n"); - } else { - g_autoptr(GVariant) summary = NULL; - g_autoptr(GVariant) ref_map = NULL; - GVariantIter iter; - GVariant *child; - - summary = g_variant_new_from_bytes (OSTREE_SUMMARY_GVARIANT_FORMAT, - summary_bytes, FALSE); + g_autoptr(GList) ordered_keys = NULL; + GList *iter = NULL; - ref_map = g_variant_get_child_value (summary, 0); + ordered_keys = g_hash_table_get_keys (refs); + ordered_keys = g_list_sort (ordered_keys, (GCompareFunc) strcmp); - /* Ref map should already be sorted by ref name. */ - g_variant_iter_init (&iter, ref_map); - while ((child = g_variant_iter_next_value (&iter)) != NULL) + for (iter = ordered_keys; iter; iter = iter->next) { - const char *ref_name = NULL; - - g_variant_get_child (child, 0, "&s", &ref_name); - - if (ref_name != NULL) - g_print ("%s\n", ref_name); - - g_variant_unref (child); + g_print ("%s\n", (const char *) iter->data); } } |