mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-23 21:35:26 +03:00
core: Fix ostree-pull to be able to look up remotes in parent repo
We should probably add a generalized inheritance mechanism.
This commit is contained in:
parent
f33a2f9a08
commit
a04ef7ba10
@ -781,6 +781,22 @@ ostree_repo_get_mode (OstreeRepo *self)
|
|||||||
return priv->mode;
|
return priv->mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ostree_repo_get_parent:
|
||||||
|
* @self:
|
||||||
|
*
|
||||||
|
* Before this function can be used, ostree_repo_init() must have been
|
||||||
|
* called.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): Parent repository, or %NULL if none
|
||||||
|
*/
|
||||||
|
OstreeRepo *
|
||||||
|
ostree_repo_get_parent (OstreeRepo *self)
|
||||||
|
{
|
||||||
|
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
||||||
|
return priv->parent_repo;
|
||||||
|
}
|
||||||
|
|
||||||
GFile *
|
GFile *
|
||||||
ostree_repo_get_file_object_path (OstreeRepo *self,
|
ostree_repo_get_file_object_path (OstreeRepo *self,
|
||||||
const char *checksum)
|
const char *checksum)
|
||||||
|
@ -69,6 +69,8 @@ GKeyFile * ostree_repo_get_config (OstreeRepo *self);
|
|||||||
|
|
||||||
GKeyFile * ostree_repo_copy_config (OstreeRepo *self);
|
GKeyFile * ostree_repo_copy_config (OstreeRepo *self);
|
||||||
|
|
||||||
|
OstreeRepo * ostree_repo_get_parent (OstreeRepo *self);
|
||||||
|
|
||||||
gboolean ostree_repo_write_config (OstreeRepo *self,
|
gboolean ostree_repo_write_config (OstreeRepo *self,
|
||||||
GKeyFile *new_config,
|
GKeyFile *new_config,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
@ -1063,6 +1063,45 @@ parse_ref_summary (const char *contents,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
repo_get_string_key_inherit (OstreeRepo *repo,
|
||||||
|
const char *section,
|
||||||
|
const char *key,
|
||||||
|
char **out_value,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
GError *temp_error = NULL;
|
||||||
|
GKeyFile *config;
|
||||||
|
ot_lfree char *ret_value = NULL;
|
||||||
|
|
||||||
|
config = ostree_repo_get_config (repo);
|
||||||
|
|
||||||
|
ret_value = g_key_file_get_value (config, section, key, &temp_error);
|
||||||
|
if (temp_error)
|
||||||
|
{
|
||||||
|
OstreeRepo *parent = ostree_repo_get_parent (repo);
|
||||||
|
if (parent &&
|
||||||
|
(g_error_matches (temp_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND)
|
||||||
|
|| g_error_matches (temp_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)))
|
||||||
|
{
|
||||||
|
g_clear_error (&temp_error);
|
||||||
|
if (!repo_get_string_key_inherit (parent, section, key, &ret_value, error))
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_propagate_error (error, temp_error);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = TRUE;
|
||||||
|
ot_transfer_out_value (out_value, &ret_value);
|
||||||
|
out:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
|
ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
{
|
{
|
||||||
@ -1118,8 +1157,7 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
|
|||||||
config = ostree_repo_get_config (repo);
|
config = ostree_repo_get_config (repo);
|
||||||
|
|
||||||
remote_key = g_strdup_printf ("remote \"%s\"", pull_data->remote_name);
|
remote_key = g_strdup_printf ("remote \"%s\"", pull_data->remote_name);
|
||||||
baseurl = g_key_file_get_string (config, remote_key, "url", error);
|
if (!repo_get_string_key_inherit (repo, remote_key, "url", &baseurl, error))
|
||||||
if (!baseurl)
|
|
||||||
goto out;
|
goto out;
|
||||||
pull_data->base_uri = soup_uri_new (baseurl);
|
pull_data->base_uri = soup_uri_new (baseurl);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user