[ostree] main: Treat default osname more consistently



commit affccb343a61262cc87af283241c62385c88a681
Author: Colin Walters <walters verbum org>
Date:   Sun Oct 27 16:41:40 2013 -0400

    main: Treat default osname more consistently
    
    The libostree already treats passing NULL for osname as "booted
    osname, if any".  We should do the same inside the tools.  The upgrade
    builtin had this logic duplicated there; we should be able to safely
    remove it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710970

 src/ostree/ot-admin-builtin-upgrade.c |    2 --
 src/ostree/ot-admin-functions.c       |    3 +++
 2 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/src/ostree/ot-admin-builtin-upgrade.c b/src/ostree/ot-admin-builtin-upgrade.c
index 3eeb18a..1249501 100644
--- a/src/ostree/ot-admin-builtin-upgrade.c
+++ b/src/ostree/ot-admin-builtin-upgrade.c
@@ -70,8 +70,6 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancel
   if (!ot_admin_require_booted_deployment_or_osname (sysroot, opt_osname,
                                                      cancellable, error))
     goto out;
-  if (!opt_osname)
-    opt_osname = (char*)ostree_deployment_get_osname (ostree_sysroot_get_booted_deployment (sysroot));
   merge_deployment = ostree_sysroot_get_merge_deployment (sysroot, opt_osname); 
   if (merge_deployment == NULL)
     {
diff --git a/src/ostree/ot-admin-functions.c b/src/ostree/ot-admin-functions.c
index 7c8a050..6d81655 100644
--- a/src/ostree/ot-admin-functions.c
+++ b/src/ostree/ot-admin-functions.c
@@ -67,6 +67,9 @@ ot_admin_complete_deploy_one (OstreeSysroot      *sysroot,
   deployments = ostree_sysroot_get_deployments (sysroot);
   booted_deployment = ostree_sysroot_get_booted_deployment (sysroot);
 
+  if (osname == NULL && booted_deployment)
+    osname = ostree_deployment_get_osname (booted_deployment);
+
   g_ptr_array_add (new_deployments, g_object_ref (new_deployment));
 
   for (i = 0; i < deployments->len; i++)


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