mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-22 17:35:55 +03:00
lib/core: Support <remote>: syntax when listing refs
Allow users to pass `<remote>:` to list all refs we have locally belonging to `<remote>`. Also (re-)allow the similar `<remote>:.` syntax for backwards compatibility with flatpak. Closes: #1500 Approved by: cgwalters
This commit is contained in:
parent
10fb74025d
commit
296ef25e12
@ -629,8 +629,24 @@ _ostree_repo_list_refs_internal (OstreeRepo *self,
|
||||
const char *prefix_path;
|
||||
const char *path;
|
||||
|
||||
/* special-case "<remote>:" and "<remote>:.", which ostree_parse_refspec won't like */
|
||||
if (g_str_has_suffix (refspec_prefix, ":") ||
|
||||
g_str_has_suffix (refspec_prefix, ":."))
|
||||
{
|
||||
const char *colon = strrchr (refspec_prefix, ':');
|
||||
g_autofree char *r = g_strndup (refspec_prefix, colon - refspec_prefix);
|
||||
if (ostree_validate_remote_name (r, NULL))
|
||||
{
|
||||
remote = g_steal_pointer (&r);
|
||||
ref_prefix = g_strdup (".");
|
||||
}
|
||||
}
|
||||
|
||||
if (!ref_prefix)
|
||||
{
|
||||
if (!ostree_parse_refspec (refspec_prefix, &remote, &ref_prefix, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!(flags & OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES) && remote)
|
||||
{
|
||||
|
@ -147,6 +147,13 @@ ${CMD_PREFIX} ostree --repo=repo refs local1 --create=origin:local1
|
||||
${CMD_PREFIX} ostree --repo=repo refs | wc -l > refscount.create6
|
||||
assert_file_has_content refscount.create6 "^11$"
|
||||
|
||||
#Check that we can list just remote refs
|
||||
${CMD_PREFIX} ostree --repo=repo refs origin: | wc -l > refscount.create7
|
||||
assert_file_has_content refscount.create7 "^2$" # origin:remote1 origin:local1
|
||||
#Also support :. for backcompat with flatpak
|
||||
${CMD_PREFIX} ostree --repo=repo refs origin:. | wc -l > refscount.create8
|
||||
assert_file_has_content refscount.create8 "^2$" # origin:remote1 origin:local1
|
||||
|
||||
echo "ok refs"
|
||||
|
||||
# Test symlinking a ref
|
||||
|
Loading…
Reference in New Issue
Block a user