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:
Jonathan Lebon authored and Atomic Bot committed 2018-03-16 19:18:08 +00:00
1 parent 10fb74025d
commit 296ef25e12
2 files changed
+25 -2

No files matched your search

+18 -2
View File
@@ -629,8 +629,24 @@ _ostree_repo_list_refs_internal (OstreeRepo *self,
const char *prefix_path;
const char *path;
if (!ostree_parse_refspec (refspec_prefix, &remote, &ref_prefix, error))
return FALSE;
/* 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)
{