main: Move GCancellable to toplevel
This is just cleaner, and makes the builtins slightly more of a library, which in turn makes it easier to turn them into real API.
This commit is contained in:
parent
272274f0af
commit
aac52cb9f7
|
|
@ -48,10 +48,9 @@ static OstreeAdminCommand admin_subcommands[] = {
|
|||
};
|
||||
|
||||
gboolean
|
||||
ostree_builtin_admin (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_admin (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
__attribute__((unused)) GCancellable *cancellable = NULL;
|
||||
const char *opt_sysroot = "/";
|
||||
const char *subcommand_name;
|
||||
OstreeAdminCommand *subcommand;
|
||||
|
|
|
|||
|
|
@ -53,12 +53,11 @@ cat_one_file (GFile *f,
|
|||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_cat (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_cat (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
int i;
|
||||
GCancellable *cancellable = NULL;
|
||||
const char *rev;
|
||||
gs_unref_object OstreeRepo *repo = NULL;
|
||||
gs_unref_object GOutputStream *stdout_stream = NULL;
|
||||
|
|
|
|||
|
|
@ -215,10 +215,9 @@ process_many_checkouts (OstreeRepo *repo,
|
|||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_checkout (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_checkout (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
GCancellable *cancellable = NULL;
|
||||
gboolean ret = FALSE;
|
||||
const char *commit;
|
||||
const char *destination;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ on_checksum_received (GObject *obj,
|
|||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_checksum (int argc, char **argv, GFile *repo_path_path, GError **error)
|
||||
ostree_builtin_checksum (int argc, char **argv, GFile *repo_path_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
|
|
@ -77,7 +77,7 @@ ostree_builtin_checksum (int argc, char **argv, GFile *repo_path_path, GError **
|
|||
|
||||
data.loop = g_main_loop_new (NULL, FALSE);
|
||||
data.error = error;
|
||||
ostree_checksum_file_async (f, OSTREE_OBJECT_TYPE_FILE, G_PRIORITY_DEFAULT, NULL, on_checksum_received, &data);
|
||||
ostree_checksum_file_async (f, OSTREE_OBJECT_TYPE_FILE, G_PRIORITY_DEFAULT, cancellable, on_checksum_received, &data);
|
||||
|
||||
g_main_loop_run (data.loop);
|
||||
|
||||
|
|
|
|||
|
|
@ -208,13 +208,12 @@ commit_filter (OstreeRepo *self,
|
|||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
gboolean skip_commit = FALSE;
|
||||
gboolean in_transaction = FALSE;
|
||||
GCancellable *cancellable = NULL;
|
||||
gs_unref_object OstreeRepo *repo = NULL;
|
||||
gs_unref_object GFile *arg = NULL;
|
||||
gs_free char *parent = NULL;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ split_key_string (const char *k,
|
|||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_config (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_config (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context = NULL;
|
||||
gboolean ret = FALSE;
|
||||
|
|
|
|||
|
|
@ -58,11 +58,10 @@ parse_file_or_commit (OstreeRepo *repo,
|
|||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
GCancellable *cancellable = NULL;
|
||||
const char *src;
|
||||
const char *target;
|
||||
gs_unref_object OstreeRepo *repo = NULL;
|
||||
|
|
|
|||
|
|
@ -175,12 +175,11 @@ fsck_reachable_objects_from_commits (OtFsckData *data,
|
|||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_fsck (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_fsck (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
OtFsckData data;
|
||||
gboolean ret = FALSE;
|
||||
GCancellable *cancellable = NULL;
|
||||
GHashTableIter hash_iter;
|
||||
gpointer key, value;
|
||||
gs_unref_object OstreeRepo *repo = NULL;
|
||||
|
|
|
|||
|
|
@ -39,11 +39,10 @@ static GOptionEntry options[] = {
|
|||
|
||||
|
||||
gboolean
|
||||
ostree_builtin_init (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_init (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context = NULL;
|
||||
gboolean ret = FALSE;
|
||||
__attribute__ ((unused)) GCancellable *cancellable = NULL;
|
||||
const char *mode_str = "bare";
|
||||
gs_unref_object GFile *child = NULL;
|
||||
gs_unref_object GFile *grandchild = NULL;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ static GOptionEntry options[] = {
|
|||
};
|
||||
|
||||
gboolean
|
||||
ostree_builtin_log (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_log (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ print_directory_recurse (GFile *f,
|
|||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
|
|
@ -216,7 +216,7 @@ ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error)
|
|||
}
|
||||
rev = argv[1];
|
||||
|
||||
if (!ostree_repo_read_commit (repo, rev, &root, NULL, error))
|
||||
if (!ostree_repo_read_commit (repo, rev, &root, cancellable, error))
|
||||
goto out;
|
||||
|
||||
for (i = 2; i < argc; i++)
|
||||
|
|
@ -227,7 +227,7 @@ ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error)
|
|||
g_clear_object (&file_info);
|
||||
file_info = g_file_query_info (f, OSTREE_GIO_FAST_QUERYINFO,
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
NULL, error);
|
||||
cancellable, error);
|
||||
if (!file_info)
|
||||
goto out;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,11 +37,10 @@ static GOptionEntry options[] = {
|
|||
};
|
||||
|
||||
gboolean
|
||||
ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GOptionContext *context;
|
||||
GCancellable *cancellable = NULL;
|
||||
gs_unref_object OstreeRepo *repo = NULL;
|
||||
gs_free char *formatted_freed_size = NULL;
|
||||
OstreeRepoPruneFlags pruneflags = 0;
|
||||
|
|
|
|||
|
|
@ -161,10 +161,9 @@ idle_print_status (gpointer user_data)
|
|||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GCancellable *cancellable = NULL;
|
||||
GOptionContext *context;
|
||||
const char *src_repo_path;
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -33,11 +33,10 @@ static GOptionEntry options[] = {
|
|||
};
|
||||
|
||||
gboolean
|
||||
ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
GCancellable *cancellable = NULL;
|
||||
const char *remote;
|
||||
OstreeRepoPullFlags pullflags = 0;
|
||||
gs_unref_object OstreeRepo *repo = NULL;
|
||||
|
|
|
|||
|
|
@ -33,10 +33,9 @@ static GOptionEntry options[] = {
|
|||
};
|
||||
|
||||
gboolean
|
||||
ostree_builtin_refs (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_refs (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GCancellable *cancellable = NULL;
|
||||
GOptionContext *context;
|
||||
const char *refspec_prefix = NULL;
|
||||
gs_unref_object OstreeRepo *repo = NULL;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ usage_error (GOptionContext *context, const char *message, GError **error)
|
|||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_remote (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_remote (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ static GOptionEntry options[] = {
|
|||
};
|
||||
|
||||
gboolean
|
||||
ostree_builtin_rev_parse (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_rev_parse (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ do_print_metadata_key (OstreeRepo *repo,
|
|||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_show (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_show (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
|
|
|
|||
|
|
@ -263,10 +263,9 @@ on_dir_changed (GFileMonitor *mon,
|
|||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_trivial_httpd (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_trivial_httpd (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GCancellable *cancellable = NULL;
|
||||
GOptionContext *context;
|
||||
const char *dirpath;
|
||||
OtTrivialHttpd appstruct;
|
||||
|
|
|
|||
|
|
@ -33,11 +33,10 @@ static GOptionEntry options[] = {
|
|||
};
|
||||
|
||||
gboolean
|
||||
ostree_builtin_write_refs (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
ostree_builtin_write_refs (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
GCancellable *cancellable = NULL;
|
||||
GError *temp_error = NULL;
|
||||
gsize len;
|
||||
gs_unref_object OstreeRepo *repo = NULL;
|
||||
|
|
|
|||
|
|
@ -26,26 +26,26 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean ostree_builtin_admin (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_cat (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_config (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_checkout (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_checksum (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_init (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_log (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_refs (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_fsck (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_show (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_rev_parse (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_remote (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_write_refs (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_trivial_httpd (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean ostree_builtin_admin (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_cat (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_config (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_checkout (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_checksum (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_init (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_log (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_refs (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_fsck (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_show (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_rev_parse (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_remote (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_write_refs (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
gboolean ostree_builtin_trivial_httpd (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ ostree_run (int argc,
|
|||
{
|
||||
OstreeCommand *command;
|
||||
GError *error = NULL;
|
||||
GCancellable *cancellable = NULL;
|
||||
int cmd_argc;
|
||||
char **cmd_argv = NULL;
|
||||
gboolean have_repo_arg;
|
||||
|
|
@ -155,7 +156,7 @@ ostree_run (int argc,
|
|||
|
||||
ostree_prep_builtin_argv (cmd, argc-arg_off, argv+arg_off, &cmd_argc, &cmd_argv);
|
||||
|
||||
if (!command->fn (cmd_argc, cmd_argv, repo_file, &error))
|
||||
if (!command->fn (cmd_argc, cmd_argv, repo_file, cancellable, &error))
|
||||
goto out;
|
||||
|
||||
out:
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ typedef enum {
|
|||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
gboolean (*fn) (int argc, char **argv, GFile *repo_path, GError **error);
|
||||
gboolean (*fn) (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
|
||||
int flags; /* OstreeBuiltinFlags */
|
||||
} OstreeCommand;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue