From aac52cb9f767d58fd04f9198971eb1f2b8e81bbc Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 16 Jul 2013 18:13:39 -0400 Subject: [PATCH] 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. --- src/ostree/ot-builtin-admin.c | 3 +- src/ostree/ot-builtin-cat.c | 3 +- src/ostree/ot-builtin-checkout.c | 3 +- src/ostree/ot-builtin-checksum.c | 4 +-- src/ostree/ot-builtin-commit.c | 3 +- src/ostree/ot-builtin-config.c | 2 +- src/ostree/ot-builtin-diff.c | 3 +- src/ostree/ot-builtin-fsck.c | 5 ++-- src/ostree/ot-builtin-init.c | 3 +- src/ostree/ot-builtin-log.c | 2 +- src/ostree/ot-builtin-ls.c | 6 ++-- src/ostree/ot-builtin-prune.c | 3 +- src/ostree/ot-builtin-pull-local.c | 3 +- src/ostree/ot-builtin-pull.c | 3 +- src/ostree/ot-builtin-refs.c | 3 +- src/ostree/ot-builtin-remote.c | 2 +- src/ostree/ot-builtin-rev-parse.c | 2 +- src/ostree/ot-builtin-show.c | 2 +- src/ostree/ot-builtin-trivial-httpd.c | 3 +- src/ostree/ot-builtin-write-refs.c | 3 +- src/ostree/ot-builtins.h | 40 +++++++++++++-------------- src/ostree/ot-main.c | 3 +- src/ostree/ot-main.h | 2 +- 23 files changed, 47 insertions(+), 59 deletions(-) diff --git a/src/ostree/ot-builtin-admin.c b/src/ostree/ot-builtin-admin.c index b7b5ead4..46656806 100644 --- a/src/ostree/ot-builtin-admin.c +++ b/src/ostree/ot-builtin-admin.c @@ -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; diff --git a/src/ostree/ot-builtin-cat.c b/src/ostree/ot-builtin-cat.c index 4650ee46..357878ee 100644 --- a/src/ostree/ot-builtin-cat.c +++ b/src/ostree/ot-builtin-cat.c @@ -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; diff --git a/src/ostree/ot-builtin-checkout.c b/src/ostree/ot-builtin-checkout.c index e2ada071..5691c71b 100644 --- a/src/ostree/ot-builtin-checkout.c +++ b/src/ostree/ot-builtin-checkout.c @@ -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; diff --git a/src/ostree/ot-builtin-checksum.c b/src/ostree/ot-builtin-checksum.c index 89dc4abe..d18121b1 100644 --- a/src/ostree/ot-builtin-checksum.c +++ b/src/ostree/ot-builtin-checksum.c @@ -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); diff --git a/src/ostree/ot-builtin-commit.c b/src/ostree/ot-builtin-commit.c index 805dfcd7..58797ccc 100644 --- a/src/ostree/ot-builtin-commit.c +++ b/src/ostree/ot-builtin-commit.c @@ -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; diff --git a/src/ostree/ot-builtin-config.c b/src/ostree/ot-builtin-config.c index 28c26dd1..eb2766da 100644 --- a/src/ostree/ot-builtin-config.c +++ b/src/ostree/ot-builtin-config.c @@ -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; diff --git a/src/ostree/ot-builtin-diff.c b/src/ostree/ot-builtin-diff.c index 484f0369..143fe26a 100644 --- a/src/ostree/ot-builtin-diff.c +++ b/src/ostree/ot-builtin-diff.c @@ -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; diff --git a/src/ostree/ot-builtin-fsck.c b/src/ostree/ot-builtin-fsck.c index fe2b6dfb..77fe7955 100644 --- a/src/ostree/ot-builtin-fsck.c +++ b/src/ostree/ot-builtin-fsck.c @@ -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; diff --git a/src/ostree/ot-builtin-init.c b/src/ostree/ot-builtin-init.c index add3aab2..a992bfbd 100644 --- a/src/ostree/ot-builtin-init.c +++ b/src/ostree/ot-builtin-init.c @@ -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; diff --git a/src/ostree/ot-builtin-log.c b/src/ostree/ot-builtin-log.c index 638cec80..a5e9715b 100644 --- a/src/ostree/ot-builtin-log.c +++ b/src/ostree/ot-builtin-log.c @@ -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; diff --git a/src/ostree/ot-builtin-ls.c b/src/ostree/ot-builtin-ls.c index 333d9566..9120277b 100644 --- a/src/ostree/ot-builtin-ls.c +++ b/src/ostree/ot-builtin-ls.c @@ -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; diff --git a/src/ostree/ot-builtin-prune.c b/src/ostree/ot-builtin-prune.c index be22f4c1..98fe9d61 100644 --- a/src/ostree/ot-builtin-prune.c +++ b/src/ostree/ot-builtin-prune.c @@ -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; diff --git a/src/ostree/ot-builtin-pull-local.c b/src/ostree/ot-builtin-pull-local.c index da5374ed..d99e2b8b 100644 --- a/src/ostree/ot-builtin-pull-local.c +++ b/src/ostree/ot-builtin-pull-local.c @@ -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; diff --git a/src/ostree/ot-builtin-pull.c b/src/ostree/ot-builtin-pull.c index 5753cd87..a8606257 100644 --- a/src/ostree/ot-builtin-pull.c +++ b/src/ostree/ot-builtin-pull.c @@ -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; diff --git a/src/ostree/ot-builtin-refs.c b/src/ostree/ot-builtin-refs.c index 0c8c751f..eb3e8fcf 100644 --- a/src/ostree/ot-builtin-refs.c +++ b/src/ostree/ot-builtin-refs.c @@ -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; diff --git a/src/ostree/ot-builtin-remote.c b/src/ostree/ot-builtin-remote.c index 16ecbea1..5a9964a2 100644 --- a/src/ostree/ot-builtin-remote.c +++ b/src/ostree/ot-builtin-remote.c @@ -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; diff --git a/src/ostree/ot-builtin-rev-parse.c b/src/ostree/ot-builtin-rev-parse.c index c29172cd..7d6eebdf 100644 --- a/src/ostree/ot-builtin-rev-parse.c +++ b/src/ostree/ot-builtin-rev-parse.c @@ -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; diff --git a/src/ostree/ot-builtin-show.c b/src/ostree/ot-builtin-show.c index 543672ff..5cddc897 100644 --- a/src/ostree/ot-builtin-show.c +++ b/src/ostree/ot-builtin-show.c @@ -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; diff --git a/src/ostree/ot-builtin-trivial-httpd.c b/src/ostree/ot-builtin-trivial-httpd.c index ac11c72e..f3bd7cff 100644 --- a/src/ostree/ot-builtin-trivial-httpd.c +++ b/src/ostree/ot-builtin-trivial-httpd.c @@ -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; diff --git a/src/ostree/ot-builtin-write-refs.c b/src/ostree/ot-builtin-write-refs.c index 01185d8d..b7e463b4 100644 --- a/src/ostree/ot-builtin-write-refs.c +++ b/src/ostree/ot-builtin-write-refs.c @@ -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; diff --git a/src/ostree/ot-builtins.h b/src/ostree/ot-builtins.h index 6719f0f2..777a5e7c 100644 --- a/src/ostree/ot-builtins.h +++ b/src/ostree/ot-builtins.h @@ -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 diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c index 97bac2c2..1470860a 100644 --- a/src/ostree/ot-main.c +++ b/src/ostree/ot-main.c @@ -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: diff --git a/src/ostree/ot-main.h b/src/ostree/ot-main.h index c7981b50..b314f8ff 100644 --- a/src/ostree/ot-main.h +++ b/src/ostree/ot-main.h @@ -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;