lib/repo-refs: Add a flag to exclude listing from refs/mirrors
Currently the flag OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES for ostree_repo_list_collection_refs() means that refs in refs/remotes/ should be excluded but refs in refs/mirrors/ should still be checked, in addition to refs/heads/ which is always checked. However in some situations you want to exclude both remote and mirrored refs and only check local "owned" ones. So this commit adds a new flag OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS which lets you exclude refs/mirrors/ from the listing. This way we can avoid breaking API but still allow the listing of local collection-refs. The impetus for this change is that I'm changing Flatpak to make more use of refs/mirrors, and we need a way to specify that a collection-ref is local when using ostree_repo_resolve_collection_ref() in, for example, the implementation of the repo command. The subsequent commit will make the changes needed there. Closes: #1825 Approved by: jlebon
This commit is contained in:
parent
23304b8c15
commit
0ecbc6f2a9
|
|
@ -1247,7 +1247,9 @@ _ostree_repo_update_collection_refs (OstreeRepo *self,
|
||||||
* (ostree_repo_get_collection_id()).
|
* (ostree_repo_get_collection_id()).
|
||||||
*
|
*
|
||||||
* If you want to exclude refs from `refs/remotes`, use
|
* If you want to exclude refs from `refs/remotes`, use
|
||||||
* %OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES in @flags.
|
* %OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES in @flags. Similarly use
|
||||||
|
* %OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS to exclude refs from
|
||||||
|
* `refs/mirrors`.
|
||||||
*
|
*
|
||||||
* Returns: %TRUE on success, %FALSE otherwise
|
* Returns: %TRUE on success, %FALSE otherwise
|
||||||
* Since: 2018.6
|
* Since: 2018.6
|
||||||
|
|
@ -1269,9 +1271,12 @@ ostree_repo_list_collection_refs (OstreeRepo *self,
|
||||||
if (match_collection_id != NULL && !ostree_validate_collection_id (match_collection_id, error))
|
if (match_collection_id != NULL && !ostree_validate_collection_id (match_collection_id, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
const gchar *refs_dirs[] = { "refs/mirrors", "refs/remotes", NULL };
|
g_autoptr(GPtrArray) refs_dirs = g_ptr_array_new ();
|
||||||
if (flags & OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES)
|
if (!(flags & OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS))
|
||||||
refs_dirs[1] = NULL;
|
g_ptr_array_add (refs_dirs, "refs/mirrors");
|
||||||
|
if (!(flags & OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES))
|
||||||
|
g_ptr_array_add (refs_dirs, "refs/remotes");
|
||||||
|
g_ptr_array_add (refs_dirs, NULL);
|
||||||
|
|
||||||
g_autoptr(GHashTable) ret_all_refs = NULL;
|
g_autoptr(GHashTable) ret_all_refs = NULL;
|
||||||
|
|
||||||
|
|
@ -1301,7 +1306,7 @@ ostree_repo_list_collection_refs (OstreeRepo *self,
|
||||||
|
|
||||||
g_string_truncate (base_path, 0);
|
g_string_truncate (base_path, 0);
|
||||||
|
|
||||||
for (const char **iter = refs_dirs; iter && *iter; iter++)
|
for (const char **iter = (const char **)refs_dirs->pdata; iter && *iter; iter++)
|
||||||
{
|
{
|
||||||
const char *refs_dir = *iter;
|
const char *refs_dir = *iter;
|
||||||
gboolean refs_dir_exists = FALSE;
|
gboolean refs_dir_exists = FALSE;
|
||||||
|
|
|
||||||
|
|
@ -499,11 +499,13 @@ gboolean ostree_repo_list_refs (OstreeRepo *self,
|
||||||
* @OSTREE_REPO_LIST_REFS_EXT_NONE: No flags.
|
* @OSTREE_REPO_LIST_REFS_EXT_NONE: No flags.
|
||||||
* @OSTREE_REPO_LIST_REFS_EXT_ALIASES: Only list aliases. Since: 2017.10
|
* @OSTREE_REPO_LIST_REFS_EXT_ALIASES: Only list aliases. Since: 2017.10
|
||||||
* @OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES: Exclude remote refs. Since: 2017.11
|
* @OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES: Exclude remote refs. Since: 2017.11
|
||||||
|
* @OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS: Exclude mirrored refs. Since: 2019.2
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OSTREE_REPO_LIST_REFS_EXT_NONE = 0,
|
OSTREE_REPO_LIST_REFS_EXT_NONE = 0,
|
||||||
OSTREE_REPO_LIST_REFS_EXT_ALIASES = (1 << 0),
|
OSTREE_REPO_LIST_REFS_EXT_ALIASES = (1 << 0),
|
||||||
OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES = (1 << 1),
|
OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES = (1 << 1),
|
||||||
|
OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS = (1 << 2),
|
||||||
} OstreeRepoListRefsExtFlags;
|
} OstreeRepoListRefsExtFlags;
|
||||||
|
|
||||||
_OSTREE_PUBLIC
|
_OSTREE_PUBLIC
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue