summaryrefslogtreecommitdiff
path: root/src/ostree/ot-builtin-init.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-08-25 15:11:05 -0400
committerColin Walters <walters@verbum.org>2013-08-25 15:28:23 -0400
commitedfa76fad5d2fc92d753c3317333200d552b99e9 (patch)
tree6b76d3928db6c3dbcfde5292b58b5b06f4163ebd /src/ostree/ot-builtin-init.c
parent6c61b1910714c5bde7f35594ab7fcd980d03c8f1 (diff)
downloadostree-edfa76fad5d2fc92d753c3317333200d552b99e9.tar.gz
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
Diffstat (limited to 'src/ostree/ot-builtin-init.c')
-rw-r--r--src/ostree/ot-builtin-init.c7
1 files changed, 4 insertions, 3 deletions
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;