From: Alexander Larsson Date: Wed, 13 Jun 2018 17:20:28 +0000 (+0200) Subject: ostree_repo_resolve_rev: Resolve refs set in the transaction X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~22^2~8 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=677e1810254685a1ec34679c5b1f5324236b091d;p=ostree.git ostree_repo_resolve_rev: Resolve refs set in the transaction This allows you to get at the current commit for a ref pending in the transaction. Closes: #1624 Approved by: cgwalters --- diff --git a/src/libostree/ostree-repo-refs.c b/src/libostree/ostree-repo-refs.c index d10e302e..2600cb7c 100644 --- a/src/libostree/ostree-repo-refs.c +++ b/src/libostree/ostree-repo-refs.c @@ -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);