Re: [PATCH v4 6/9] update-ref: handle rejections while adding updates
- From
Patrick Steinhardt <ps@pks.im>
- Date
- May 5, 2026, 05:52 UTC
- Message-ID
- <afmFmGo_Sg33Rv6V@pks.im>
- In-Reply-To
- <20260504-refs-move-to-generic-layer-v4-6-936ac2f0b1a3@gmail.com>
On Mon, May 04, 2026 at 07:44:10PM +0200, Karthik Nayak wrote:
Show 32 quoted lines
> diff --git a/builtin/update-ref.c b/builtin/update-ref.c
> index 5259cc7226..6355c3dd3e 100644
> --- a/builtin/update-ref.c
> +++ b/builtin/update-ref.c
> @@ -257,6 +266,31 @@ static void print_rejected_refs(const char *refname,
> strbuf_release(&sb);
> }
>
> +/*
> + * Handle transaction errors. If we're using batches updates, we want to only
> + * die for generic errors and print the remaining to the user.
> + */
> +static void handle_ref_transaction_error(const char *refname,
> + struct object_id *new_oid,
> + struct object_id *old_oid,
> + const char *new_target,
> + const char *old_target,
> + enum ref_transaction_error tx_err,
> + struct strbuf *err,
> + struct command_options *opts)
> +{
> + if (!tx_err)
> + return;
> +
> + if (tx_err != REF_TRANSACTION_ERROR_GENERIC && opts->allow_update_failures) {
> + print_rejected_refs(refname, old_oid, new_oid, old_target,
> + new_target, tx_err, err->buf, NULL);
> + return;
> + }
> +
> + die("%s", err->buf);
> +}It's a bit weird that we pass in the error message as a strbuf given that we really only care about the actual message.
Show 8 quoted lines
> @@ -644,6 +699,10 @@ static void update_refs_stdin(unsigned int flags)
> struct ref_transaction *transaction;
> int i, j;
>
> + struct command_options opts = {
> + .allow_update_failures = flags & REF_TRANSACTION_ALLOW_FAILURE,
> + };
> +Nit: stray empty line between the variable declarations.
Other than that this patch looks good to me, thanks!
Patrick