[ostree] pull-local: Support pulling checksums too



commit 13f36aa224dfdf81d7c4e5ff826c6249c81dff72
Author: Colin Walters <walters verbum org>
Date:   Mon Jan 28 15:32:06 2013 -0500

    pull-local: Support pulling checksums too
    
    This matches what pull allows.

 src/ostree/ot-builtin-pull-local.c |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/src/ostree/ot-builtin-pull-local.c b/src/ostree/ot-builtin-pull-local.c
index c45ae4e..77e0e1e 100644
--- a/src/ostree/ot-builtin-pull-local.c
+++ b/src/ostree/ot-builtin-pull-local.c
@@ -162,6 +162,7 @@ ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **err
   ot_lobj GFile *src_dir = NULL;
   ot_lobj GFile *dest_dir = NULL;
   ot_lhash GHashTable *refs_to_clone = NULL;
+  ot_lhash GHashTable *commits_to_clone = NULL;
   ot_lhash GHashTable *source_objects = NULL;
   ot_lhash GHashTable *objects_to_copy = NULL;
   OtLocalCloneData datav;
@@ -211,16 +212,24 @@ ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **err
   else
     {
       refs_to_clone = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+      commits_to_clone = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
       for (i = 2; i < argc; i++)
         {
           const char *ref = argv[i];
           char *rev;
           
-          if (!ostree_repo_resolve_rev (data->src_repo, ref, FALSE, &rev, error))
-            goto out;
+          if (ostree_validate_checksum_string (ref, NULL))
+            {
+              g_hash_table_insert (commits_to_clone, (char*)ref, (char*) ref);
+            }
+          else
+            {
+              if (!ostree_repo_resolve_rev (data->src_repo, ref, FALSE, &rev, error))
+                goto out;
           
-          /* Transfer ownership of rev */
-          g_hash_table_insert (refs_to_clone, g_strdup (ref), rev);
+              /* Transfer ownership of rev */
+              g_hash_table_insert (refs_to_clone, g_strdup (ref), rev);
+            }
         }
     }
 
@@ -237,6 +246,15 @@ ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **err
         goto out;
     }
 
+  g_hash_table_iter_init (&hash_iter, commits_to_clone);
+  while (g_hash_table_iter_next (&hash_iter, &key, &value))
+    {
+      const char *checksum = key;
+
+      if (!ostree_traverse_commit (data->src_repo, checksum, 0, source_objects, cancellable, error))
+        goto out;
+    }
+
   if (!ostree_repo_prepare_transaction (data->dest_repo, FALSE, cancellable, error))
     goto out;
 



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