[ostree/wip/repo-file: 4/5] repo: Make read_commit spit out a resolved commit ref as well



commit 223bccf2f6ccb82be9314b44d2c271f40a54eb53
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sat Sep 7 14:21:24 2013 -0400

    repo: Make read_commit spit out a resolved commit ref as well
    
    read_commit resolves the ref to a commit, and a lot of consumers want
    the resolved commit for their own purposes; this prevents them from
    calling resolve_rev themselves.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=707727

 src/libostree/ostree-repo.c      |   15 +++++++++------
 src/libostree/ostree-repo.h      |   11 ++++++-----
 src/ostree/ot-admin-deploy.c     |    4 ++--
 src/ostree/ot-builtin-cat.c      |    2 +-
 src/ostree/ot-builtin-checkout.c |    2 +-
 src/ostree/ot-builtin-commit.c   |    4 ++--
 src/ostree/ot-builtin-diff.c     |    2 +-
 src/ostree/ot-builtin-ls.c       |    2 +-
 8 files changed, 23 insertions(+), 19 deletions(-)
---
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 81ffe8d..0459fff 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -1398,28 +1398,30 @@ ostree_repo_list_objects (OstreeRepo                  *self,
 /**
  * ostree_repo_read_commit:
  * @self: Repo
- * @rev: Revision (ref or ASCII checksum)
+ * @ref: Ref or ASCII checksum
  * @out_root: (out): An #OstreeRepoFile corresponding to the root
+ * @out_commit: (out): The resolved commit checksum
  * @cancellable: Cancellable
  * @error: Error
  *
  * Load the content for @rev into @out_root.
  */
 gboolean
-ostree_repo_read_commit (OstreeRepo *self,
-                         const char *rev,
+ostree_repo_read_commit (OstreeRepo   *self,
+                         const char   *ref,
                          GFile       **out_root,
+                         char        **out_commit,
                          GCancellable *cancellable,
                          GError **error)
 {
   gboolean ret = FALSE;
   gs_unref_object OstreeRepoFile *ret_root = NULL;
-  gs_free char *resolved_rev = NULL;
+  gs_free char *resolved_commit = NULL;
 
-  if (!ostree_repo_resolve_rev (self, rev, FALSE, &resolved_rev, error))
+  if (!ostree_repo_resolve_rev (self, ref, FALSE, &resolved_commit, error))
     goto out;
 
-  ret_root = _ostree_repo_file_new_for_commit (self, resolved_rev, error);
+  ret_root = _ostree_repo_file_new_for_commit (self, resolved_commit, error);
   if (!ret_root)
     goto out;
 
@@ -1428,6 +1430,7 @@ ostree_repo_read_commit (OstreeRepo *self,
 
   ret = TRUE;
   ot_transfer_out_value(out_root, (GFile **) &ret_root);
+  ot_transfer_out_value(out_commit, &resolved_commit);
  out:
   return ret;
 }
diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h
index fff9d6a..1511b84 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -370,11 +370,12 @@ gboolean       ostree_repo_checkout_gc (OstreeRepo        *self,
                                         GCancellable      *cancellable,
                                         GError           **error);
 
-gboolean       ostree_repo_read_commit (OstreeRepo *self,
-                                        const char *rev,
-                                        GFile       **out_root,
-                                        GCancellable *cancellable,
-                                        GError  **error);
+gboolean       ostree_repo_read_commit (OstreeRepo    *self,
+                                        const char    *ref,
+                                        GFile        **out_root,
+                                        char         **out_commit,
+                                        GCancellable  *cancellable,
+                                        GError        **error);
 
 /**
  * OstreeRepoListObjectsFlags:
diff --git a/src/ostree/ot-admin-deploy.c b/src/ostree/ot-admin-deploy.c
index 575522e..c2a171d 100644
--- a/src/ostree/ot-admin-deploy.c
+++ b/src/ostree/ot-admin-deploy.c
@@ -216,7 +216,7 @@ checkout_deployment_tree (GFile             *sysroot,
   gs_unref_object GFile *deploy_target_path = NULL;
   gs_unref_object GFile *deploy_parent = NULL;
 
-  if (!ostree_repo_read_commit (repo, csum, &root, cancellable, error))
+  if (!ostree_repo_read_commit (repo, csum, &root, NULL, cancellable, error))
     goto out;
 
   file_info = g_file_query_info (root, OSTREE_GIO_FAST_QUERYINFO,
@@ -1115,7 +1115,7 @@ ot_admin_deploy (GFile             *sysroot,
       goto out;
     }
 
-  if (!ostree_repo_read_commit (repo, revision, &commit_root, cancellable, error))
+  if (!ostree_repo_read_commit (repo, revision, &commit_root, NULL, cancellable, error))
     goto out;
 
   if (!get_kernel_from_tree (commit_root, &tree_kernel_path, &tree_initramfs_path,
diff --git a/src/ostree/ot-builtin-cat.c b/src/ostree/ot-builtin-cat.c
index b95ea27..b56e714 100644
--- a/src/ostree/ot-builtin-cat.c
+++ b/src/ostree/ot-builtin-cat.c
@@ -78,7 +78,7 @@ ostree_builtin_cat (int argc, char **argv, OstreeRepo *repo, GCancellable *cance
     }
   rev = argv[1];
 
-  if (!ostree_repo_read_commit (repo, rev, &root, NULL, error))
+  if (!ostree_repo_read_commit (repo, rev, &root, NULL, NULL, error))
     goto out;
 
   stdout_stream = g_unix_output_stream_new (1, FALSE);
diff --git a/src/ostree/ot-builtin-checkout.c b/src/ostree/ot-builtin-checkout.c
index b2284b4..ff055e7 100644
--- a/src/ostree/ot-builtin-checkout.c
+++ b/src/ostree/ot-builtin-checkout.c
@@ -60,7 +60,7 @@ process_one_checkout (OstreeRepo           *repo,
   gs_unref_object GFile *subtree = NULL;
   gs_unref_object GFileInfo *file_info = NULL;
 
-  if (!ostree_repo_read_commit (repo, resolved_commit, &root, cancellable, error))
+  if (!ostree_repo_read_commit (repo, resolved_commit, &root, NULL, cancellable, error))
     goto out;
 
   if (subpath)
diff --git a/src/ostree/ot-builtin-commit.c b/src/ostree/ot-builtin-commit.c
index a4ede8f..2cbe22f 100644
--- a/src/ostree/ot-builtin-commit.c
+++ b/src/ostree/ot-builtin-commit.c
@@ -393,7 +393,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeRepo *repo, GCancellable *ca
             }
           else if (strcmp (tree_type, "ref") == 0)
             {
-              if (!ostree_repo_read_commit (repo, tree, &arg, cancellable, error))
+              if (!ostree_repo_read_commit (repo, tree, &arg, NULL, cancellable, error))
                 goto out;
 
               if (!ostree_repo_write_directory_to_mtree (repo, arg, mtree, modifier,
@@ -440,7 +440,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeRepo *repo, GCancellable *ca
     {
       gs_unref_object GFile *parent_root;
 
-      if (!ostree_repo_read_commit (repo, parent, &parent_root, cancellable, error))
+      if (!ostree_repo_read_commit (repo, parent, &parent_root, NULL, cancellable, error))
         goto out;
 
       if (g_file_equal (root, parent_root))
diff --git a/src/ostree/ot-builtin-diff.c b/src/ostree/ot-builtin-diff.c
index 7bd772c..9680c3b 100644
--- a/src/ostree/ot-builtin-diff.c
+++ b/src/ostree/ot-builtin-diff.c
@@ -53,7 +53,7 @@ parse_file_or_commit (OstreeRepo  *repo,
     }
   else
     {
-      if (!ostree_repo_read_commit (repo, arg, &ret_file, cancellable, error))
+      if (!ostree_repo_read_commit (repo, arg, &ret_file, NULL, cancellable, error))
         goto out;
     }
 
diff --git a/src/ostree/ot-builtin-ls.c b/src/ostree/ot-builtin-ls.c
index c7f180f..b4d5ac9 100644
--- a/src/ostree/ot-builtin-ls.c
+++ b/src/ostree/ot-builtin-ls.c
@@ -260,7 +260,7 @@ ostree_builtin_ls (int argc, char **argv, OstreeRepo *repo, GCancellable *cancel
     }
   rev = argv[1];
 
-  if (!ostree_repo_read_commit (repo, rev, &root, cancellable, error))
+  if (!ostree_repo_read_commit (repo, rev, &root, NULL, cancellable, error))
     goto out;
 
   if (argc > 2)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]