mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-26 14:04:12 +03:00
Merge pull request #2651 from cgwalters/misc-declare-and-initialize-2
cli: Port to C99 style (3)
This commit is contained in:
commit
b04c436bb9
@ -201,62 +201,52 @@ out:
|
||||
gboolean
|
||||
ostree_builtin_gpg_sign (int argc, char **argv,OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("COMMIT KEY-ID...");
|
||||
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
g_autofree char *resolved_commit = NULL;
|
||||
const char *commit;
|
||||
char **key_ids;
|
||||
int n_key_ids, ii;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
context = g_option_context_new ("COMMIT KEY-ID...");
|
||||
|
||||
if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
usage_error (context, "Need a COMMIT to sign", error);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
usage_error (context, "Need at least one GPG KEY-ID to sign with", error);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
commit = argv[1];
|
||||
key_ids = argv + 2;
|
||||
n_key_ids = argc - 2;
|
||||
const char *commit = argv[1];
|
||||
char **key_ids = argv + 2;
|
||||
int n_key_ids = argc - 2;
|
||||
|
||||
g_autofree char *resolved_commit = NULL;
|
||||
if (!ostree_repo_resolve_rev (repo, commit, FALSE, &resolved_commit, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (opt_delete)
|
||||
{
|
||||
guint n_deleted = 0;
|
||||
|
||||
if (delete_signatures (repo, resolved_commit,
|
||||
(const char * const *) key_ids, n_key_ids,
|
||||
&n_deleted, cancellable, error))
|
||||
{
|
||||
g_print ("Signatures deleted: %u\n", n_deleted);
|
||||
ret = TRUE;
|
||||
}
|
||||
if (!delete_signatures (repo, resolved_commit,
|
||||
(const char * const *) key_ids, n_key_ids,
|
||||
&n_deleted, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
goto out;
|
||||
g_print ("Signatures deleted: %u\n", n_deleted);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < n_key_ids; ii++)
|
||||
for (int ii = 0; ii < n_key_ids; ii++)
|
||||
{
|
||||
if (!ostree_repo_sign_commit (repo, resolved_commit, key_ids[ii],
|
||||
opt_gpg_homedir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -37,45 +37,38 @@ static GOptionEntry option_entries[] = {
|
||||
gboolean
|
||||
ot_remote_builtin_list (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("");
|
||||
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
g_auto(GStrv) remotes = NULL;
|
||||
guint ii, n_remotes = 0;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
|
||||
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
|
||||
invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
remotes = ostree_repo_remote_list (repo, &n_remotes);
|
||||
guint n_remotes = 0;
|
||||
g_auto(GStrv) remotes = ostree_repo_remote_list (repo, &n_remotes);
|
||||
|
||||
if (opt_show_urls)
|
||||
{
|
||||
int max_length = 0;
|
||||
|
||||
for (ii = 0; ii < n_remotes; ii++)
|
||||
for (guint ii = 0; ii < n_remotes; ii++)
|
||||
max_length = MAX (max_length, strlen (remotes[ii]));
|
||||
|
||||
for (ii = 0; ii < n_remotes; ii++)
|
||||
for (guint ii = 0; ii < n_remotes; ii++)
|
||||
{
|
||||
g_autofree char *remote_url = NULL;
|
||||
|
||||
if (!ostree_repo_remote_get_url (repo, remotes[ii], &remote_url, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
g_print ("%-*s %s\n", max_length, remotes[ii], remote_url);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (ii = 0; ii < n_remotes; ii++)
|
||||
for (guint ii = 0; ii < n_remotes; ii++)
|
||||
g_print ("%s\n", remotes[ii]);
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -39,34 +39,30 @@ static GOptionEntry option_entries[] = {
|
||||
gboolean
|
||||
ot_remote_builtin_refs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("NAME");
|
||||
|
||||
g_autoptr(OstreeRepo) repo = NULL;
|
||||
const char *remote_name;
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GHashTable) refs = NULL;
|
||||
|
||||
context = g_option_context_new ("NAME");
|
||||
|
||||
if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
|
||||
invocation, &repo, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
ot_util_usage_error (context, "NAME must be specified", error);
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (opt_cache_dir)
|
||||
{
|
||||
if (!ostree_repo_set_cache_dir (repo, AT_FDCWD, opt_cache_dir, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
remote_name = argv[1];
|
||||
const char *remote_name = argv[1];
|
||||
g_autoptr(GHashTable) refs = NULL;
|
||||
|
||||
if (!ostree_repo_remote_list_refs (repo, remote_name, &refs, cancellable, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
else
|
||||
{
|
||||
g_autoptr(GList) ordered_keys = NULL;
|
||||
@ -81,7 +77,5 @@ ot_remote_builtin_refs (int argc, char **argv, OstreeCommandInvocation *invocati
|
||||
}
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user