[ostree] Don't pass non-checksums to ostree_repo_has_object()



commit 1904e3e0f4472d98258bbe27887bf87d269705d8
Author: Stef Walter <stefw redhat com>
Date:   Wed Aug 14 10:10:08 2013 +0200

    Don't pass non-checksums to ostree_repo_has_object()
    
    The 'ostree show' command passed non-checksum arguments
    to the ostree_repo_has_object() function which led to
    an assertion.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705967

 src/ostree/ot-builtin-show.c |   10 +++++-----
 tests/test-basic.sh          |    5 ++++-
 2 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/src/ostree/ot-builtin-show.c b/src/ostree/ot-builtin-show.c
index 82a8e01..206999a 100644
--- a/src/ostree/ot-builtin-show.c
+++ b/src/ostree/ot-builtin-show.c
@@ -143,7 +143,7 @@ do_print_metadata_key (OstreeRepo  *repo,
 static gboolean
 print_if_found (OstreeRepo        *repo,
                 OstreeObjectType   objtype,
-                const char        *rev,
+                const char        *checksum,
                 gboolean          *inout_was_found,
                 GCancellable      *cancellable,
                 GError           **error)
@@ -154,17 +154,17 @@ print_if_found (OstreeRepo        *repo,
   if (*inout_was_found)
     return TRUE;
 
-  if (!ostree_repo_has_object (repo, objtype, rev, &have_object,
+  if (!ostree_repo_has_object (repo, objtype, checksum, &have_object,
                                cancellable, error))
     goto out;
   if (have_object)
     {
       gs_unref_variant GVariant *variant = NULL;
-      if (!ostree_repo_load_variant (repo, objtype, rev,
+      if (!ostree_repo_load_variant (repo, objtype, checksum,
                                      &variant, error))
         goto out;
       *inout_was_found = TRUE;
-      g_print ("Object: %s\nType: %s\n", rev, ostree_object_type_to_string (objtype));
+      g_print ("Object: %s\nType: %s\n", checksum, ostree_object_type_to_string (objtype));
       print_variant (variant);
     }
   
@@ -223,7 +223,7 @@ ostree_builtin_show (int argc, char **argv, GFile *repo_path, GCancellable *canc
   else
     {
       gboolean found = FALSE;
-      if (!ostree_validate_rev (rev, NULL))
+      if (!ostree_validate_checksum_string (rev, NULL))
         {
           gs_unref_variant GVariant *variant = NULL;
           if (!ostree_repo_resolve_rev (repo, rev, FALSE, &resolved_rev, error))
diff --git a/tests/test-basic.sh b/tests/test-basic.sh
index c6401ad..baef00c 100755
--- a/tests/test-basic.sh
+++ b/tests/test-basic.sh
@@ -19,7 +19,7 @@
 
 set -e
 
-echo "1..35"
+echo "1..36"
 
 . $(dirname $0)/libtest.sh
 
@@ -245,3 +245,6 @@ cd ${test_tmpdir}
 $OSTREE ls test2
 echo "ok ls with no argument"
 
+cd ${test_tmpdir}
+$OSTREE show test2
+echo "ok show with non-checksum"


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