diff options
author | Colin Walters <walters@verbum.org> | 2017-10-20 10:19:00 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-10-23 14:19:41 +0000 |
commit | 0e0fe859223e7c6e94717f02e8ca04197934b199 (patch) | |
tree | c5adcb0c5ce1412e0876bca07a000568c38cacab | |
parent | 32357cef4d76eb611564ab26eb82c72c48e0bfee (diff) | |
download | ostree-0e0fe859223e7c6e94717f02e8ca04197934b199.tar.gz |
bin/status: Inline metadata parsing for versions
Pull out the commit metadata explicitly; still just rendering the version, but
this is prep for rendering other metadata keys.
Closes: #1296
Approved by: jlebon
-rw-r--r-- | src/ostree/ot-admin-builtin-status.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/ostree/ot-admin-builtin-status.c b/src/ostree/ot-admin-builtin-status.c index d3e524f3..8d180a6a 100644 --- a/src/ostree/ot-admin-builtin-status.c +++ b/src/ostree/ot-admin-builtin-status.c @@ -37,18 +37,6 @@ static GOptionEntry options[] = { { NULL } }; -static char * -version_of_commit (OstreeRepo *repo, const char *checksum) -{ - g_autoptr(GVariant) variant = NULL; - /* Shouldn't fail, but if it does, we ignore it */ - if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum, - &variant, NULL)) - return NULL; - - return ot_admin_checksum_version (variant); -} - static gboolean deployment_get_gpg_verify (OstreeDeployment *deployment, OstreeRepo *repo) @@ -114,7 +102,20 @@ ot_admin_builtin_status (int argc, char **argv, OstreeCommandInvocation *invocat { OstreeDeployment *deployment = deployments->pdata[i]; const char *ref = ostree_deployment_get_csum (deployment); - g_autofree char *version = version_of_commit (repo, ref); + + /* Load the backing commit; shouldn't normally fail, but if it does, + * we stumble on. + */ + g_autoptr(GVariant) commit = NULL; + (void)ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, ref, + &commit, NULL); + g_autoptr(GVariant) commit_metadata = NULL; + if (commit) + commit_metadata = g_variant_get_child_value (commit, 0); + + const char *version = NULL; + if (commit_metadata) + (void) g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_VERSION, "&s", &version); GKeyFile *origin = ostree_deployment_get_origin (deployment); |