[ostree] ostree-repo: new public function `ostree_repo_list_refs_ext`
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] ostree-repo: new public function `ostree_repo_list_refs_ext`
- Date: Wed, 2 Mar 2016 19:53:26 +0000 (UTC)
commit 898c7b6577a7310d46f0ca8514d6954395bbd85e
Author: Giuseppe Scrivano <gscrivan redhat com>
Date: Wed Mar 2 09:58:38 2016 +0100
ostree-repo: new public function `ostree_repo_list_refs_ext`
It accepts a `flags` argument to control its behavior. Differently
from `ostree_repo_list_refs`, the `refspec_prefix` is not removed from
the results.
Signed-off-by: Giuseppe Scrivano <gscrivan redhat com>
apidoc/ostree-sections.txt | 1 +
src/libostree/libostree.sym | 1 +
src/libostree/ostree-repo-refs.c | 79 ++++++++++++++++++++++++++++----------
src/libostree/ostree-repo.h | 16 ++++++++
4 files changed, 77 insertions(+), 20 deletions(-)
---
diff --git a/apidoc/ostree-sections.txt b/apidoc/ostree-sections.txt
index 4b22e25..e4ce525 100644
--- a/apidoc/ostree-sections.txt
+++ b/apidoc/ostree-sections.txt
@@ -260,6 +260,7 @@ ostree_repo_write_content_async
ostree_repo_write_content_finish
ostree_repo_resolve_rev
ostree_repo_list_refs
+ostree_repo_list_refs_ext
ostree_repo_remote_list_refs
ostree_repo_load_variant
ostree_repo_load_commit
diff --git a/src/libostree/libostree.sym b/src/libostree/libostree.sym
index ce8861f..f86a1ea 100644
--- a/src/libostree/libostree.sym
+++ b/src/libostree/libostree.sym
@@ -315,4 +315,5 @@ local:
LIBOSTREE_2016.4 {
global:
ostree_repo_get_dfd;
+ ostree_repo_list_refs_ext;
} LIBOSTREE_2016.3;
diff --git a/src/libostree/ostree-repo-refs.c b/src/libostree/ostree-repo-refs.c
index 68e34f2..bf48006 100644
--- a/src/libostree/ostree-repo-refs.c
+++ b/src/libostree/ostree-repo-refs.c
@@ -508,24 +508,13 @@ enumerate_refs_recurse (OstreeRepo *repo,
return ret;
}
-/**
- * ostree_repo_list_refs:
- * @self: Repo
- * @refspec_prefix: (allow-none): Only list refs which match this prefix
- * @out_all_refs: (out) (element-type utf8 utf8): Mapping from ref to checksum
- * @cancellable: Cancellable
- * @error: Error
- *
- * If @refspec_prefix is %NULL, list all local and remote refspecs,
- * with their current values in @out_all_refs. Otherwise, only list
- * refspecs which have @refspec_prefix as a prefix.
- */
-gboolean
-ostree_repo_list_refs (OstreeRepo *self,
- const char *refspec_prefix,
- GHashTable **out_all_refs,
- GCancellable *cancellable,
- GError **error)
+static gboolean
+_ostree_repo_list_refs_internal (OstreeRepo *self,
+ gboolean cut_prefix,
+ const char *refspec_prefix,
+ GHashTable **out_all_refs,
+ GCancellable *cancellable,
+ GError **error)
{
gboolean ret = FALSE;
g_autoptr(GHashTable) ret_all_refs = NULL;
@@ -568,12 +557,14 @@ ostree_repo_list_refs (OstreeRepo *self,
{
glnx_fd_close int base_fd = -1;
g_autoptr(GString) base_path = g_string_new ("");
+ if (!cut_prefix)
+ g_string_printf (base_path, "%s/", ref_prefix);
- if (!glnx_opendirat (self->repo_dir_fd, path, TRUE, &base_fd, error))
+ if (!glnx_opendirat (self->repo_dir_fd, cut_prefix ? path : prefix_path, TRUE, &base_fd,
error))
goto out;
if (!enumerate_refs_recurse (self, remote, base_fd, base_path,
- base_fd, ".",
+ base_fd, cut_prefix ? "." : ref_prefix,
ret_all_refs, cancellable, error))
goto out;
}
@@ -640,6 +631,54 @@ ostree_repo_list_refs (OstreeRepo *self,
}
/**
+ * ostree_repo_list_refs:
+ * @self: Repo
+ * @refspec_prefix: (allow-none): Only list refs which match this prefix
+ * @out_all_refs: (out) (element-type utf8 utf8): Mapping from ref to checksum
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * If @refspec_prefix is %NULL, list all local and remote refspecs,
+ * with their current values in @out_all_refs. Otherwise, only list
+ * refspecs which have @refspec_prefix as a prefix.
+ */
+gboolean
+ostree_repo_list_refs (OstreeRepo *self,
+ const char *refspec_prefix,
+ GHashTable **out_all_refs,
+ GCancellable *cancellable,
+ GError **error)
+{
+ return _ostree_repo_list_refs_internal (self, TRUE, refspec_prefix, out_all_refs, cancellable, error);
+}
+
+/**
+ * ostree_repo_list_refs_ext:
+ * @self: Repo
+ * @refspec_prefix: (allow-none): Only list refs which match this prefix
+ * @out_all_refs: (out) (element-type utf8 utf8): Mapping from ref to checksum
+ * @flags: Options controlling listing behavior
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * If @refspec_prefix is %NULL, list all local and remote refspecs,
+ * with their current values in @out_all_refs. Otherwise, only list
+ * refspecs which have @refspec_prefix as a prefix. Differently from
+ * ostree_repo_list_refs(), the prefix will not be removed from the ref
+ * name.
+ */
+gboolean
+ostree_repo_list_refs_ext (OstreeRepo *self,
+ const char *refspec_prefix,
+ GHashTable **out_all_refs,
+ OstreeRepoListRefsExtFlags flags,
+ GCancellable *cancellable,
+ GError **error)
+{
+ return _ostree_repo_list_refs_internal (self, FALSE, refspec_prefix, out_all_refs, cancellable, error);
+}
+
+/**
* ostree_repo_remote_list_refs:
* @self: Repo
* @remote_name: Name of the remote.
diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h
index b8399b1..07e76aa 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -342,6 +342,22 @@ gboolean ostree_repo_list_refs (OstreeRepo *self,
GCancellable *cancellable,
GError **error);
+/**
+ * OstreeRepoListRefsExtFlags:
+ * @OSTREE_REPO_LIST_REFS_EXT_NONE: No flags.
+ */
+typedef enum {
+ OSTREE_REPO_LIST_REFS_EXT_NONE = 0,
+} OstreeRepoListRefsExtFlags;
+
+_OSTREE_PUBLIC
+gboolean ostree_repo_list_refs_ext (OstreeRepo *self,
+ const char *refspec_prefix,
+ GHashTable **out_all_refs,
+ OstreeRepoListRefsExtFlags flags,
+ GCancellable *cancellable,
+ GError **error);
+
_OSTREE_PUBLIC
gboolean ostree_repo_remote_list_refs (OstreeRepo *self,
const char *remote_name,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]