ostree_repo_resolve_rev: Resolve refs set in the transaction
authorAlexander Larsson <alexl@redhat.com>
Wed, 13 Jun 2018 17:20:28 +0000 (19:20 +0200)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 14 Jun 2018 17:58:47 +0000 (17:58 +0000)
This allows you to get at the current commit for a ref pending in the transaction.

Closes: #1624
Approved by: cgwalters

src/libostree/ostree-repo-refs.c

index d10e302e357a76ce3c5f16dad2178781f990f95c..2600cb7ce250b5fb70fe10bf0dddd35258d714e3 100644 (file)
@@ -245,7 +245,28 @@ resolve_refspec (OstreeRepo     *self,
     {
       ret_rev = g_strdup (ref);
     }
-  else if (remote != NULL)
+  else if (self->in_transaction)
+    {
+      const char *refspec;
+
+      if (remote != NULL)
+        refspec = glnx_strjoina (remote, ":", ref);
+      else
+        refspec = ref;
+
+      g_mutex_lock (&self->txn_lock);
+      if (self->txn.refs)
+        ret_rev = g_strdup (g_hash_table_lookup (self->txn.refs, refspec));
+      g_mutex_unlock (&self->txn_lock);
+    }
+
+  if (ret_rev != NULL)
+    {
+      ot_transfer_out_value (out_rev, &ret_rev);
+      return TRUE;
+    }
+
+  if (remote != NULL)
     {
       const char *remote_ref = glnx_strjoina ("refs/remotes/", remote, "/", ref);