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
This commit is contained in:
Stef Walter 2013-08-14 10:10:08 +02:00
parent 8c31e6fda7
commit 1904e3e0f4
2 changed files with 9 additions and 6 deletions

View File

@ -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))

View File

@ -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"