From 38a5f6e5ed61cfb7a831c78920a8d11457c59dee Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 27 Sep 2013 12:55:07 -0400 Subject: [PATCH] show: Handle keys of any type, and set an error if key doesn't exist Previously we were just handling strings, and silently doing nothing if the key didn't exist, which is pretty broken. --- src/ostree/ot-builtin-show.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ostree/ot-builtin-show.c b/src/ostree/ot-builtin-show.c index 859c3d14..de54535a 100644 --- a/src/ostree/ot-builtin-show.c +++ b/src/ostree/ot-builtin-show.c @@ -107,7 +107,7 @@ do_print_metadata_key (OstreeRepo *repo, GError **error) { gboolean ret = FALSE; - const char *value; + gs_unref_variant GVariant *value = NULL; gs_unref_variant GVariant *commit = NULL; gs_unref_variant GVariant *metadata = NULL; @@ -132,10 +132,15 @@ do_print_metadata_key (OstreeRepo *repo, } } - if (!g_variant_lookup (metadata, key, "&s", &value)) - goto out; + value = g_variant_lookup_value (metadata, key, NULL); + if (!value) + { + g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, + "No such metadata key '%s'", key); + goto out; + } - g_print ("%s\n", value); + ot_dump_variant (value); ret = TRUE; out: