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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 *
|
||||
ostree_repo_get_file_object_path (OstreeRepo *self,
|
||||
const char *checksum)
|
||||
|
@ -69,6 +69,8 @@ GKeyFile * ostree_repo_get_config (OstreeRepo *self);
|
||||
|
||||
GKeyFile * ostree_repo_copy_config (OstreeRepo *self);
|
||||
|
||||
OstreeRepo * ostree_repo_get_parent (OstreeRepo *self);
|
||||
|
||||
gboolean ostree_repo_write_config (OstreeRepo *self,
|
||||
GKeyFile *new_config,
|
||||
GError **error);
|
||||
|
@ -1062,7 +1062,46 @@ parse_ref_summary (const char *contents,
|
||||
g_strfreev (lines);
|
||||
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
|
||||
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);
|
||||
|
||||
remote_key = g_strdup_printf ("remote \"%s\"", pull_data->remote_name);
|
||||
baseurl = g_key_file_get_string (config, remote_key, "url", error);
|
||||
if (!baseurl)
|
||||
if (!repo_get_string_key_inherit (repo, remote_key, "url", &baseurl, error))
|
||||
goto out;
|
||||
pull_data->base_uri = soup_uri_new (baseurl);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user