refs: export `ref_transaction_update_reflog()`

In a subsequent commit we'll add another user that wants to write reflog entries. This requires them to call `ref_transaction_update_reflog()`, but that function is local to "refs.c". Export the function to prepare for the change. While at it, drop the `flags` field, as all callers are for now expected to use the same flags anyway. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Aug 6, 2025 at 07:54 UTC 1ffd2d41599e2b506f20430914e3bc53a0e05f3a
2 files changed +26 -18
refs.c
+11 -18
@@ -1371,27 +1371,21 @@ int ref_transaction_update(struct ref_transaction *transaction,
1371 return 0;
1372 }
1373
1374 -/*
1375 - * Similar to`ref_transaction_update`, but this function is only for adding
1376 - * a reflog update. Supports providing custom committer information. The index
1377 - * field can be utiltized to order updates as desired. When not used, the
1378 - * updates default to being ordered by refname.
1379 - */
1380 -static int ref_transaction_update_reflog(struct ref_transaction *transaction,
1381 - const char *refname,
1382 - const struct object_id *new_oid,
1383 - const struct object_id *old_oid,
1384 - const char *committer_info,
1385 - unsigned int flags,
1386 - const char *msg,
1387 - uint64_t index,
1388 - struct strbuf *err)
1374 +int ref_transaction_update_reflog(struct ref_transaction *transaction,
1375 + const char *refname,
1376 + const struct object_id *new_oid,
1377 + const struct object_id *old_oid,
1378 + const char *committer_info,
1379 + const char *msg,
1380 + uint64_t index,
1381 + struct strbuf *err)
1382 {
1383 struct ref_update *update;
1384 + unsigned int flags;
1385
1386 assert(err);
1387
1394 - flags |= REF_LOG_ONLY | REF_FORCE_CREATE_REFLOG | REF_NO_DEREF;
1388 + flags = REF_HAVE_OLD | REF_HAVE_NEW | REF_LOG_ONLY | REF_FORCE_CREATE_REFLOG | REF_NO_DEREF;
1389
1390 if (!transaction_refname_valid(refname, new_oid, flags, err))
1391 return -1;
@@ -3019,8 +3013,7 @@ static int migrate_one_reflog_entry(struct object_id *old_oid,
3013
3014 ret = ref_transaction_update_reflog(data->transaction, data->refname,
3015 new_oid, old_oid, data->sb->buf,
3022 - REF_HAVE_NEW | REF_HAVE_OLD, msg,
3023 - data->index++, data->errbuf);
3016 + msg, data->index++, data->errbuf);
3017 return ret;
3018 }
3019
refs.h
+15
@@ -795,6 +795,21 @@ int ref_transaction_update(struct ref_transaction *transaction,
795 unsigned int flags, const char *msg,
796 struct strbuf *err);
797
798 +/*
799 + * Similar to `ref_transaction_update`, but this function is only for adding
800 + * a reflog update. Supports providing custom committer information. The index
801 + * field can be utiltized to order updates as desired. When set to zero, the
802 + * updates default to being ordered by refname.
803 + */
804 +int ref_transaction_update_reflog(struct ref_transaction *transaction,
805 + const char *refname,
806 + const struct object_id *new_oid,
807 + const struct object_id *old_oid,
808 + const char *committer_info,
809 + const char *msg,
810 + uint64_t index,
811 + struct strbuf *err);
812 +
813 /*
814 * Add a reference creation to transaction. new_oid is the value that
815 * the reference should have after the update; it must not be