lib/repo-refs: Resolve collection-refs in-memory and in parent repos
Currently the behavior of ostree_repo_resolve_rev() is that it tries to resolve a ref to a commit by checking the refs/ directories, but also by checking for in-memory ref-checksum pairs which are part of an in-progress transaction and also by checking the parent repo if one exists. Currently ostree_repo_resolve_collection_ref() only checks the refs/ directories, so this commit makes its behavior analagous since it is the analagous API which supports collection-refs. The impetus for this was that currently Flatpak uses ostree_repo_resolve_rev() to load a commit after doing a P2P pull in flatpak_dir_do_resolve_p2p_refs(), but that assumes the ref came from the same remote that originally provided it, which might not be the case if more than one remote has the same collection ID configured. And changing Flatpak to use ostree_repo_resolve_collection_ref() doesn't work without this patch. Closes: #1821 Approved by: pwithnall
This commit is contained in:
parent
f5c86c834b
commit
77f91d6c6b
|
|
@ -537,7 +537,30 @@ ostree_repo_resolve_collection_ref (OstreeRepo *self,
|
|||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
const char *ret_contents = g_hash_table_lookup (refs, ref);
|
||||
g_autofree char *ret_contents = g_strdup (g_hash_table_lookup (refs, ref));
|
||||
|
||||
/* Check for refs in the current transaction that haven't been written to
|
||||
* disk, to match the behavior of ostree_repo_resolve_rev() */
|
||||
if (ret_contents == NULL && self->in_transaction)
|
||||
{
|
||||
g_mutex_lock (&self->txn_lock);
|
||||
if (self->txn.collection_refs)
|
||||
ret_contents = g_strdup (g_hash_table_lookup (self->txn.collection_refs, ref));
|
||||
g_mutex_unlock (&self->txn_lock);
|
||||
}
|
||||
|
||||
/* Check for refs in the parent repo */
|
||||
if (ret_contents == NULL && self->parent_repo != NULL)
|
||||
{
|
||||
if (!ostree_repo_resolve_collection_ref (self->parent_repo,
|
||||
ref,
|
||||
TRUE,
|
||||
flags,
|
||||
&ret_contents,
|
||||
cancellable,
|
||||
error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (ret_contents == NULL && !allow_noent)
|
||||
{
|
||||
|
|
@ -548,7 +571,7 @@ ostree_repo_resolve_collection_ref (OstreeRepo *self,
|
|||
}
|
||||
|
||||
if (out_rev != NULL)
|
||||
*out_rev = g_strdup (ret_contents);
|
||||
*out_rev = g_steal_pointer (&ret_contents);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue