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

Re: [PATCH v2 7/7] update-ref: add --allow-partial flag for stdin mode

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 25, 2025, 11:08 UTC
Message-ID
<Z72klAEpQ0-cWCGa@pks.im>
In-Reply-To
<20250225-245-partially-atomic-ref-updates-v2-7-cfa3236895d7@gmail.com>
On Tue, Feb 25, 2025 at 10:29:10AM +0100, Karthik Nayak wrote:
Show 29 quoted lines
> diff --git a/Documentation/git-update-ref.adoc b/Documentation/git-update-ref.adoc
> index 9e6935d38d..fc73f1d8aa 100644
> --- a/Documentation/git-update-ref.adoc
> +++ b/Documentation/git-update-ref.adoc
> @@ -7,8 +7,10 @@ git-update-ref - Update the object name stored in a ref safely
>  
>  SYNOPSIS
>  --------
> -[verse]
> -'git update-ref' [-m <reason>] [--no-deref] (-d <ref> [<old-oid>] | [--create-reflog] <ref> <new-oid> [<old-oid>] | --stdin [-z])
> +[synopsis]
> +git update-ref [-m <reason>] [--no-deref] -d <ref> [<old-oid>]
> +	       [-m <reason>] [--no-deref] [--create-reflog] <ref> <new-oid> [<old-oid>]
> +               [-m <reason>] [--no-deref] --stdin [-z] [--allow-partial]
>  
>  DESCRIPTION
>  -----------
> @@ -57,6 +59,17 @@ performs all modifications together.  Specify commands of the form:
>  With `--create-reflog`, update-ref will create a reflog for each ref
>  even if one would not ordinarily be created.
>  
> +With `--allow-partial`, update-ref continues executing the transaction even if
> +some updates fail due to invalid or incorrect user input, applying only the
> +successful updates. Errors resulting from user-provided input are treated as
> +non-system-related and do not cause the entire transaction to be aborted.
> +However, system-related errors—such as I/O failures or memory issues—will still
> +result in a full failure. Additionally, errors like F/D conflicts are batched
> +for performance optimization and will also cause a full failure. Any failed
> +updates will be reported in the following format:

Shouldn't it be possible to detect F/D conflicts though and not abort the transaction? If we want to make use of partial transactions in the context of git-fetch(1) and/or git-receive-pack(1) we would have to handle them.

Show 42 quoted lines
> diff --git a/builtin/update-ref.c b/builtin/update-ref.c
> index 1d541e13ad..b03b40eacb 100644
> --- a/builtin/update-ref.c
> +++ b/builtin/update-ref.c
> @@ -565,6 +566,54 @@ static void parse_cmd_abort(struct ref_transaction *transaction,
>  	report_ok("abort");
>  }
>  
> +static void print_rejected_refs(const char *refname,
> +				const struct object_id *old_oid,
> +				const struct object_id *new_oid,
> +				const char *old_target,
> +				const char *new_target,
> +				enum transaction_error err,
> +				void *cb_data UNUSED)
> +{
> +	struct strbuf sb = STRBUF_INIT;
> +	char space = ' ';
> +	const char *reason = "";
> +
> +	switch (err) {
> +	case TRANSACTION_NAME_CONFLICT:
> +		reason = _("refname conflict");
> +		break;
> +	case TRANSACTION_CREATE_EXISTS:
> +		reason = _("reference already exists");
> +		break;
> +	case TRANSACTION_NONEXISTENT_REF:
> +		reason = _("reference does not exist");
> +		break;
> +	case TRANSACTION_INCORRECT_OLD_VALUE:
> +		reason = _("incorrect old value provided");
> +		break;
> +	case TRANSACTION_INVALID_NEW_VALUE:
> +		reason = _("invalid new value provided");
> +		break;
> +	case TRANSACTION_EXPECTED_SYMREF:
> +		reason = _("expected symref but found regular ref");
> +		break;
> +	default:
> +		reason = _("unkown failure");
> +	}

As git-update-ref(1) is part of plumbing we don't want to translate those messages.

Patrick
Previous: Karthik NayakNext: Karthik Nayak
Message 17 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.