aboutsummaryrefslogtreecommitdiffstats
path: root/refs.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-05-20 11:20:04 -0700
committerJunio C Hamano <gitster@pobox.com>2024-05-20 11:20:04 -0700
commit4beb7a3b066c98d614d402aec32fc87d76206c89 (patch)
tree856e6ccd092b8b18c70868be74f70ee85be814e6 /refs.h
parentd8ab1d464d07baa30e5a180eb33b3f9aa5c93adf (diff)
parent4865707bdae18163c215f2fa44c37388989bc0e4 (diff)
downloadgit-4beb7a3b066c98d614d402aec32fc87d76206c89.tar.gz
Merge branch 'kn/ref-transaction-symref'
Updates to symbolic refs can now be made as a part of ref transaction. * kn/ref-transaction-symref: refs: remove `create_symref` and associated dead code refs: rename `refs_create_symref()` to `refs_update_symref()` refs: use transaction in `refs_create_symref()` refs: add support for transactional symref updates refs: move `original_update_refname` to 'refs.c' refs: support symrefs in 'reference-transaction' hook files-backend: extract out `create_symref_lock()` refs: accept symref values in `ref_transaction_update()`
Diffstat (limited to 'refs.h')
-rw-r--r--refs.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/refs.h b/refs.h
index d02dd79ca6..fb419ab2ed 100644
--- a/refs.h
+++ b/refs.h
@@ -563,7 +563,7 @@ int refs_rename_ref(struct ref_store *refs, const char *oldref,
int refs_copy_existing_ref(struct ref_store *refs, const char *oldref,
const char *newref, const char *logmsg);
-int refs_create_symref(struct ref_store *refs, const char *refname,
+int refs_update_symref(struct ref_store *refs, const char *refname,
const char *target, const char *logmsg);
enum action_on_err {
@@ -603,6 +603,16 @@ struct ref_transaction *ref_store_transaction_begin(struct ref_store *refs,
* before the update. A copy of this value is made in the
* transaction.
*
+ * new_target -- the target reference that the reference will be
+ * updated to point to. If the reference is a regular reference,
+ * it will be converted to a symbolic reference. Cannot be set
+ * together with `new_oid`. A copy of this value is made in the
+ * transaction.
+ *
+ * old_target -- the reference that the reference must be pointing to.
+ * Canont be set together with `old_oid`. A copy of this value is
+ * made in the transaction.
+ *
* flags -- flags affecting the update, passed to
* update_ref_lock(). Possible flags: REF_NO_DEREF,
* REF_FORCE_CREATE_REFLOG. See those constants for more
@@ -668,7 +678,11 @@ struct ref_transaction *ref_store_transaction_begin(struct ref_store *refs,
* beforehand. The old value is checked after the lock is taken to
* prevent races. If the old value doesn't agree with old_oid, the
* whole transaction fails. If old_oid is NULL, then the previous
- * value is not checked.
+ * value is not checked. If `old_target` is not NULL, treat the reference
+ * as a symbolic ref and validate that its target before the update is
+ * `old_target`. If the `new_target` is not NULL, then the reference
+ * will be updated to a symbolic ref which targets `new_target`.
+ * Together, these allow us to update between regular refs and symrefs.
*
* See the above comment "Reference transaction updates" for more
* information.
@@ -677,6 +691,8 @@ int ref_transaction_update(struct ref_transaction *transaction,
const char *refname,
const struct object_id *new_oid,
const struct object_id *old_oid,
+ const char *new_target,
+ const char *old_target,
unsigned int flags, const char *msg,
struct strbuf *err);