mirror of
https://github.com/ostreedev/ostree.git
synced 2025-02-21 05:57:45 +03:00
core: Use GFile for repo constructor API, and a bit more internally
Also, ensure that the repo directory GFile is absolute - this avoids a getcwd() syscall every time we construct a GFile object.
This commit is contained in:
parent
8a499c4a2a
commit
d25f1bf73d
@ -253,11 +253,11 @@ on_name_acquired (GDBusConnection *connection,
|
|||||||
{
|
{
|
||||||
OstreeDaemon *self = user_data;
|
OstreeDaemon *self = user_data;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
char *repo_path;
|
GFile *repo_file = NULL;
|
||||||
|
|
||||||
repo_path = g_build_filename (ot_gfile_get_path_cached (self->prefix), "repo", NULL);
|
repo_file = g_file_get_child (self->prefix, "repo");
|
||||||
self->repo = ostree_repo_new (repo_path);
|
self->repo = ostree_repo_new (repo_file);
|
||||||
g_free (repo_path);
|
g_clear_object (&repo_file);
|
||||||
if (!ostree_repo_check (self->repo, &error))
|
if (!ostree_repo_check (self->repo, &error))
|
||||||
{
|
{
|
||||||
g_printerr ("%s\n", error->message);
|
g_printerr ("%s\n", error->message);
|
||||||
|
@ -51,13 +51,12 @@ G_DEFINE_TYPE (OstreeRepo, ostree_repo, G_TYPE_OBJECT)
|
|||||||
typedef struct _OstreeRepoPrivate OstreeRepoPrivate;
|
typedef struct _OstreeRepoPrivate OstreeRepoPrivate;
|
||||||
|
|
||||||
struct _OstreeRepoPrivate {
|
struct _OstreeRepoPrivate {
|
||||||
char *path;
|
GFile *repodir;
|
||||||
GFile *repo_file;
|
|
||||||
GFile *tmp_dir;
|
GFile *tmp_dir;
|
||||||
GFile *local_heads_dir;
|
GFile *local_heads_dir;
|
||||||
GFile *remote_heads_dir;
|
GFile *remote_heads_dir;
|
||||||
char *objects_path;
|
GFile *objects_dir;
|
||||||
char *config_path;
|
GFile *config_file;
|
||||||
|
|
||||||
gboolean inited;
|
gboolean inited;
|
||||||
gboolean in_transaction;
|
gboolean in_transaction;
|
||||||
@ -74,13 +73,12 @@ ostree_repo_finalize (GObject *object)
|
|||||||
OstreeRepo *self = OSTREE_REPO (object);
|
OstreeRepo *self = OSTREE_REPO (object);
|
||||||
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
||||||
|
|
||||||
g_free (priv->path);
|
g_clear_object (&priv->repodir);
|
||||||
g_clear_object (&priv->repo_file);
|
|
||||||
g_clear_object (&priv->tmp_dir);
|
g_clear_object (&priv->tmp_dir);
|
||||||
g_clear_object (&priv->local_heads_dir);
|
g_clear_object (&priv->local_heads_dir);
|
||||||
g_clear_object (&priv->remote_heads_dir);
|
g_clear_object (&priv->remote_heads_dir);
|
||||||
g_free (priv->objects_path);
|
g_clear_object (&priv->objects_dir);
|
||||||
g_free (priv->config_path);
|
g_clear_object (&priv->config_file);
|
||||||
g_hash_table_destroy (priv->pending_transaction_tmpfiles);
|
g_hash_table_destroy (priv->pending_transaction_tmpfiles);
|
||||||
if (priv->config)
|
if (priv->config)
|
||||||
g_key_file_free (priv->config);
|
g_key_file_free (priv->config);
|
||||||
@ -100,7 +98,8 @@ ostree_repo_set_property(GObject *object,
|
|||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_PATH:
|
case PROP_PATH:
|
||||||
priv->path = g_value_dup_string (value);
|
/* Canonicalize */
|
||||||
|
priv->repodir = ot_gfile_new_for_path (g_file_get_path (g_value_get_object (value)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
@ -120,7 +119,7 @@ ostree_repo_get_property(GObject *object,
|
|||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_PATH:
|
case PROP_PATH:
|
||||||
g_value_set_string (value, priv->path);
|
g_value_set_object (value, priv->repodir);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
@ -142,15 +141,14 @@ ostree_repo_constructor (GType gtype,
|
|||||||
|
|
||||||
priv = GET_PRIVATE (object);
|
priv = GET_PRIVATE (object);
|
||||||
|
|
||||||
g_assert (priv->path != NULL);
|
g_assert (priv->repodir != NULL);
|
||||||
|
|
||||||
priv->repo_file = ot_gfile_new_for_path (priv->path);
|
priv->tmp_dir = g_file_resolve_relative_path (priv->repodir, "tmp");
|
||||||
priv->tmp_dir = g_file_resolve_relative_path (priv->repo_file, "tmp");
|
priv->local_heads_dir = g_file_resolve_relative_path (priv->repodir, "refs/heads");
|
||||||
priv->local_heads_dir = g_file_resolve_relative_path (priv->repo_file, "refs/heads");
|
priv->remote_heads_dir = g_file_resolve_relative_path (priv->repodir, "refs/remotes");
|
||||||
priv->remote_heads_dir = g_file_resolve_relative_path (priv->repo_file, "refs/remotes");
|
|
||||||
|
|
||||||
priv->objects_path = g_build_filename (priv->path, "objects", NULL);
|
priv->objects_dir = g_file_get_child (priv->repodir, "objects");
|
||||||
priv->config_path = g_build_filename (priv->path, "config", NULL);
|
priv->config_file = g_file_get_child (priv->repodir, "config");
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
@ -169,10 +167,10 @@ ostree_repo_class_init (OstreeRepoClass *klass)
|
|||||||
|
|
||||||
g_object_class_install_property (object_class,
|
g_object_class_install_property (object_class,
|
||||||
PROP_PATH,
|
PROP_PATH,
|
||||||
g_param_spec_string ("path",
|
g_param_spec_object ("path",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
NULL,
|
G_TYPE_FILE,
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +185,7 @@ ostree_repo_init (OstreeRepo *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
OstreeRepo*
|
OstreeRepo*
|
||||||
ostree_repo_new (const char *path)
|
ostree_repo_new (GFile *path)
|
||||||
{
|
{
|
||||||
return g_object_new (OSTREE_TYPE_REPO, "path", path, NULL);
|
return g_object_new (OSTREE_TYPE_REPO, "path", path, NULL);
|
||||||
}
|
}
|
||||||
@ -474,7 +472,8 @@ ostree_repo_write_config (OstreeRepo *self,
|
|||||||
g_return_val_if_fail (priv->inited, FALSE);
|
g_return_val_if_fail (priv->inited, FALSE);
|
||||||
|
|
||||||
data = g_key_file_to_data (new_config, &len, error);
|
data = g_key_file_to_data (new_config, &len, error);
|
||||||
if (!g_file_set_contents (priv->config_path, data, len, error))
|
if (!g_file_replace_contents (priv->config_file, data, len, NULL, FALSE, 0, NULL,
|
||||||
|
NULL, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
g_key_file_free (priv->config);
|
g_key_file_free (priv->config);
|
||||||
@ -569,15 +568,16 @@ ostree_repo_check (OstreeRepo *self, GError **error)
|
|||||||
if (priv->inited)
|
if (priv->inited)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (!g_file_test (priv->objects_path, G_FILE_TEST_IS_DIR))
|
if (!g_file_test (ot_gfile_get_path_cached (priv->objects_dir), G_FILE_TEST_IS_DIR))
|
||||||
{
|
{
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
"Couldn't find objects directory '%s'", priv->objects_path);
|
"Couldn't find objects directory '%s'",
|
||||||
|
ot_gfile_get_path_cached (priv->objects_dir));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->config = g_key_file_new ();
|
priv->config = g_key_file_new ();
|
||||||
if (!g_key_file_load_from_file (priv->config, priv->config_path, 0, error))
|
if (!g_key_file_load_from_file (priv->config, ot_gfile_get_path_cached (priv->config_file), 0, error))
|
||||||
{
|
{
|
||||||
g_prefix_error (error, "Couldn't parse config file: ");
|
g_prefix_error (error, "Couldn't parse config file: ");
|
||||||
goto out;
|
goto out;
|
||||||
@ -627,11 +627,11 @@ ostree_repo_check (OstreeRepo *self, GError **error)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
GFile *
|
||||||
ostree_repo_get_path (OstreeRepo *self)
|
ostree_repo_get_path (OstreeRepo *self)
|
||||||
{
|
{
|
||||||
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
||||||
return priv->path;
|
return priv->repodir;
|
||||||
}
|
}
|
||||||
|
|
||||||
GFile *
|
GFile *
|
||||||
@ -1132,15 +1132,12 @@ ostree_repo_get_object_path (OstreeRepo *self,
|
|||||||
OstreeObjectType type)
|
OstreeObjectType type)
|
||||||
{
|
{
|
||||||
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
||||||
char *path;
|
|
||||||
char *relpath;
|
char *relpath;
|
||||||
GFile *ret;
|
GFile *ret;
|
||||||
|
|
||||||
relpath = ostree_get_relative_object_path (checksum, type);
|
relpath = ostree_get_relative_object_path (checksum, type);
|
||||||
path = g_build_filename (priv->path, relpath, NULL);
|
ret = g_file_resolve_relative_path (priv->repodir, relpath);
|
||||||
g_free (relpath);
|
g_free (relpath);
|
||||||
ret = ot_gfile_new_for_path (path);
|
|
||||||
g_free (path);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1974,7 +1971,6 @@ ostree_repo_iter_objects (OstreeRepo *self,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
||||||
GFile *objectdir = NULL;
|
|
||||||
GFileEnumerator *enumerator = NULL;
|
GFileEnumerator *enumerator = NULL;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
GFileInfo *file_info = NULL;
|
GFileInfo *file_info = NULL;
|
||||||
@ -1983,8 +1979,7 @@ ostree_repo_iter_objects (OstreeRepo *self,
|
|||||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
g_return_val_if_fail (priv->inited, FALSE);
|
g_return_val_if_fail (priv->inited, FALSE);
|
||||||
|
|
||||||
objectdir = ot_gfile_new_for_path (priv->objects_path);
|
enumerator = g_file_enumerate_children (priv->objects_dir, OSTREE_GIO_FAST_QUERYINFO,
|
||||||
enumerator = g_file_enumerate_children (objectdir, OSTREE_GIO_FAST_QUERYINFO,
|
|
||||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||||
NULL,
|
NULL,
|
||||||
error);
|
error);
|
||||||
@ -2001,7 +1996,7 @@ ostree_repo_iter_objects (OstreeRepo *self,
|
|||||||
|
|
||||||
if (strlen (name) == 2 && type == G_FILE_TYPE_DIRECTORY)
|
if (strlen (name) == 2 && type == G_FILE_TYPE_DIRECTORY)
|
||||||
{
|
{
|
||||||
GFile *objdir = g_file_get_child (objectdir, name);
|
GFile *objdir = g_file_get_child (priv->objects_dir, name);
|
||||||
if (!iter_object_dir (self, objdir, callback, user_data, error))
|
if (!iter_object_dir (self, objdir, callback, user_data, error))
|
||||||
{
|
{
|
||||||
g_object_unref (objdir);
|
g_object_unref (objdir);
|
||||||
@ -2023,7 +2018,6 @@ ostree_repo_iter_objects (OstreeRepo *self,
|
|||||||
out:
|
out:
|
||||||
g_clear_object (&file_info);
|
g_clear_object (&file_info);
|
||||||
g_clear_object (&enumerator);
|
g_clear_object (&enumerator);
|
||||||
g_clear_object (&objectdir);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,11 +50,11 @@ typedef struct {
|
|||||||
|
|
||||||
GType ostree_repo_get_type (void);
|
GType ostree_repo_get_type (void);
|
||||||
|
|
||||||
OstreeRepo* ostree_repo_new (const char *path);
|
OstreeRepo* ostree_repo_new (GFile *path);
|
||||||
|
|
||||||
gboolean ostree_repo_check (OstreeRepo *self, GError **error);
|
gboolean ostree_repo_check (OstreeRepo *self, GError **error);
|
||||||
|
|
||||||
const char * ostree_repo_get_path (OstreeRepo *self);
|
GFile * ostree_repo_get_path (OstreeRepo *self);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OSTREE_REPO_MODE_BARE,
|
OSTREE_REPO_MODE_BARE,
|
||||||
|
@ -351,7 +351,7 @@ store_commit_recurse (OstreeRepo *repo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
ostree_builtin_pull (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
@ -35,7 +35,7 @@ static GOptionEntry options[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_checkout (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_checkout (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
@ -55,7 +55,7 @@ on_checksum_received (GObject *obj,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_checksum (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_checksum (int argc, char **argv, GFile *repo_path_path, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
@ -53,7 +53,7 @@ static GOptionEntry options[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_commit (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
@ -70,7 +70,7 @@ add_branch (OstreeRepo *repo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_compose (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
@ -62,7 +62,7 @@ parse_file_or_commit (OstreeRepo *repo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_diff (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
@ -176,7 +176,7 @@ object_iter_callback (OstreeRepo *repo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_fsck (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_fsck (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
OtFsckData data;
|
OtFsckData data;
|
||||||
|
@ -39,11 +39,10 @@ static GOptionEntry options[] = {
|
|||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_init (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_init (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context = NULL;
|
GOptionContext *context = NULL;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
GFile *repodir = NULL;
|
|
||||||
GFile *child = NULL;
|
GFile *child = NULL;
|
||||||
GFile *grandchild = NULL;
|
GFile *grandchild = NULL;
|
||||||
GString *config_data = NULL;
|
GString *config_data = NULL;
|
||||||
@ -54,9 +53,7 @@ ostree_builtin_init (int argc, char **argv, const char *repo_path, GError **erro
|
|||||||
if (!g_option_context_parse (context, &argc, &argv, error))
|
if (!g_option_context_parse (context, &argc, &argv, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
repodir = ot_gfile_new_for_path (repo_path);
|
child = g_file_get_child (repo_path, "config");
|
||||||
|
|
||||||
child = g_file_get_child (repodir, "config");
|
|
||||||
|
|
||||||
config_data = g_string_new (DEFAULT_CONFIG_CONTENTS);
|
config_data = g_string_new (DEFAULT_CONFIG_CONTENTS);
|
||||||
g_string_append_printf (config_data, "mode=%s\n", archive ? "archive" : "bare");
|
g_string_append_printf (config_data, "mode=%s\n", archive ? "archive" : "bare");
|
||||||
@ -68,17 +65,17 @@ ostree_builtin_init (int argc, char **argv, const char *repo_path, GError **erro
|
|||||||
goto out;
|
goto out;
|
||||||
g_clear_object (&child);
|
g_clear_object (&child);
|
||||||
|
|
||||||
child = g_file_get_child (repodir, "objects");
|
child = g_file_get_child (repo_path, "objects");
|
||||||
if (!g_file_make_directory (child, NULL, error))
|
if (!g_file_make_directory (child, NULL, error))
|
||||||
goto out;
|
goto out;
|
||||||
g_clear_object (&child);
|
g_clear_object (&child);
|
||||||
|
|
||||||
child = g_file_get_child (repodir, "tmp");
|
child = g_file_get_child (repo_path, "tmp");
|
||||||
if (!g_file_make_directory (child, NULL, error))
|
if (!g_file_make_directory (child, NULL, error))
|
||||||
goto out;
|
goto out;
|
||||||
g_clear_object (&child);
|
g_clear_object (&child);
|
||||||
|
|
||||||
child = g_file_get_child (repodir, "refs");
|
child = g_file_get_child (repo_path, "refs");
|
||||||
if (!g_file_make_directory (child, NULL, error))
|
if (!g_file_make_directory (child, NULL, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -94,7 +91,7 @@ ostree_builtin_init (int argc, char **argv, const char *repo_path, GError **erro
|
|||||||
|
|
||||||
g_clear_object (&child);
|
g_clear_object (&child);
|
||||||
|
|
||||||
child = g_file_get_child (repodir, "tags");
|
child = g_file_get_child (repo_path, "tags");
|
||||||
if (!g_file_make_directory (child, NULL, error))
|
if (!g_file_make_directory (child, NULL, error))
|
||||||
goto out;
|
goto out;
|
||||||
g_clear_object (&child);
|
g_clear_object (&child);
|
||||||
@ -105,7 +102,6 @@ ostree_builtin_init (int argc, char **argv, const char *repo_path, GError **erro
|
|||||||
g_option_context_free (context);
|
g_option_context_free (context);
|
||||||
if (config_data)
|
if (config_data)
|
||||||
g_string_free (config_data, TRUE);
|
g_string_free (config_data, TRUE);
|
||||||
g_clear_object (&repodir);
|
|
||||||
g_clear_object (&child);
|
g_clear_object (&child);
|
||||||
g_clear_object (&grandchild);
|
g_clear_object (&grandchild);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -160,11 +160,12 @@ object_iter_callback (OstreeRepo *repo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_local_clone (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_local_clone (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
const char *destination;
|
const char *destination;
|
||||||
|
GFile *dest_f = NULL;
|
||||||
OtLocalCloneData data;
|
OtLocalCloneData data;
|
||||||
GFile *src_repo_dir = NULL;
|
GFile *src_repo_dir = NULL;
|
||||||
GFile *dest_repo_dir = NULL;
|
GFile *dest_repo_dir = NULL;
|
||||||
@ -196,13 +197,14 @@ ostree_builtin_local_clone (int argc, char **argv, const char *repo_path, GError
|
|||||||
}
|
}
|
||||||
|
|
||||||
destination = argv[1];
|
destination = argv[1];
|
||||||
|
dest_f = ot_gfile_new_for_path (destination);
|
||||||
|
|
||||||
data.dest_repo = ostree_repo_new (destination);
|
data.dest_repo = ostree_repo_new (dest_f);
|
||||||
if (!ostree_repo_check (data.dest_repo, error))
|
if (!ostree_repo_check (data.dest_repo, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
src_repo_dir = ot_gfile_new_for_path (ostree_repo_get_path (data.src_repo));
|
src_repo_dir = g_object_ref (ostree_repo_get_path (data.src_repo));
|
||||||
dest_repo_dir = ot_gfile_new_for_path (ostree_repo_get_path (data.dest_repo));
|
dest_repo_dir = g_object_ref (ostree_repo_get_path (data.dest_repo));
|
||||||
|
|
||||||
src_info = g_file_query_info (src_repo_dir, OSTREE_GIO_FAST_QUERYINFO,
|
src_info = g_file_query_info (src_repo_dir, OSTREE_GIO_FAST_QUERYINFO,
|
||||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||||
@ -242,6 +244,7 @@ ostree_builtin_local_clone (int argc, char **argv, const char *repo_path, GError
|
|||||||
out:
|
out:
|
||||||
if (context)
|
if (context)
|
||||||
g_option_context_free (context);
|
g_option_context_free (context);
|
||||||
|
g_clear_object (&dest_f);
|
||||||
g_clear_object (&src_repo_dir);
|
g_clear_object (&src_repo_dir);
|
||||||
g_clear_object (&dest_repo_dir);
|
g_clear_object (&dest_repo_dir);
|
||||||
g_clear_object (&src_info);
|
g_clear_object (&src_info);
|
||||||
|
@ -32,7 +32,7 @@ static GOptionEntry options[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_log (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_log (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
@ -165,7 +165,7 @@ print_directory_recurse (GFile *f,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_ls (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
@ -42,7 +42,7 @@ usage_error (GOptionContext *context, const char *message, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_remote (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_remote (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
@ -32,7 +32,7 @@ static GOptionEntry options[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_rev_parse (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_rev_parse (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
@ -35,7 +35,7 @@ static GOptionEntry options[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_run_triggers (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_run_triggers (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
@ -192,7 +192,7 @@ do_print_compose (OstreeRepo *repo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_show (int argc, char **argv, const char *repo_path, GError **error)
|
ostree_builtin_show (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
@ -23,24 +23,24 @@
|
|||||||
#ifndef __OSTREE_BUILTINS__
|
#ifndef __OSTREE_BUILTINS__
|
||||||
#define __OSTREE_BUILTINS__
|
#define __OSTREE_BUILTINS__
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
gboolean ostree_builtin_checkout (int argc, char **argv, const char *repo, GError **error);
|
gboolean ostree_builtin_checkout (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
gboolean ostree_builtin_checksum (int argc, char **argv, const char *repo, GError **error);
|
gboolean ostree_builtin_checksum (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
gboolean ostree_builtin_commit (int argc, char **argv, const char *repo, GError **error);
|
gboolean ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
gboolean ostree_builtin_compose (int argc, char **argv, const char *repo, GError **error);
|
gboolean ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
gboolean ostree_builtin_diff (int argc, char **argv, const char *repo, GError **error);
|
gboolean ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
gboolean ostree_builtin_init (int argc, char **argv, const char *repo, GError **error);
|
gboolean ostree_builtin_init (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
gboolean ostree_builtin_local_clone (int argc, char **argv, const char *repo, GError **error);
|
gboolean ostree_builtin_local_clone (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
gboolean ostree_builtin_log (int argc, char **argv, const char *repo, GError **error);
|
gboolean ostree_builtin_log (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
gboolean ostree_builtin_ls (int argc, char **argv, const char *repo, GError **error);
|
gboolean ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
gboolean ostree_builtin_run_triggers (int argc, char **argv, const char *repo, GError **error);
|
gboolean ostree_builtin_run_triggers (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
gboolean ostree_builtin_fsck (int argc, char **argv, const char *repo, GError **error);
|
gboolean ostree_builtin_fsck (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
gboolean ostree_builtin_show (int argc, char **argv, const char *repo, GError **error);
|
gboolean ostree_builtin_show (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
gboolean ostree_builtin_rev_parse (int argc, char **argv, const char *repo, GError **error);
|
gboolean ostree_builtin_rev_parse (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
gboolean ostree_builtin_remote (int argc, char **argv, const char *repo, GError **error);
|
gboolean ostree_builtin_remote (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "ot-main.h"
|
#include "ot-main.h"
|
||||||
|
#include "otutil.h"
|
||||||
|
|
||||||
static int
|
static int
|
||||||
usage (char **argv, OstreeBuiltin *builtins, gboolean is_error)
|
usage (char **argv, OstreeBuiltin *builtins, gboolean is_error)
|
||||||
@ -91,6 +92,7 @@ ostree_main (int argc,
|
|||||||
gboolean have_repo_arg;
|
gboolean have_repo_arg;
|
||||||
const char *cmd = NULL;
|
const char *cmd = NULL;
|
||||||
const char *repo = NULL;
|
const char *repo = NULL;
|
||||||
|
GFile *repo_file = NULL;
|
||||||
int arg_off;
|
int arg_off;
|
||||||
|
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
@ -110,6 +112,9 @@ ostree_main (int argc,
|
|||||||
else
|
else
|
||||||
repo = NULL;
|
repo = NULL;
|
||||||
|
|
||||||
|
if (repo)
|
||||||
|
repo_file = ot_gfile_new_for_path (repo);
|
||||||
|
|
||||||
cmd = strchr (argv[0], '-');
|
cmd = strchr (argv[0], '-');
|
||||||
if (cmd)
|
if (cmd)
|
||||||
{
|
{
|
||||||
@ -151,11 +156,12 @@ ostree_main (int argc,
|
|||||||
|
|
||||||
prep_builtin_argv (cmd, argc-arg_off, argv+arg_off, &cmd_argc, &cmd_argv);
|
prep_builtin_argv (cmd, argc-arg_off, argv+arg_off, &cmd_argc, &cmd_argv);
|
||||||
|
|
||||||
if (!builtin->fn (cmd_argc, cmd_argv, repo, &error))
|
if (!builtin->fn (cmd_argc, cmd_argv, repo_file, &error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
g_free (cmd_argv);
|
g_free (cmd_argv);
|
||||||
|
g_clear_object (&repo_file);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
g_printerr ("%s\n", error->message);
|
g_printerr ("%s\n", error->message);
|
||||||
|
@ -29,7 +29,7 @@ typedef enum {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
gboolean (*fn) (int argc, char **argv, const char *repo, GError **error);
|
gboolean (*fn) (int argc, char **argv, GFile *repo_path, GError **error);
|
||||||
int flags; /* OstreeBuiltinFlags */
|
int flags; /* OstreeBuiltinFlags */
|
||||||
} OstreeBuiltin;
|
} OstreeBuiltin;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user