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



commit d8e1b0ce9146ac1414a4779a0d0890d03e1e84cc
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

 src/libostree/ostree-repo.c    |   15 +++++++++------
 src/libostree/ostree-repo.h    |   11 ++++++-----
 src/ostree/ot-admin-deploy.c   |    2 +-
 src/ostree/ot-builtin-cat.c    |    2 +-
 src/ostree/ot-builtin-commit.c |    4 ++--
 src/ostree/ot-builtin-diff.c   |    2 +-
 src/ostree/ot-builtin-ls.c     |    2 +-
 7 files changed, 21 insertions(+), 17 deletions(-)
---
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index c87d24e..1e45971 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -1328,28 +1328,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 GFile *ret_root = NULL;
-  gs_free char *resolved_rev = NULL;
+  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;
 
@@ -1358,6 +1360,7 @@ ostree_repo_read_commit (OstreeRepo *self,
 
   ret = TRUE;
   ot_transfer_out_value(out_root, &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 9cca662..2a392f4 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -357,11 +357,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 9d4059e..09c0062 100644
--- a/src/ostree/ot-admin-deploy.c
+++ b/src/ostree/ot-admin-deploy.c
@@ -1119,7 +1119,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-commit.c b/src/ostree/ot-builtin-commit.c
index 27521a7..3078809 100644
--- a/src/ostree/ot-builtin-commit.c
+++ b/src/ostree/ot-builtin-commit.c
@@ -335,7 +335,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,
@@ -382,7 +382,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]