ostree admin: Fix return value from 'ostree admin [instutil]'

'ostree admin' and 'ostree admin instuil' with no arguments were meant to fail,
but the logic was wrong; add an assertion on the return value from all ostree
commands to catch similar problems in the future.

https://bugzilla.gnome.org/show_bug.cgi?id=737194
This commit is contained in:
Owen W. Taylor 2014-09-23 11:58:27 -04:00
parent 8f4ffa6950
commit 40f490ed11
3 changed files with 23 additions and 3 deletions

View File

@ -127,7 +127,13 @@ ot_admin_builtin_instutil (int argc, char **argv, OstreeSysroot *sysroot, GCance
g_print (" %s\n", subcommand->name);
subcommand++;
}
return subcommand_name == NULL ? 1 : 0;
if (want_help)
ret = TRUE;
else
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"No command specified");
goto out;
}
subcommand = admin_instutil_subcommands;

View File

@ -155,7 +155,13 @@ ostree_builtin_admin (int argc, char **argv, OstreeRepo *repo, GCancellable *can
g_print (" %s\n", subcommand->name);
subcommand++;
}
return subcommand_name == NULL ? 1 : 0;
if (want_help)
ret = TRUE;
else
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"No command specified");
goto out;
}
subcommand = admin_subcommands;

View File

@ -83,6 +83,7 @@ ostree_run (int argc,
const char *repo_arg = NULL;
gboolean want_help = FALSE;
gboolean skip;
gboolean success = FALSE;
int in, out, i;
/* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */
@ -191,7 +192,11 @@ ostree_run (int argc,
if (cmd == NULL)
{
if (!want_help)
if (want_help)
{
success = TRUE;
}
else
{
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
"No command specified");
@ -252,7 +257,10 @@ ostree_run (int argc,
if (!command->fn (argc, argv, repo, cancellable, &error))
goto out;
success = TRUE;
out:
g_assert (success || error);
if (error)
{
g_propagate_error (res_error, error);