[ostree] core: Should write remote refs in refs/<remote>/<branch>



commit ed2be6306d6565cdb8ec08848eb4af5545fad5d0
Author: Colin Walters <walters verbum org>
Date:   Thu Nov 17 10:40:01 2011 -0500

    core: Should write remote refs in refs/<remote>/<branch>
    
    Not just refs/<branch>, otherwise multiple remotes conflict.

 src/libostree/ostree-repo.c |   26 ++++++++++++++++++++++----
 src/libostree/ostree-repo.h |    2 +-
 2 files changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index a2d2170..516d3e0 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -1342,14 +1342,32 @@ add_one_path_to_tree_and_import (OstreeRepo     *self,
 
 gboolean      
 ostree_repo_write_ref (OstreeRepo  *self,
-                       gboolean     is_local,
+                       const char  *remote,
                        const char  *name,
                        const char  *rev,
                        GError     **error)
 {
+  gboolean ret = FALSE;
   OstreeRepoPrivate *priv = GET_PRIVATE (self);
-  return write_checksum_file (is_local ? priv->local_heads_dir : priv->remote_heads_dir, 
-                              name, rev, error);
+  GFile *dir = NULL;
+
+  if (remote == NULL)
+    dir = g_object_ref (priv->local_heads_dir);
+  else
+    {
+      dir = g_file_get_child (priv->remote_heads_dir, remote);
+
+      if (!ot_util_ensure_directory (ot_gfile_get_path_cached (dir), FALSE, error))
+        goto out;
+    }
+
+  if (!write_checksum_file (dir, name, rev, error))
+    goto out;
+
+  ret = TRUE;
+ out:
+  g_clear_object (&dir);
+  return ret;
 }
 
 static gboolean
@@ -1389,7 +1407,7 @@ commit_parsed_tree (OstreeRepo *self,
                                commit, &ret_commit, error))
     goto out;
 
-  if (!ostree_repo_write_ref (self, TRUE, branch, g_checksum_get_string (ret_commit), error))
+  if (!ostree_repo_write_ref (self, NULL, branch, g_checksum_get_string (ret_commit), error))
     goto out;
 
   ret = TRUE;
diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h
index 1c7eeb3..22bb0e6 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -91,7 +91,7 @@ gboolean      ostree_repo_resolve_rev (OstreeRepo  *self,
                                        GError     **error);
 
 gboolean      ostree_repo_write_ref (OstreeRepo  *self,
-                                     gboolean     is_local,
+                                     const char  *remote,
                                      const char  *name,
                                      const char  *rev,
                                      GError     **error);



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