refs: add function to translate errors to strings

The commit 76e760b999 (refs: introduce enum-based transaction error
types, 2025-04-08) introduced enum-based transaction error types. The
refs transaction logic was also modified to propagate these errors. For
clients of the ref transaction system, it would be beneficial to provide
human readable messages for these errors.

There is already an existing mapping in 'builtin/update-ref.c', move it
to 'refs.c' as `ref_transaction_error_msg()` and use the same within the
'builtin/update-ref.c'.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Karthik Nayak
2025-05-19 11:58:06 +02:00
committed by Junio C Hamano
parent 1a8a4971cc
commit b3de3832ce
3 changed files with 26 additions and 24 deletions

5
refs.h
View File

@@ -907,6 +907,11 @@ void ref_transaction_for_each_rejected_update(struct ref_transaction *transactio
ref_transaction_for_each_rejected_update_fn cb,
void *cb_data);
/*
* Translate errors to human readable error messages.
*/
const char *ref_transaction_error_msg(enum ref_transaction_error err);
/*
* Free `*transaction` and all associated data.
*/