[ostree] core: Improve checkout API
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] core: Improve checkout API
- Date: Tue, 6 Mar 2012 17:01:47 +0000 (UTC)
commit 1f7d776a18abdfd2eff8e80dc407ef2845c6195e
Author: Colin Walters <walters verbum org>
Date: Tue Mar 6 08:48:48 2012 -0500
core: Improve checkout API
Expose the lower-level functionality in libostree, change checkout
builtin to be a higher level driver. This will allow us to more
easily improve the "checkout" builtin..
src/libostree/ostree-repo.c | 56 +++++++-------------------------------
src/libostree/ostree-repo.h | 14 +++++----
src/ostree/ot-builtin-checkout.c | 26 +++++++++++++++--
3 files changed, 41 insertions(+), 55 deletions(-)
---
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index dc0baef..0ff30b1 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -2486,14 +2486,14 @@ checkout_file_from_input (GFile *file,
return ret;
}
-static gboolean
-checkout_tree (OstreeRepo *self,
- OstreeRepoCheckoutMode mode,
- GFile *destination,
- OstreeRepoFile *source,
- GFileInfo *source_info,
- GCancellable *cancellable,
- GError **error)
+gboolean
+ostree_repo_checkout_tree (OstreeRepo *self,
+ OstreeRepoCheckoutMode mode,
+ GFile *destination,
+ OstreeRepoFile *source,
+ GFileInfo *source_info,
+ GCancellable *cancellable,
+ GError **error)
{
OstreeRepoPrivate *priv = GET_PRIVATE (self);
gboolean ret = FALSE;
@@ -2541,7 +2541,8 @@ checkout_tree (OstreeRepo *self,
if (type == G_FILE_TYPE_DIRECTORY)
{
- if (!checkout_tree (self, mode, dest_path, (OstreeRepoFile*)src_child, file_info, cancellable, error))
+ if (!ostree_repo_checkout_tree (self, mode, dest_path, (OstreeRepoFile*)src_child, file_info,
+ cancellable, error))
goto out;
}
else
@@ -2620,43 +2621,6 @@ checkout_tree (OstreeRepo *self,
return ret;
}
-gboolean
-ostree_repo_checkout (OstreeRepo *self,
- OstreeRepoCheckoutMode mode,
- const char *ref,
- GFile *destination,
- GCancellable *cancellable,
- GError **error)
-{
- gboolean ret = FALSE;
- char *resolved = NULL;
- OstreeRepoFile *root = NULL;
- GFileInfo *root_info = NULL;
-
- if (!ostree_repo_resolve_rev (self, ref, FALSE, &resolved, error))
- goto out;
-
- root = (OstreeRepoFile*)ostree_repo_file_new_root (self, resolved);
- if (!ostree_repo_file_ensure_resolved (root, error))
- goto out;
-
- root_info = g_file_query_info ((GFile*)root, OSTREE_GIO_FAST_QUERYINFO,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- NULL, error);
- if (!root_info)
- goto out;
-
- if (!checkout_tree (self, mode, destination, root, root_info, cancellable, error))
- goto out;
-
- ret = TRUE;
- out:
- g_free (resolved);
- g_clear_object (&root);
- g_clear_object (&root_info);
- return ret;
-}
-
static gboolean
get_file_checksum (GFile *f,
GFileInfo *f_info,
diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h
index 002b02e..9166db7 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -205,12 +205,14 @@ typedef enum {
OSTREE_REPO_CHECKOUT_MODE_USER
} OstreeRepoCheckoutMode;
-gboolean ostree_repo_checkout (OstreeRepo *self,
- OstreeRepoCheckoutMode mode,
- const char *ref,
- GFile *destination,
- GCancellable *cancellable,
- GError **error);
+gboolean
+ostree_repo_checkout_tree (OstreeRepo *self,
+ OstreeRepoCheckoutMode mode,
+ GFile *destination,
+ OstreeRepoFile *source,
+ GFileInfo *source_info,
+ GCancellable *cancellable,
+ GError **error);
gboolean ostree_repo_read_commit (OstreeRepo *self,
const char *rev,
diff --git a/src/ostree/ot-builtin-checkout.c b/src/ostree/ot-builtin-checkout.c
index 0526023..e7cc20a 100644
--- a/src/ostree/ot-builtin-checkout.c
+++ b/src/ostree/ot-builtin-checkout.c
@@ -38,10 +38,14 @@ gboolean
ostree_builtin_checkout (int argc, char **argv, GFile *repo_path, GError **error)
{
GOptionContext *context;
+ GCancellable *cancellable = NULL;
gboolean ret = FALSE;
OstreeRepo *repo = NULL;
const char *commit;
+ char *resolved_commit = NULL;
const char *destination;
+ OstreeRepoFile *root = NULL;
+ GFileInfo *root_info = NULL;
GFile *destf = NULL;
context = g_option_context_new ("COMMIT DESTINATION - Check out a commit into a filesystem tree");
@@ -68,16 +72,32 @@ ostree_builtin_checkout (int argc, char **argv, GFile *repo_path, GError **error
destination = argv[2];
destf = ot_gfile_new_for_path (destination);
-
- if (!ostree_repo_checkout (repo, user_mode ? OSTREE_REPO_CHECKOUT_MODE_USER : 0,
- commit, destf, NULL, error))
+
+ if (!ostree_repo_resolve_rev (repo, commit, FALSE, &resolved_commit, error))
+ goto out;
+
+ root = (OstreeRepoFile*)ostree_repo_file_new_root (repo, resolved_commit);
+ if (!ostree_repo_file_ensure_resolved (root, error))
+ goto out;
+
+ root_info = g_file_query_info ((GFile*)root, OSTREE_GIO_FAST_QUERYINFO,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ cancellable, error);
+ if (!root_info)
+ goto out;
+
+ if (!ostree_repo_checkout_tree (repo, user_mode ? OSTREE_REPO_CHECKOUT_MODE_USER : 0,
+ destf, root, root_info, cancellable, error))
goto out;
ret = TRUE;
out:
+ g_free (resolved_commit);
if (context)
g_option_context_free (context);
g_clear_object (&repo);
g_clear_object (&destf);
+ g_clear_object (&root);
+ g_clear_object (&root_info);
return ret;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]