From 08d2b8ab7bb4cadd0ad41fcfa9c7cc7762316861 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Tue, 19 Apr 2016 11:32:14 +0200 Subject: [PATCH] lib: Add URL override pull option The "override-url" option allows to use the other URL while still using some options from the passed remote. Closes: #271 Approved by: cgwalters --- src/libostree/ostree-repo-pull.c | 6 +++++- src/libostree/ostree-repo.c | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c index 968b5951..708df5b6 100644 --- a/src/libostree/ostree-repo-pull.c +++ b/src/libostree/ostree-repo-pull.c @@ -1909,6 +1909,7 @@ ostree_repo_pull_with_options (OstreeRepo *self, gboolean require_static_deltas = FALSE; gboolean opt_gpg_verify = FALSE; gboolean opt_gpg_verify_summary = FALSE; + const char *url_override = NULL; if (options) { @@ -1926,6 +1927,7 @@ ostree_repo_pull_with_options (OstreeRepo *self, (void) g_variant_lookup (options, "require-static-deltas", "b", &require_static_deltas); (void) g_variant_lookup (options, "override-commit-ids", "^a&s", &override_commit_ids); (void) g_variant_lookup (options, "dry-run", "b", &pull_data->dry_run); + (void) g_variant_lookup (options, "override-url", "&s", &url_override); } g_return_val_if_fail (pull_data->maxdepth >= -1, FALSE); @@ -2021,7 +2023,9 @@ ostree_repo_pull_with_options (OstreeRepo *self, { g_autofree char *baseurl = NULL; - if (!ostree_repo_remote_get_url (self, remote_name_or_baseurl, &baseurl, error)) + if (url_override != NULL) + baseurl = g_strdup (url_override); + else 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 35bc3a5d..97233d3d 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -4077,6 +4077,7 @@ ostree_repo_pull_one_dir (OstreeRepo *self, * * require-static-deltas (b): Require static deltas * * override-commit-ids (as): Array of specific commit IDs to fetch for refs * * dry-run (b): Only print information on what will be downloaded (requires static deltas) + * * override-url (s): Fetch objects from this URL if remote specifies no metalink in options */ gboolean ostree_repo_pull_with_options (OstreeRepo *self,