Git development
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org, toon@iotcl.com
Subject: Re: [PATCH v4 6/9] update-ref: handle rejections while adding updates
Date: Tue, 5 May 2026 07:52:24 +0200	[thread overview]
Message-ID: <afmFmGo_Sg33Rv6V@pks.im> (raw)
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:
> 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.

> @@ -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

  reply	other threads:[~2026-05-05  5:52 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20 10:11 [PATCH 0/8] refs: move some of the generic logic out of the backends Karthik Nayak
2026-04-20 10:11 ` [PATCH 1/8] refs: remove unused typedef 'ref_transaction_commit_fn' Karthik Nayak
2026-04-22 11:15   ` Patrick Steinhardt
2026-04-22 12:20     ` Karthik Nayak
2026-04-20 10:12 ` [PATCH 2/8] refs: extract out reflog config to generic layer Karthik Nayak
2026-04-22 11:15   ` Patrick Steinhardt
2026-04-22 13:13     ` Karthik Nayak
2026-04-20 10:12 ` [PATCH 3/8] refs: return `ref_transaction_error` from `ref_transaction_update()` Karthik Nayak
2026-04-22 11:15   ` Patrick Steinhardt
2026-04-22 13:14     ` Karthik Nayak
2026-04-20 10:12 ` [PATCH 4/8] update-ref: move `print_rejected_refs()` up Karthik Nayak
2026-04-22 11:15   ` Patrick Steinhardt
2026-04-22 13:16     ` Karthik Nayak
2026-04-20 10:12 ` [PATCH 5/8] update-ref: handle rejections while adding updates Karthik Nayak
2026-04-22 11:15   ` Patrick Steinhardt
2026-04-22 14:13     ` Karthik Nayak
2026-04-20 10:12 ` [PATCH 6/8] refs: move object parsing to the generic layer Karthik Nayak
2026-04-22 11:15   ` Patrick Steinhardt
2026-04-22 15:03     ` Karthik Nayak
2026-04-20 10:12 ` [PATCH 7/8] refs: add peeled object ID to the `ref_update` struct Karthik Nayak
2026-04-20 10:12 ` [PATCH 8/8] refs: use peeled tag values in reference backends Karthik Nayak
2026-04-23  8:40 ` [PATCH v2 0/9] refs: move some of the generic logic out of the backends Karthik Nayak
2026-04-23  8:40   ` [PATCH v2 1/9] refs: remove unused typedef 'ref_transaction_commit_fn' Karthik Nayak
2026-04-23  8:40   ` [PATCH v2 2/9] refs: introduce `ref_store_init_options` Karthik Nayak
2026-04-23  8:52     ` Patrick Steinhardt
2026-04-24  9:34       ` Karthik Nayak
2026-04-23  8:40   ` [PATCH v2 3/9] refs: extract out reflog config to generic layer Karthik Nayak
2026-04-23  8:52     ` Patrick Steinhardt
2026-04-23  8:40   ` [PATCH v2 4/9] refs: return `ref_transaction_error` from `ref_transaction_update()` Karthik Nayak
2026-04-24 11:01     ` Toon Claes
2026-04-23  8:40   ` [PATCH v2 5/9] update-ref: move `print_rejected_refs()` up Karthik Nayak
2026-04-23  8:40   ` [PATCH v2 6/9] update-ref: handle rejections while adding updates Karthik Nayak
2026-04-23  8:52     ` Patrick Steinhardt
2026-04-24  9:35       ` Karthik Nayak
2026-04-24 11:22     ` Toon Claes
2026-04-27  8:47       ` Karthik Nayak
2026-04-23  8:40   ` [PATCH v2 7/9] refs: move object parsing to the generic layer Karthik Nayak
2026-04-24 12:06     ` Toon Claes
2026-04-27  9:32       ` Karthik Nayak
2026-04-23  8:40   ` [PATCH v2 8/9] refs: add peeled object ID to the `ref_update` struct Karthik Nayak
2026-04-24 16:44     ` Toon Claes
2026-04-27  9:33       ` Karthik Nayak
2026-04-23  8:40   ` [PATCH v2 9/9] refs: use peeled tag values in reference backends Karthik Nayak
2026-04-27 10:42 ` [PATCH v3 0/9] refs: move some of the generic logic out of the backends Karthik Nayak
2026-04-27 10:42   ` [PATCH v3 1/9] refs: remove unused typedef 'ref_transaction_commit_fn' Karthik Nayak
2026-04-27 10:42   ` [PATCH v3 2/9] refs: introduce `ref_store_init_options` Karthik Nayak
2026-04-27 10:42   ` [PATCH v3 3/9] refs: extract out reflog config to generic layer Karthik Nayak
2026-04-27 10:42   ` [PATCH v3 4/9] refs: return `ref_transaction_error` from `ref_transaction_update()` Karthik Nayak
2026-04-27 10:42   ` [PATCH v3 5/9] update-ref: move `print_rejected_refs()` up Karthik Nayak
2026-04-27 10:42   ` [PATCH v3 6/9] update-ref: handle rejections while adding updates Karthik Nayak
2026-04-29 12:24     ` Toon Claes
2026-04-30  9:52       ` Karthik Nayak
2026-04-27 10:42   ` [PATCH v3 7/9] refs: move object parsing to the generic layer Karthik Nayak
2026-04-27 10:42   ` [PATCH v3 8/9] refs: add peeled object ID to the `ref_update` struct Karthik Nayak
2026-04-27 10:42   ` [PATCH v3 9/9] refs: use peeled tag values in reference backends Karthik Nayak
2026-05-04 17:44 ` [PATCH v4 0/9] refs: move some of the generic logic out of the backends Karthik Nayak
2026-05-04 17:44   ` [PATCH v4 1/9] refs: remove unused typedef 'ref_transaction_commit_fn' Karthik Nayak
2026-05-04 17:44   ` [PATCH v4 2/9] refs: introduce `ref_store_init_options` Karthik Nayak
2026-05-04 17:44   ` [PATCH v4 3/9] refs: extract out reflog config to generic layer Karthik Nayak
2026-05-04 17:44   ` [PATCH v4 4/9] refs: return `ref_transaction_error` from `ref_transaction_update()` Karthik Nayak
2026-05-04 17:44   ` [PATCH v4 5/9] update-ref: move `print_rejected_refs()` up Karthik Nayak
2026-05-04 17:44   ` [PATCH v4 6/9] update-ref: handle rejections while adding updates Karthik Nayak
2026-05-05  5:52     ` Patrick Steinhardt [this message]
2026-05-05  8:23       ` Karthik Nayak
2026-05-06 19:44         ` Toon Claes
2026-05-04 17:44   ` [PATCH v4 7/9] refs: move object parsing to the generic layer Karthik Nayak
2026-05-04 17:44   ` [PATCH v4 8/9] refs: add peeled object ID to the `ref_update` struct Karthik Nayak
2026-05-04 17:44   ` [PATCH v4 9/9] refs: use peeled tag values in reference backends Karthik Nayak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=afmFmGo_Sg33Rv6V@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=karthik.188@gmail.com \
    --cc=toon@iotcl.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox