Blame SOURCES/0003-repo-Factor-out-_ostree_repo_auto_transaction_new.patch

7a9a56
From 4a997ae08605ebe6ca02d9f422082f954e667a6c Mon Sep 17 00:00:00 2001
7a9a56
From: Simon McVittie <smcv@collabora.com>
7a9a56
Date: Sat, 30 Apr 2022 12:20:11 +0100
7a9a56
Subject: [PATCH 3/6] repo: Factor out _ostree_repo_auto_transaction_new()
7a9a56
7a9a56
This will allow the direct allocation in
7a9a56
ostree_repo_prepare_transaction() to be replaced with a call to this
7a9a56
function, avoiding breaking encapsulation.
7a9a56
7a9a56
Signed-off-by: Simon McVittie <smcv@collabora.com>
7a9a56
(cherry picked from commit 540e60c3e3ace66dd4e6cf825488fc918260a642)
7a9a56
---
7a9a56
 src/libostree/ostree-repo-private.h |  4 ++++
7a9a56
 src/libostree/ostree-repo.c         | 32 ++++++++++++++++++++++++-----
7a9a56
 2 files changed, 31 insertions(+), 5 deletions(-)
7a9a56
7a9a56
diff --git a/src/libostree/ostree-repo-private.h b/src/libostree/ostree-repo-private.h
7a9a56
index 988c2179..96253e77 100644
7a9a56
--- a/src/libostree/ostree-repo-private.h
7a9a56
+++ b/src/libostree/ostree-repo-private.h
7a9a56
@@ -554,4 +554,8 @@ GType _ostree_repo_auto_transaction_get_type (void);
7a9a56
 
7a9a56
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepoAutoTransaction, _ostree_repo_auto_transaction_unref);
7a9a56
 
7a9a56
+/* Internal function to break a circular dependency:
7a9a56
+ * should not be made into public API, even if the rest is */
7a9a56
+OstreeRepoAutoTransaction *_ostree_repo_auto_transaction_new (OstreeRepo *repo);
7a9a56
+
7a9a56
 G_END_DECLS
7a9a56
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
7a9a56
index a27591b3..f6bffd60 100644
7a9a56
--- a/src/libostree/ostree-repo.c
7a9a56
+++ b/src/libostree/ostree-repo.c
7a9a56
@@ -709,6 +709,32 @@ ostree_repo_auto_lock_cleanup (OstreeRepoAutoLock *auto_lock)
7a9a56
     }
7a9a56
 }
7a9a56
 
7a9a56
+/**
7a9a56
+ * _ostree_repo_auto_transaction_new:
7a9a56
+ * @repo: (not nullable): an #OsreeRepo object
7a9a56
+ * @cancellable: Cancellable
7a9a56
+ * @error: a #GError
7a9a56
+ *
7a9a56
+ * Return a guard for a transaction in @repo.
7a9a56
+ *
7a9a56
+ * Do not call this function outside the OstreeRepo transaction implementation.
7a9a56
+ * Use _ostree_repo_auto_transaction_start() instead.
7a9a56
+ *
7a9a56
+ * Returns: (transfer full): an #OstreeRepoAutoTransaction guard on success,
7a9a56
+ * %NULL otherwise.
7a9a56
+ */
7a9a56
+OstreeRepoAutoTransaction *
7a9a56
+_ostree_repo_auto_transaction_new (OstreeRepo *repo)
7a9a56
+{
7a9a56
+  g_assert (repo != NULL);
7a9a56
+
7a9a56
+  OstreeRepoAutoTransaction *txn = g_malloc(sizeof(OstreeRepoAutoTransaction));
7a9a56
+  txn->atomic_refcount = 1;
7a9a56
+  txn->repo = g_object_ref (repo);
7a9a56
+
7a9a56
+  return g_steal_pointer (&txn);
7a9a56
+}
7a9a56
+
7a9a56
 /**
7a9a56
  * _ostree_repo_auto_transaction_start:
7a9a56
  * @repo: (not nullable): an #OsreeRepo object
7a9a56
@@ -730,11 +756,7 @@ _ostree_repo_auto_transaction_start (OstreeRepo     *repo,
7a9a56
   if (!ostree_repo_prepare_transaction (repo, NULL, cancellable, error))
7a9a56
     return NULL;
7a9a56
 
7a9a56
-  OstreeRepoAutoTransaction *txn = g_malloc(sizeof(OstreeRepoAutoTransaction));
7a9a56
-  txn->atomic_refcount = 1;
7a9a56
-  txn->repo = g_object_ref (repo);
7a9a56
-
7a9a56
-  return g_steal_pointer (&txn);
7a9a56
+  return _ostree_repo_auto_transaction_new (repo);
7a9a56
 }
7a9a56
 
7a9a56
 /**
7a9a56
-- 
7a9a56
2.31.1
7a9a56