lib/repo-pull: Fix remote names in refspecs from non-mirror P2P pulls

Propagate the refspec_name from the OstreeRemote returned by an
OstreeRepoFinder through to the set_ref() call.

This changes ostree_repo_pull_with_options() to accept the
previously-disallowed combination of passing override-remote-name in
options and also setting a remote name in remote_name_or_baseurl.
ostree_repo_pull_with_options() will continue to pull using the remote
config named in remote_name_or_baseurl as before; but will now use the
remote name from override-remote-name when it’s setting the refs at the
end of the pull. This is consistent with the documentation for
override-remote-name.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1202
Approved by: cgwalters
This commit is contained in:
Philip Withnall 2017-09-21 16:08:26 +01:00 committed by Atomic Bot
parent 69e332a0c0
commit 9d8c1ec7df
1 changed files with 10 additions and 3 deletions

View File

@ -68,7 +68,8 @@ typedef struct {
OstreeRepo *repo; OstreeRepo *repo;
int tmpdir_dfd; int tmpdir_dfd;
OstreeRepoPullFlags flags; OstreeRepoPullFlags flags;
char *remote_name; char *remote_name;
char *remote_refspec_name;
OstreeRepoMode remote_mode; OstreeRepoMode remote_mode;
OstreeFetcher *fetcher; OstreeFetcher *fetcher;
OstreeFetcherSecurityState fetcher_security_state; OstreeFetcherSecurityState fetcher_security_state;
@ -3226,7 +3227,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
flags = flags_i; flags = flags_i;
(void) g_variant_lookup (options, "subdir", "&s", &dir_to_pull); (void) g_variant_lookup (options, "subdir", "&s", &dir_to_pull);
(void) g_variant_lookup (options, "subdirs", "^a&s", &dirs_to_pull); (void) g_variant_lookup (options, "subdirs", "^a&s", &dirs_to_pull);
(void) g_variant_lookup (options, "override-remote-name", "s", &pull_data->remote_name); (void) g_variant_lookup (options, "override-remote-name", "s", &pull_data->remote_refspec_name);
opt_gpg_verify_set = opt_gpg_verify_set =
g_variant_lookup (options, "gpg-verify", "b", &pull_data->gpg_verify); g_variant_lookup (options, "gpg-verify", "b", &pull_data->gpg_verify);
opt_gpg_verify_summary_set = opt_gpg_verify_summary_set =
@ -3242,6 +3243,9 @@ ostree_repo_pull_with_options (OstreeRepo *self,
(void) g_variant_lookup (options, "update-frequency", "u", &update_frequency); (void) g_variant_lookup (options, "update-frequency", "u", &update_frequency);
(void) g_variant_lookup (options, "localcache-repos", "^a&s", &opt_localcache_repos); (void) g_variant_lookup (options, "localcache-repos", "^a&s", &opt_localcache_repos);
(void) g_variant_lookup (options, "timestamp-check", "b", &pull_data->timestamp_check); (void) g_variant_lookup (options, "timestamp-check", "b", &pull_data->timestamp_check);
if (pull_data->remote_refspec_name != NULL)
pull_data->remote_name = g_strdup (pull_data->remote_refspec_name);
} }
g_return_val_if_fail (OSTREE_IS_REPO (self), FALSE); g_return_val_if_fail (OSTREE_IS_REPO (self), FALSE);
@ -4049,7 +4053,8 @@ ostree_repo_pull_with_options (OstreeRepo *self,
ostree_repo_transaction_set_collection_ref (pull_data->repo, ostree_repo_transaction_set_collection_ref (pull_data->repo,
ref, checksum); ref, checksum);
else else
ostree_repo_transaction_set_ref (pull_data->repo, pull_data->remote_name, ostree_repo_transaction_set_ref (pull_data->repo,
(pull_data->remote_refspec_name != NULL) ? pull_data->remote_refspec_name : pull_data->remote_name,
ref->ref_name, checksum); ref->ref_name, checksum);
} }
} }
@ -5370,6 +5375,8 @@ ostree_repo_pull_from_remotes_async (OstreeRepo *self,
g_variant_dict_insert (&local_options_dict, "gpg-verify", "b", TRUE); g_variant_dict_insert (&local_options_dict, "gpg-verify", "b", TRUE);
g_variant_dict_insert (&local_options_dict, "gpg-verify-summary", "b", FALSE); g_variant_dict_insert (&local_options_dict, "gpg-verify-summary", "b", FALSE);
g_variant_dict_insert (&local_options_dict, "inherit-transaction", "b", TRUE); g_variant_dict_insert (&local_options_dict, "inherit-transaction", "b", TRUE);
if (result->remote->refspec_name != NULL)
g_variant_dict_insert (&local_options_dict, "override-remote-name", "s", result->remote->refspec_name);
copy_option (&options_dict, &local_options_dict, "depth", G_VARIANT_TYPE ("i")); copy_option (&options_dict, &local_options_dict, "depth", G_VARIANT_TYPE ("i"));
copy_option (&options_dict, &local_options_dict, "disable-static-deltas", G_VARIANT_TYPE ("b")); copy_option (&options_dict, &local_options_dict, "disable-static-deltas", G_VARIANT_TYPE ("b"));
copy_option (&options_dict, &local_options_dict, "http-headers", G_VARIANT_TYPE ("a(ss)")); copy_option (&options_dict, &local_options_dict, "http-headers", G_VARIANT_TYPE ("a(ss)"));