summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-repo-refs.c
diff options
context:
space:
mode:
authorMatthew Leeds <matthew.leeds@endlessm.com>2019-02-21 15:39:45 -0800
committerAtomic Bot <atomic-devel@projectatomic.io>2019-04-15 15:56:40 +0000
commit0ecbc6f2a9ddd6ab9700e98da794eef7290ffdc7 (patch)
tree13b93c184b6f7baf752518eb3b726e1d4a5b0c8d /src/libostree/ostree-repo-refs.c
parent23304b8c15835e75e257c7eb589808e40f3e39c9 (diff)
downloadostree-0ecbc6f2a9ddd6ab9700e98da794eef7290ffdc7.tar.gz
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
Diffstat (limited to 'src/libostree/ostree-repo-refs.c')
-rw-r--r--src/libostree/ostree-repo-refs.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libostree/ostree-repo-refs.c b/src/libostree/ostree-repo-refs.c
index be2eb59a..fec36420 100644
--- a/src/libostree/ostree-repo-refs.c
+++ b/src/libostree/ostree-repo-refs.c
@@ -1247,7 +1247,9 @@ _ostree_repo_update_collection_refs (OstreeRepo *self,
* (ostree_repo_get_collection_id()).
*
* 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
* 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))
return FALSE;
- const gchar *refs_dirs[] = { "refs/mirrors", "refs/remotes", NULL };
- if (flags & OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES)
- refs_dirs[1] = NULL;
+ g_autoptr(GPtrArray) refs_dirs = g_ptr_array_new ();
+ if (!(flags & OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS))
+ 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;
@@ -1301,7 +1306,7 @@ ostree_repo_list_collection_refs (OstreeRepo *self,
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;
gboolean refs_dir_exists = FALSE;