From edfa76fad5d2fc92d753c3317333200d552b99e9 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 25 Aug 2013 15:11:05 -0400 Subject: main: Code cleanup by passing OstreeRepo * directly to builtins It turns out every builtin (with one special exception) that takes a repo argument did the same thing; let's just centralize it. The special exception was "ostree init --repo=foo" where foo is expected to *not* actually be a repo. In that case, simply skip the ostree_repo_check() invocation. https://bugzilla.gnome.org/show_bug.cgi?id=706762 --- src/ostree/ot-builtin-init.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ostree/ot-builtin-init.c') diff --git a/src/ostree/ot-builtin-init.c b/src/ostree/ot-builtin-init.c index 01421aef..acfa9287 100644 --- a/src/ostree/ot-builtin-init.c +++ b/src/ostree/ot-builtin-init.c @@ -38,14 +38,14 @@ static GOptionEntry options[] = { gboolean -ostree_builtin_init (int argc, char **argv, GFile *repo_path, GCancellable *cancellable, GError **error) +ostree_builtin_init (int argc, char **argv, OstreeRepo *repo, GCancellable *cancellable, GError **error) { GOptionContext *context = NULL; gboolean ret = FALSE; const char *mode_str = "bare"; + GFile *repo_path = NULL; gs_unref_object GFile *child = NULL; gs_unref_object GFile *grandchild = NULL; - gs_unref_object OstreeRepo *repo = NULL; GString *config_data = NULL; context = g_option_context_new ("- Initialize a new empty repository"); @@ -54,6 +54,8 @@ ostree_builtin_init (int argc, char **argv, GFile *repo_path, GCancellable *canc if (!g_option_context_parse (context, &argc, &argv, error)) goto out; + repo_path = ostree_repo_get_path (repo); + child = g_file_get_child (repo_path, "config"); config_data = g_string_new (DEFAULT_CONFIG_CONTENTS); @@ -112,7 +114,6 @@ ostree_builtin_init (int argc, char **argv, GFile *repo_path, GCancellable *canc if (!g_file_make_directory (child, NULL, error)) goto out; - repo = ostree_repo_new (repo_path); if (!ostree_repo_check (repo, error)) goto out; -- cgit v1.2.1