[ostree] repo: Redo ostree_repo_remote_get_url()



commit 3515e01f6a4967e7ad67409dd429747d05f032ab
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Jun 6 16:47:15 2015 -0400

    repo: Redo ostree_repo_remote_get_url()
    
    Make it work like in ostree_repo_pull_with_options(), handling "file://"
    remotes and inheriting the "url" option from parent repos if needed.

 src/libostree/ostree-repo-pull.c |   26 +++++---------------------
 src/libostree/ostree-repo.c      |   28 ++++++++++++++++++----------
 2 files changed, 23 insertions(+), 31 deletions(-)
---
diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c
index e259e34..11e32a3 100644
--- a/src/libostree/ostree-repo-pull.c
+++ b/src/libostree/ostree-repo-pull.c
@@ -1604,7 +1604,6 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
   gpointer key, value;
   g_autofree char *remote_key = NULL;
   g_autofree char *path = NULL;
-  g_autofree char *baseurl = NULL;
   g_autofree char *metalink_url_str = NULL;
   g_autoptr(GHashTable) requested_refs_to_fetch = NULL;
   g_autoptr(GHashTable) commits_to_fetch = NULL;
@@ -1670,14 +1669,8 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
 
   pull_data->start_time = g_get_monotonic_time ();
 
-  if (_ostree_repo_remote_name_is_file (remote_name_or_baseurl))
-    {
-      baseurl = g_strdup (remote_name_or_baseurl);
-    }
-  else
-    {
-      pull_data->remote_name = g_strdup (remote_name_or_baseurl);
-    }
+  if (!_ostree_repo_remote_name_is_file (remote_name_or_baseurl))
+    pull_data->remote_name = g_strdup (remote_name_or_baseurl);
 
   if (!ostree_repo_remote_get_gpg_verify (self, remote_name_or_baseurl,
                                           &pull_data->gpg_verify, error))
@@ -1700,19 +1693,10 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
 
   if (!metalink_url_str)
     {
-      if (baseurl == NULL)
-        {
-          if (!_ostree_repo_get_remote_option_inherit (self, remote_name_or_baseurl, "url", &baseurl, error))
-            goto out;
-        }
+      g_autofree char *baseurl = NULL;
 
-      if (baseurl == NULL)
-        {
-          g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
-                       "No \"url\" option in remote \"%s\"",
-                       remote_name_or_baseurl);
-          goto out;
-        }
+      if (!ostree_repo_remote_get_url (self, remote_name_or_baseurl, &baseurl, error))
+        goto out;
 
       pull_data->base_uri = soup_uri_new (baseurl);
 
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index aaeffd5..f7c2a4e 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -1206,24 +1206,32 @@ ostree_repo_remote_get_url (OstreeRepo  *self,
                             char       **out_url,
                             GError     **error)
 {
-  local_cleanup_remote OstreeRemote *remote = NULL;
   g_autofree char *url = NULL;
   gboolean ret = FALSE;
 
   g_return_val_if_fail (name != NULL, FALSE);
 
-  remote = ost_repo_get_remote (self, name, error);
+  if (_ostree_repo_remote_name_is_file (name))
+    {
+      url = g_strdup (name);
+    }
+  else
+    {
+      if (!_ostree_repo_get_remote_option_inherit (self, name, "url", &url, error))
+        goto out;
 
-  if (remote == NULL)
-    goto out;
+      if (url == NULL)
+        {
+          g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+                       "No \"url\" option in remote \"%s\"", name);
+          goto out;
+        }
+    }
 
-  url = g_key_file_get_string (remote->options, remote->group, "url", error);
+  if (out_url != NULL)
+    *out_url = g_steal_pointer (&url);
 
-  if (url != NULL)
-    {
-      gs_transfer_out_value (out_url, &url);
-      ret = TRUE;
-    }
+  ret = TRUE;
 
  out:
   return ret;


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