[ostree] main: Move GCancellable to toplevel



commit aac52cb9f767d58fd04f9198971eb1f2b8e81bbc
Author: Colin Walters <walters verbum org>
Date:   Tue Jul 16 18:13:39 2013 -0400

    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 b7b5ead..4665680 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 4650ee4..357878e 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 e2ada07..5691c71 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 89dc4ab..d18121b 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 805dfcd..58797cc 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 28c26dd..eb2766d 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 484f036..143fe26 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 fe2b6df..77fe795 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 add3aab..a992bfb 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 638cec8..a5e9715 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 333d956..9120277 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 be22f4c..98fe9d6 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 da5374e..d99e2b8 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 5753cd8..a860625 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 0c8c751..eb3e8fc 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 16ecbea..5a9964a 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 c29172c..7d6eebd 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 543672f..5cddc89 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 ac11c72..f3bd7cf 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 01185d8..b7e463b 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 6719f0f..777a5e7 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 97bac2c..1470860 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 c7981b5..b314f8f 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;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]