[ostree] repo: Make abort_transaction silently succeed if we're not in a transaction



commit f84504a8c402274ed2c93aaf9c678663a8831b95
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Sep 5 17:57:53 2013 -0400

    repo: Make abort_transaction silently succeed if we're not in a transaction
    
    This helps callers out a lot, and means we can always call abort_transaction
    at the end of a function.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=707644

 src/libostree/ostree-repo-commit.c |    3 +++
 src/ostree/ot-builtin-commit.c     |   16 +---------------
 2 files changed, 4 insertions(+), 15 deletions(-)
---
diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c
index 69b48c8..8b69e48 100644
--- a/src/libostree/ostree-repo-commit.c
+++ b/src/libostree/ostree-repo-commit.c
@@ -662,6 +662,9 @@ ostree_repo_abort_transaction (OstreeRepo     *self,
 {
   gboolean ret = FALSE;
 
+  if (!self->in_transaction)
+    return TRUE;
+
   if (!cleanup_tmpdir (self, cancellable, error))
     goto out;
 
diff --git a/src/ostree/ot-builtin-commit.c b/src/ostree/ot-builtin-commit.c
index 22d6d89..80d0e50 100644
--- a/src/ostree/ot-builtin-commit.c
+++ b/src/ostree/ot-builtin-commit.c
@@ -224,7 +224,6 @@ ostree_builtin_commit (int argc, char **argv, OstreeRepo *repo, GCancellable *ca
   GOptionContext *context;
   gboolean ret = FALSE;
   gboolean skip_commit = FALSE;
-  gboolean in_transaction = FALSE;
   gs_unref_object GFile *arg = NULL;
   gs_free char *parent = NULL;
   gs_free char *commit_checksum = NULL;
@@ -294,8 +293,6 @@ ostree_builtin_commit (int argc, char **argv, OstreeRepo *repo, GCancellable *ca
   if (!ostree_repo_prepare_transaction (repo, opt_link_checkout_speedup, NULL, cancellable, error))
     goto out;
 
-  in_transaction = TRUE;
-
   mtree = ostree_mutable_tree_new ();
 
   if (argc <= 1 && (opt_trees == NULL || opt_trees[0] == NULL))
@@ -422,20 +419,12 @@ ostree_builtin_commit (int argc, char **argv, OstreeRepo *repo, GCancellable *ca
 
       if (!ostree_repo_commit_transaction (repo, &stats, cancellable, error))
         goto out;
-
-      in_transaction = FALSE;
       
       if (!ostree_repo_write_ref (repo, NULL, opt_branch, commit_checksum, error))
         goto out;
-
     }
   else
     {
-      if (!ostree_repo_abort_transaction (repo, cancellable, error))
-        goto out;
-
-      in_transaction = FALSE;
-
       commit_checksum = g_strdup (parent);
     }
 
@@ -455,10 +444,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeRepo *repo, GCancellable *ca
 
   ret = TRUE;
  out:
-  if (in_transaction)
-    {
-      (void) ostree_repo_abort_transaction (repo, cancellable, NULL);
-    }
+  ostree_repo_abort_transaction (repo, cancellable, NULL);
   if (context)
     g_option_context_free (context);
   if (modifier)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]