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

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