refs: support rejection in batch updates during F/D checks

The `refs_verify_refnames_available()` is used to batch check refnames
for F/D conflicts. While this is the more performant alternative than
its individual version, it does not provide rejection capabilities on a
single update level. For batched updates, this would mean a rejection of
the entire transaction whenever one reference has a F/D conflict.

Modify the function to call `ref_transaction_maybe_set_rejected()` to
check if a single update can be rejected. Since this function is only
internally used within 'refs/' and we want to pass in a `struct
ref_transaction *` as a variable. We also move and mark
`refs_verify_refnames_available()` to 'refs-internal.h' to be an
internal function.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Karthik Nayak
2025-04-08 10:51:11 +02:00
committed by Junio C Hamano
parent 23fc8e4f61
commit 31726bb90d
5 changed files with 76 additions and 27 deletions

View File

@@ -806,4 +806,20 @@ enum ref_transaction_error ref_update_check_old_target(const char *referent,
*/
int ref_update_expects_existing_old_ref(struct ref_update *update);
/*
* Same as `refs_verify_refname_available()`, but checking for a list of
* refnames instead of only a single item. This is more efficient in the case
* where one needs to check multiple refnames.
*
* If using batched updates, then individual updates are marked rejected,
* reference backends are then in charge of not committing those updates.
*/
enum ref_transaction_error refs_verify_refnames_available(struct ref_store *refs,
const struct string_list *refnames,
const struct string_list *extras,
const struct string_list *skip,
struct ref_transaction *transaction,
unsigned int initial_transaction,
struct strbuf *err);
#endif /* REFS_REFS_INTERNAL_H */