diff options
Diffstat (limited to 'src/libostree/ostree-repo.c')
-rw-r--r-- | src/libostree/ostree-repo.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index a27591b3..f6bffd60 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -710,6 +710,32 @@ ostree_repo_auto_lock_cleanup (OstreeRepoAutoLock *auto_lock) } /** + * _ostree_repo_auto_transaction_new: + * @repo: (not nullable): an #OsreeRepo object + * @cancellable: Cancellable + * @error: a #GError + * + * Return a guard for a transaction in @repo. + * + * Do not call this function outside the OstreeRepo transaction implementation. + * Use _ostree_repo_auto_transaction_start() instead. + * + * Returns: (transfer full): an #OstreeRepoAutoTransaction guard on success, + * %NULL otherwise. + */ +OstreeRepoAutoTransaction * +_ostree_repo_auto_transaction_new (OstreeRepo *repo) +{ + g_assert (repo != NULL); + + OstreeRepoAutoTransaction *txn = g_malloc(sizeof(OstreeRepoAutoTransaction)); + txn->atomic_refcount = 1; + txn->repo = g_object_ref (repo); + + return g_steal_pointer (&txn); +} + +/** * _ostree_repo_auto_transaction_start: * @repo: (not nullable): an #OsreeRepo object * @cancellable: Cancellable @@ -730,11 +756,7 @@ _ostree_repo_auto_transaction_start (OstreeRepo *repo, if (!ostree_repo_prepare_transaction (repo, NULL, cancellable, error)) return NULL; - OstreeRepoAutoTransaction *txn = g_malloc(sizeof(OstreeRepoAutoTransaction)); - txn->atomic_refcount = 1; - txn->repo = g_object_ref (repo); - - return g_steal_pointer (&txn); + return _ostree_repo_auto_transaction_new (repo); } /** |