Merge pull request #2690 from cgwalters/cli-less-goto-1

cli/rev-parse: Port to new code style
This commit is contained in:
Luca Bruno 2022-08-17 07:21:55 +00:00 committed by GitHub
commit ea2f0c2943
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 18 deletions

View File

@ -38,34 +38,24 @@ static GOptionEntry options[] = {
gboolean gboolean
ostree_builtin_rev_parse (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error) ostree_builtin_rev_parse (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
{ {
g_autoptr(GOptionContext) context = NULL; g_autoptr(GOptionContext) context = g_option_context_new ("REV");
g_autoptr(OstreeRepo) repo = NULL; g_autoptr(OstreeRepo) repo = NULL;
gboolean ret = FALSE;
const char *rev = "master";
int i;
g_autofree char *resolved_rev = NULL;
context = g_option_context_new ("REV");
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error)) if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
goto out; return FALSE;
if (argc < 2) if (argc < 2)
{ {
ot_util_usage_error (context, "REV must be specified", error); ot_util_usage_error (context, "REV must be specified", error);
goto out; return FALSE;
} }
for (i = 1; i < argc; i++) for (gint i = 1; i < argc; i++)
{ {
rev = argv[i]; const char *rev = argv[i];
g_free (resolved_rev); g_autofree char *resolved_rev = NULL;
resolved_rev = NULL;
if (!ostree_repo_resolve_rev (repo, rev, FALSE, &resolved_rev, error)) if (!ostree_repo_resolve_rev (repo, rev, FALSE, &resolved_rev, error))
goto out; return FALSE;
g_print ("%s\n", resolved_rev); g_print ("%s\n", resolved_rev);
} }
ret = TRUE; return TRUE;
out:
return ret;
} }