git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 6/7] refs: implement partial reference transaction support

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 25, 2025, 11:07 UTC
Message-ID
<Z72kjTRDNOM6iFkY@pks.im>
In-Reply-To
<20250225-245-partially-atomic-ref-updates-v2-6-cfa3236895d7@gmail.com>
On Tue, Feb 25, 2025 at 10:29:09AM +0100, Karthik Nayak wrote:
Show 20 quoted lines
> diff --git a/refs.c b/refs.c
> index f989a46a5a..243c09c368 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -2726,6 +2736,27 @@ void ref_transaction_for_each_queued_update(struct ref_transaction *transaction,
>  	}
>  }
>  
> +void ref_transaction_for_each_rejected_update(struct ref_transaction *transaction,
> +					      ref_transaction_for_each_rejected_update_fn cb,
> +					      void *cb_data)
> +{
> +	if (!(transaction->flags & REF_TRANSACTION_ALLOW_PARTIAL))
> +		return;
> +
> +	for (size_t i = 0; i < transaction->nr; i++) {
> +		struct ref_update *update = transaction->updates[i];
> +
> +		if (!update->rejection_err)
> +			continue;

This kind of proves my point that `TRANSACTION_OK` is pointless and leads to a mixture of using and not using the enum :)

Show 11 quoted lines
> diff --git a/refs/files-backend.c b/refs/files-backend.c
> index 3b0adf8bb2..d0a53c9ace 100644
> --- a/refs/files-backend.c
> +++ b/refs/files-backend.c
> @@ -2851,8 +2851,18 @@ static int files_transaction_prepare(struct ref_store *ref_store,
>  		ret = lock_ref_for_update(refs, update, transaction,
>  					  head_ref, &refnames_to_check,
>  					  err);
> -		if (ret)
> +		if (ret) {
> +			if (transaction->flags & REF_TRANSACTION_ALLOW_PARTIAL &&

Hm. If the error values were defined as a bitfield we could refactor this to not be a flag, but have a `transaction->accepted_rejections` instead that allows the caller to ask for only a subset of rejections to be accepted.

I'm not quite sure whether it is a good idea, but the logic to handle all of that could be self-contained in `ref_transaction_set_rejected()`: if it returned an error code itself, it would swallow any errors in case the transaction allows a given error, and bubble up the error again in case the error is not allowed. The function could use a rename in that case though, e.g. `ref_transaction_maybe_set_rejected()`.

Patrick
Previous: Karthik NayakNext: Karthik Nayak
Message 7 of 20 in “refs: introduce support for partial reference transactions”
  1. 0/7 refs: introduce support for partial reference transactionsKarthik Nayak, Feb 25, 2025
  2. 1/7 refs/files: remove redundant check in split_symref_update()Karthik Nayak, Feb 25, 2025
  3. 2/7 refs: move duplicate refname update check to generic layerKarthik Nayak, Feb 25, 2025
  4. 3/7 refs/files: remove duplicate duplicates checkKarthik Nayak, Feb 25, 2025
  5. 4/7 refs/reftable: extract code from the transaction preparationKarthik Nayak, Feb 25, 2025
  6. 6/7 refs: implement partial reference transaction supportKarthik Nayak, Feb 25, 2025
  7. Patrick SteinhardtFeb 25, 2025
  8. Karthik NayakMar 3, 2025
  9. Phillip WoodFeb 25, 2025
  10. Karthik NayakMar 3, 2025
  11. Phillip WoodMar 4, 2025
  12. Karthik NayakMar 5, 2025
  13. 5/7 refs: introduce enum-based transaction error typesKarthik Nayak, Feb 25, 2025
  14. Patrick SteinhardtFeb 25, 2025
  15. Karthik NayakMar 3, 2025
  16. 7/7 update-ref: add --allow-partial flag for stdin modeKarthik Nayak, Feb 25, 2025
  17. Patrick SteinhardtFeb 25, 2025
  18. Karthik NayakMar 3, 2025
  19. Phillip WoodFeb 25, 2025
  20. Karthik NayakMar 3, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.