[ostree] Add ostree_commit_get_parent() to get parent from variant



commit 5efb8e86e9d76e46aceb3a2043fe66a53a7821d8
Author: Stef Walter <stefw redhat com>
Date:   Wed Aug 14 11:46:50 2013 +0200

    Add ostree_commit_get_parent() to get parent from variant
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705973

 src/libostree/ostree-core.c          |   10 ++++++++++
 src/libostree/ostree-core.h          |    1 +
 src/libostree/ostree-repo-traverse.c |    9 +++------
 3 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index 9231141..f746b33 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -1643,3 +1643,13 @@ ostree_validate_structureof_dirmeta (GVariant      *dirmeta,
  out:
   return ret;
 }
+
+gchar *
+ostree_commit_get_parent (GVariant  *commit_variant)
+{
+  gs_unref_variant GVariant *bytes = NULL;
+  bytes = g_variant_get_child_value (commit_variant, 1);
+  if (g_variant_n_children (bytes) == 0)
+    return NULL;
+  return ostree_checksum_from_bytes_v (bytes);
+}
diff --git a/src/libostree/ostree-core.h b/src/libostree/ostree-core.h
index a28b0ca..b2d24e6 100644
--- a/src/libostree/ostree-core.h
+++ b/src/libostree/ostree-core.h
@@ -319,5 +319,6 @@ gboolean ostree_validate_structureof_dirtree (GVariant      *index,
 gboolean ostree_validate_structureof_dirmeta (GVariant      *index,
                                               GError       **error);
 
+gchar *  ostree_commit_get_parent            (GVariant  *commit_variant);
 
 G_END_DECLS
diff --git a/src/libostree/ostree-repo-traverse.c b/src/libostree/ostree-repo-traverse.c
index 996033e..d15fc6c 100644
--- a/src/libostree/ostree-repo-traverse.c
+++ b/src/libostree/ostree-repo-traverse.c
@@ -211,12 +211,10 @@ ostree_repo_traverse_commit (OstreeRepo      *repo,
 
       if (maxdepth == -1 || maxdepth > 0)
         {
-          g_variant_get_child (commit, 1, "@ay", &parent_csum_bytes);
-          
-          if (g_variant_n_children (parent_csum_bytes) > 0)
+          g_free (tmp_checksum);
+          tmp_checksum = ostree_commit_get_parent (commit);
+          if (tmp_checksum)
             {
-              g_free (tmp_checksum);
-              tmp_checksum = ostree_checksum_from_bytes_v (parent_csum_bytes);
               commit_checksum = tmp_checksum;
               if (maxdepth > 0)
                 maxdepth -= 1;
@@ -231,4 +229,3 @@ ostree_repo_traverse_commit (OstreeRepo      *repo,
  out:
   return ret;
 }
-


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