[PATCH 6/8] refs/reftable-backend: add support for symref updates

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

 



From: Karthik Nayak <karthik.188@xxxxxxxxx>

Add support for transactional symbolic reference updates in the reftable
backend.

While this commit is setting up the reftable-backend to support symrefs
in transaction's. It will only be used in a consequent commit, when we
wire up the `update-symref` option for `git-update-ref`.

Signed-off-by: Karthik Nayak <karthik.188@xxxxxxxxx>
---
 refs/reftable-backend.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
index 92f2803e90..35f2e8e050 100644
--- a/refs/reftable-backend.c
+++ b/refs/reftable-backend.c
@@ -884,7 +884,7 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,
 			new_update = ref_transaction_add_update(
 					transaction, "HEAD",
 					u->flags | REF_LOG_ONLY | REF_NO_DEREF,
-					&u->new_oid, &u->old_oid, u->msg, NULL);
+					&u->new_oid, &u->old_oid, u->msg, u->symref_target);
 			string_list_insert(&affected_refnames, new_update->refname);
 		}
 
@@ -909,9 +909,11 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,
 
 			/*
 			 * There is no need to write the reference deletion
-			 * when the reference in question doesn't exist.
+			 * when the reference in question doesn't exist except
+			 * when we want to create new symrefs.
 			 */
-			 if (u->flags & REF_HAVE_NEW && !is_null_oid(&u->new_oid)) {
+			if ((u->flags & REF_HAVE_NEW && !is_null_oid(&u->new_oid)) ||
+			    u->flags & REF_UPDATE_SYMREF) {
 				 ret = queue_transaction_update(refs, tx_data, u,
 								&current_oid, err);
 				 if (ret)
@@ -963,7 +965,7 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,
 				 */
 				new_update = ref_transaction_add_update(
 						transaction, referent.buf, new_flags,
-						&u->new_oid, &u->old_oid, u->msg, NULL);
+						&u->new_oid, &u->old_oid, u->msg, u->symref_target);
 				new_update->parent_update = u;
 
 				/*
@@ -1026,6 +1028,7 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,
 		 */
 		if ((u->type & REF_ISSYMREF) ||
 		    (u->flags & REF_LOG_ONLY) ||
+		    (u->flags & REF_UPDATE_SYMREF) ||
 		    (u->flags & REF_HAVE_NEW && !oideq(&current_oid, &u->new_oid))) {
 			ret = queue_transaction_update(refs, tx_data, u,
 						       &current_oid, err);
@@ -1187,6 +1190,18 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
 			ret = reftable_writer_add_ref(writer, &ref);
 			if (ret < 0)
 				goto done;
+		} else if (u->flags & REF_UPDATE_SYMREF) {
+			struct write_create_symref_arg create  = {
+				.refs = arg->refs,
+				.stack = arg->stack,
+				.refname = u->refname,
+				.target = u->symref_target,
+				.logmsg = u->msg,
+			};
+
+			write_symref_with_log(writer, &create, ts);
+			if (ret < 0)
+				goto done;
 		}
 	}
 
-- 
2.43.GIT





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux