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:
Colin Walters 2013-07-16 18:13:39 -04:00
parent 272274f0af
commit aac52cb9f7
23 changed files with 47 additions and 59 deletions

View File

@ -48,10 +48,9 @@ static OstreeAdminCommand admin_subcommands[] = {
}; };
gboolean 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; gboolean ret = FALSE;
__attribute__((unused)) GCancellable *cancellable = NULL;
const char *opt_sysroot = "/"; const char *opt_sysroot = "/";
const char *subcommand_name; const char *subcommand_name;
OstreeAdminCommand *subcommand; OstreeAdminCommand *subcommand;

View File

@ -53,12 +53,11 @@ cat_one_file (GFile *f,
} }
gboolean 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; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
int i; int i;
GCancellable *cancellable = NULL;
const char *rev; const char *rev;
gs_unref_object OstreeRepo *repo = NULL; gs_unref_object OstreeRepo *repo = NULL;
gs_unref_object GOutputStream *stdout_stream = NULL; gs_unref_object GOutputStream *stdout_stream = NULL;

View File

@ -215,10 +215,9 @@ process_many_checkouts (OstreeRepo *repo,
} }
gboolean 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; GOptionContext *context;
GCancellable *cancellable = NULL;
gboolean ret = FALSE; gboolean ret = FALSE;
const char *commit; const char *commit;
const char *destination; const char *destination;

View File

@ -53,7 +53,7 @@ on_checksum_received (GObject *obj,
} }
gboolean 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; GOptionContext *context;
gboolean ret = FALSE; 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.loop = g_main_loop_new (NULL, FALSE);
data.error = error; 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); g_main_loop_run (data.loop);

View File

@ -208,13 +208,12 @@ commit_filter (OstreeRepo *self,
} }
gboolean 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; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
gboolean skip_commit = FALSE; gboolean skip_commit = FALSE;
gboolean in_transaction = FALSE; gboolean in_transaction = FALSE;
GCancellable *cancellable = NULL;
gs_unref_object OstreeRepo *repo = NULL; gs_unref_object OstreeRepo *repo = NULL;
gs_unref_object GFile *arg = NULL; gs_unref_object GFile *arg = NULL;
gs_free char *parent = NULL; gs_free char *parent = NULL;

View File

@ -51,7 +51,7 @@ split_key_string (const char *k,
} }
gboolean 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; GOptionContext *context = NULL;
gboolean ret = FALSE; gboolean ret = FALSE;

View File

@ -58,11 +58,10 @@ parse_file_or_commit (OstreeRepo *repo,
} }
gboolean 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; gboolean ret = FALSE;
GOptionContext *context; GOptionContext *context;
GCancellable *cancellable = NULL;
const char *src; const char *src;
const char *target; const char *target;
gs_unref_object OstreeRepo *repo = NULL; gs_unref_object OstreeRepo *repo = NULL;

View File

@ -175,12 +175,11 @@ fsck_reachable_objects_from_commits (OtFsckData *data,
} }
gboolean 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; GOptionContext *context;
OtFsckData data; OtFsckData data;
gboolean ret = FALSE;
GCancellable *cancellable = NULL;
GHashTableIter hash_iter; GHashTableIter hash_iter;
gpointer key, value; gpointer key, value;
gs_unref_object OstreeRepo *repo = NULL; gs_unref_object OstreeRepo *repo = NULL;

View File

@ -39,11 +39,10 @@ static GOptionEntry options[] = {
gboolean 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; GOptionContext *context = NULL;
gboolean ret = FALSE; gboolean ret = FALSE;
__attribute__ ((unused)) GCancellable *cancellable = NULL;
const char *mode_str = "bare"; const char *mode_str = "bare";
gs_unref_object GFile *child = NULL; gs_unref_object GFile *child = NULL;
gs_unref_object GFile *grandchild = NULL; gs_unref_object GFile *grandchild = NULL;

View File

@ -30,7 +30,7 @@ static GOptionEntry options[] = {
}; };
gboolean 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; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;

View File

@ -188,7 +188,7 @@ print_directory_recurse (GFile *f,
} }
gboolean 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; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -216,7 +216,7 @@ ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error)
} }
rev = argv[1]; 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; goto out;
for (i = 2; i < argc; i++) 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); g_clear_object (&file_info);
file_info = g_file_query_info (f, OSTREE_GIO_FAST_QUERYINFO, file_info = g_file_query_info (f, OSTREE_GIO_FAST_QUERYINFO,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL, error); cancellable, error);
if (!file_info) if (!file_info)
goto out; goto out;

View File

@ -37,11 +37,10 @@ static GOptionEntry options[] = {
}; };
gboolean 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; gboolean ret = FALSE;
GOptionContext *context; GOptionContext *context;
GCancellable *cancellable = NULL;
gs_unref_object OstreeRepo *repo = NULL; gs_unref_object OstreeRepo *repo = NULL;
gs_free char *formatted_freed_size = NULL; gs_free char *formatted_freed_size = NULL;
OstreeRepoPruneFlags pruneflags = 0; OstreeRepoPruneFlags pruneflags = 0;

View File

@ -161,10 +161,9 @@ idle_print_status (gpointer user_data)
} }
gboolean 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; gboolean ret = FALSE;
GCancellable *cancellable = NULL;
GOptionContext *context; GOptionContext *context;
const char *src_repo_path; const char *src_repo_path;
int i; int i;

View File

@ -33,11 +33,10 @@ static GOptionEntry options[] = {
}; };
gboolean 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; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
GCancellable *cancellable = NULL;
const char *remote; const char *remote;
OstreeRepoPullFlags pullflags = 0; OstreeRepoPullFlags pullflags = 0;
gs_unref_object OstreeRepo *repo = NULL; gs_unref_object OstreeRepo *repo = NULL;

View File

@ -33,10 +33,9 @@ static GOptionEntry options[] = {
}; };
gboolean 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; gboolean ret = FALSE;
GCancellable *cancellable = NULL;
GOptionContext *context; GOptionContext *context;
const char *refspec_prefix = NULL; const char *refspec_prefix = NULL;
gs_unref_object OstreeRepo *repo = NULL; gs_unref_object OstreeRepo *repo = NULL;

View File

@ -40,7 +40,7 @@ usage_error (GOptionContext *context, const char *message, GError **error)
} }
gboolean 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; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;

View File

@ -30,7 +30,7 @@ static GOptionEntry options[] = {
}; };
gboolean 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; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;

View File

@ -194,7 +194,7 @@ do_print_metadata_key (OstreeRepo *repo,
} }
gboolean 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; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;

View File

@ -263,10 +263,9 @@ on_dir_changed (GFileMonitor *mon,
} }
gboolean 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; gboolean ret = FALSE;
GCancellable *cancellable = NULL;
GOptionContext *context; GOptionContext *context;
const char *dirpath; const char *dirpath;
OtTrivialHttpd appstruct; OtTrivialHttpd appstruct;

View File

@ -33,11 +33,10 @@ static GOptionEntry options[] = {
}; };
gboolean 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; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
GCancellable *cancellable = NULL;
GError *temp_error = NULL; GError *temp_error = NULL;
gsize len; gsize len;
gs_unref_object OstreeRepo *repo = NULL; gs_unref_object OstreeRepo *repo = NULL;

View File

@ -26,26 +26,26 @@
G_BEGIN_DECLS G_BEGIN_DECLS
gboolean ostree_builtin_admin (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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, GError **error); gboolean ostree_builtin_trivial_httpd (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error);
G_END_DECLS G_END_DECLS

View File

@ -82,6 +82,7 @@ ostree_run (int argc,
{ {
OstreeCommand *command; OstreeCommand *command;
GError *error = NULL; GError *error = NULL;
GCancellable *cancellable = NULL;
int cmd_argc; int cmd_argc;
char **cmd_argv = NULL; char **cmd_argv = NULL;
gboolean have_repo_arg; 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); 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; goto out;
out: out:

View File

@ -31,7 +31,7 @@ typedef enum {
typedef struct { typedef struct {
const char *name; 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 */ int flags; /* OstreeBuiltinFlags */
} OstreeCommand; } OstreeCommand;