summaryrefslogtreecommitdiffstats
path: root/refs.h
diff options
context:
space:
mode:
authorKarthik Nayak <karthik.188@gmail.com>2024-12-16 17:44:31 +0100
committerJunio C Hamano <gitster@pobox.com>2024-12-16 18:45:34 +0100
commit84675fa2717e08b39bf810eb9a439068ac915dfb (patch)
treedca887317d4699b844a946f8d725c1888c336fcc /refs.h
parentrefs: add `committer_info` to `ref_transaction_add_update()` (diff)
downloadgit-84675fa2717e08b39bf810eb9a439068ac915dfb.tar.xz
git-84675fa2717e08b39bf810eb9a439068ac915dfb.zip
refs: introduce the `ref_transaction_update_reflog` function
Introduce a new function `ref_transaction_update_reflog`, for clients to add a reflog update to a transaction. While the existing function `ref_transaction_update` also allows clients to add a reflog entry, this function does a few things more, It: - Enforces that only a reflog entry is added and does not update the ref itself. - Allows the users to also provide the committer information. This means clients can add reflog entries with custom committer information. The `transaction_refname_valid()` function also modifies the error message selectively based on the type of the update. This change also affects reflog updates which go through `ref_transaction_update()`. A follow up commit will utilize this function to add reflog support to `git refs migrate`. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.h')
-rw-r--r--refs.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/refs.h b/refs.h
index a5bedf48cf..b0dfc65ed2 100644
--- a/refs.h
+++ b/refs.h
@@ -728,6 +728,20 @@ int ref_transaction_update(struct ref_transaction *transaction,
struct strbuf *err);
/*
+ * Similar to`ref_transaction_update`, but this function is only for adding
+ * a reflog update. Supports providing custom committer information. The index
+ * field can be utiltized to order updates as desired. When not used, the
+ * updates default to being ordered by refname.
+ */
+int ref_transaction_update_reflog(struct ref_transaction *transaction,
+ const char *refname,
+ const struct object_id *new_oid,
+ const struct object_id *old_oid,
+ const char *committer_info, unsigned int flags,
+ const char *msg, unsigned int index,
+ struct strbuf *err);
+
+/*
* Add a reference creation to transaction. new_oid is the value that
* the reference should have after the update; it must not be
* null_oid. It is verified that the reference does not exist