app/override: Don't crash on no change

Doing `override reset --all` may be a no-op if there are no overrides
currently applied. But we were trying to always print the tree diff
under the assumption that all override invocations have to result in a
new deployment.

Fix this by using the same default deployment check that `upgrade` does
before printing.

Closes: #1407
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2018-06-13 12:00:56 -04:00 committed by Atomic Bot
parent 85a39dd923
commit 72e427cc3d
2 changed files with 8 additions and 1 deletions

View File

@ -83,6 +83,8 @@ handle_override (RPMOSTreeSysroot *sysroot_proxy,
g_variant_dict_insert (&dict, "no-overrides", "b", opt_reset_all);
g_autoptr(GVariant) options = g_variant_ref_sink (g_variant_dict_end (&dict));
g_autoptr(GVariant) previous_deployment = rpmostree_os_dup_default_deployment (os_proxy);
g_autofree char *transaction_address = NULL;
if (!rpmostree_update_deployment (os_proxy,
NULL, /* set-refspec */
@ -110,7 +112,10 @@ handle_override (RPMOSTreeSysroot *sysroot_proxy,
}
else if (!opt_reboot)
{
/* override ops currently always result in a new deployment */
/* only print diff if a new deployment was laid down (e.g. reset --all may not) */
if (!rpmostree_has_new_default_deployment (os_proxy, previous_deployment))
return TRUE;
const char *sysroot_path = rpmostree_sysroot_get_path (sysroot_proxy);
if (!rpmostree_print_treepkg_diff_from_sysroot_path (sysroot_path,
cancellable,

View File

@ -135,6 +135,8 @@ vm_rpmostree override reset --all
vm_assert_status_jq \
'.deployments[0]["base-removals"]|length == 0' \
'.deployments[0]["requested-base-removals"]|length == 0'
vm_rpmostree override reset --all |& tee out.txt
assert_file_has_content out.txt "No change."
echo "ok override reset --all"
# check that upgrading to a base without foo works