repo: Add wrapper function for setting devino cache on checkout opts
authorColin Walters <walters@verbum.org>
Thu, 19 Oct 2017 14:25:59 +0000 (10:25 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 20 Oct 2017 18:20:19 +0000 (18:20 +0000)
I was trying to use this with pygobject for an OCI+ostree project, and pygobject
rejected simply assigning to the field (understandably, since it can't bind the
lifetime together).

Add a wrapper function, which is still unsafe, but hides that unsafety
where most people shouldn't find it.  And if they do...well, sorry,
Rust wasn't invented when ostree was started.

Closes: #1295
Approved by: pwithnall

apidoc/ostree-sections.txt
src/libostree/libostree-devel.sym
src/libostree/ostree-repo-checkout.c
src/libostree/ostree-repo-commit.c
src/libostree/ostree-repo.h

index 1ba02cfc0b04aa3b08247e40557276bc5fb8dc3a..b37c8914af1b9402d2fbba70fab3c48679aebdb0 100644 (file)
@@ -371,6 +371,8 @@ ostree_repo_write_commit
 ostree_repo_write_commit_with_time
 ostree_repo_read_commit_detached_metadata
 ostree_repo_write_commit_detached_metadata
+OstreeRepoCheckoutAtOptions
+ostree_repo_checkout_at_options_set_devino
 OstreeRepoCheckoutMode
 OstreeRepoCheckoutOverwriteMode
 ostree_repo_checkout_tree
index 07d99f1564ea4ca68f141581c36c149693fdc695..aa3a82e97bdaf6ea94ad2adf99a38ab05902fc97 100644 (file)
@@ -21,6 +21,7 @@
 LIBOSTREE_2017.13 {
 global:
   ostree_checksum_file_at;
+  ostree_repo_checkout_at_options_set_devino;
 } LIBOSTREE_2017.12;
 
 /* Stub section for the stable release *after* this development one; don't
index c2639a223021eb84b0e7f348abaf3910e1f070ca..962b503d12391532787d1931c743464d459e4260 100644 (file)
@@ -1210,6 +1210,24 @@ ostree_repo_checkout_at (OstreeRepo                        *self,
   return TRUE;
 }
 
+/**
+ * ostree_repo_checkout_at_options_set_devino:
+ * @opts: Checkout options
+ * @cache: (transfer none) (nullable): Devino cache
+ *
+ * This function simply assigns @cache to the `devino_to_csum_cache` member of
+ * @opts; it's only useful for introspection.
+ *
+ * Note that cache does *not* have its refcount incremented - the lifetime of
+ * @cache must be equal to or greater than that of @opts.
+ */
+void
+ostree_repo_checkout_at_options_set_devino (OstreeRepoCheckoutAtOptions *opts,
+                                            OstreeRepoDevInoCache *cache)
+{
+  opts->devino_to_csum_cache = cache;
+}
+
 static guint
 devino_hash (gconstpointer a)
 {
index b6fbd3d149f82f7d67990bfb03e53ea3f897e8ba..d6a425d8e1667c86a191224dc7f3297b314a1b2b 100644 (file)
@@ -3415,6 +3415,8 @@ ostree_repo_commit_modifier_set_sepolicy (OstreeRepoCommitModifier
  *
  * This function will add a reference to @cache without copying - you
  * should avoid further mutation of the cache.
+ *
+ * Since: 2017.13
  */
 void
 ostree_repo_commit_modifier_set_devino_cache (OstreeRepoCommitModifier              *modifier,
index e1daf08d4ea8c53beb908a5ea3a2ae98499885f3..15e5f94e8ccc90fb57f041502beee105a53b2da0 100644 (file)
@@ -911,6 +911,9 @@ OstreeRepoDevInoCache * ostree_repo_devino_cache_ref (OstreeRepoDevInoCache *cac
 _OSTREE_PUBLIC
 void ostree_repo_devino_cache_unref (OstreeRepoDevInoCache *cache);
 
+_OSTREE_PUBLIC
+void ostree_repo_checkout_at_options_set_devino (OstreeRepoCheckoutAtOptions *opts, OstreeRepoDevInoCache *cache);
+
 _OSTREE_PUBLIC
 gboolean ostree_repo_checkout_at (OstreeRepo                         *self,
                                   OstreeRepoCheckoutAtOptions        *options,