[ostree] show: Handle keys of any type, and set an error if key doesn't exist



commit 38a5f6e5ed61cfb7a831c78920a8d11457c59dee
Author: Colin Walters <walters verbum org>
Date:   Fri Sep 27 12:55:07 2013 -0400

    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 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/ostree/ot-builtin-show.c b/src/ostree/ot-builtin-show.c
index 859c3d1..de54535 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:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]