[ostree] show: Print an error message if commit doesn't have detached metadata



commit edcfcd21a3e751f4676c8b19a8356fde36c8a3d1
Author: Colin Walters <walters verbum org>
Date:   Thu Sep 26 13:57:59 2013 -0400

    show: Print an error message if commit doesn't have detached metadata
    
    ...instead of segfaulting.

 src/ostree/ot-builtin-show.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/src/ostree/ot-builtin-show.c b/src/ostree/ot-builtin-show.c
index 09aaead..859c3d1 100644
--- a/src/ostree/ot-builtin-show.c
+++ b/src/ostree/ot-builtin-show.c
@@ -124,6 +124,12 @@ do_print_metadata_key (OstreeRepo     *repo,
       if (!ostree_repo_read_commit_detached_metadata (repo, resolved_rev, &metadata,
                                                       NULL, error))
         goto out;
+      if (metadata == NULL)
+        {
+          g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+                       "No detached metadata for commit %s", resolved_rev);
+          goto out;
+        }
     }
   
   if (!g_variant_lookup (metadata, key, "&s", &value))


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