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

Re: [PATCH v2 07/11] refs: expose function to parse reference URIs

From
Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Date
Sep 8, 2026, 13:47 UTC
Message-ID
<54fc5f97-a8ed-4927-8b48-1b4c3c7b413a@gmail.com>
In-Reply-To
<20260907-b4-pks-unify-ref-storage-format-v2-7-6733c90ca5b0@pks.im>
On 9/7/26 16:48, Patrick Steinhardt wrote:
Show 6 quoted lines
> In the next commit we're about to add more sites that want to parse a
> reference backends URI into a format and payload. Expose a new function
> `ref_storage_format_by_uri()` that enables this.
> 
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
Show 27 quoted lines
>   enum ref_transaction_error {
>   	/* Default error code */
>   	REF_TRANSACTION_ERROR_GENERIC = -1,
> diff --git a/setup.c b/setup.c
> index dfe05d9a03..3be7dac452 100644
> --- a/setup.c
> +++ b/setup.c
>
> @@ -2069,16 +2051,12 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)
>   			 */
>   			ref_backend_uri = getenv(GIT_REFERENCE_BACKEND_ENVIRONMENT);
>   			if (ref_backend_uri) {
> -				char *format;
> -
> -				free(discovery.format.ref_storage_payload);
> -
> -				parse_reference_uri(ref_backend_uri, &format, &discovery.format.ref_storage_payload);
> -				discovery.format.ref_storage_format = ref_storage_format_by_name(format);
> +				FREE_AND_NULL(discovery.format.ref_storage_payload);
> +				discovery.format.ref_storage_format =
> +					ref_storage_format_by_uri(ref_backend_uri,
> +								  &discovery.format.ref_storage_payload);
>   				if (discovery.format.ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)
> -					die(_("unknown ref storage format: '%s'"), format);
> -
> -				free(format);
> +					die(_("unknown ref storage format: '%s'"), ref_backend_uri);

If I'm not mistaken, we have now started printing the whole ref storage backend configuration rather than just the name. I could see that we don't actually have any variable that returns just the name part after the refactor. I could also understand that we can't always expect a '://' in the GIT_REF_STORAGE_FORMAT configuration so printing the whole configuration may make sense. But could we possibly improve the error message a bit? May be phrase it as follows:

   $ GIT_REF_STORAGE_FORMAT=garbage://hello-world ./git status
   fatal: invalid ref storage format configuration: 'garbage://hello-world'
Show 15 quoted lines
> @@ -2806,18 +2784,16 @@ static void repository_format_configure(struct repository_format *repo_fmt,
>   
>   	ref_backend_uri = getenv(GIT_REFERENCE_BACKEND_ENVIRONMENT);
>   	if (ref_backend_uri) {
> -		char *backend, *payload;
>   		enum ref_storage_format format;
> +		char *payload;
>   
> -		parse_reference_uri(ref_backend_uri, &backend, &payload);
> -		format = ref_storage_format_by_name(backend);
> +		format = ref_storage_format_by_uri(ref_backend_uri, &payload);
>   		if (format == REF_STORAGE_FORMAT_UNKNOWN)
> -			die(_("unknown ref storage format: '%s'"), backend);
> +			die(_("unknown ref storage format: '%s'"), ref_backend_uri);
>   
Ditto here.

-- Sivaraam

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 16 of 27 in “Fix inconsistent ref storage format terminology”
  1. 00/11 Fix inconsistent ref storage format terminologyPatrick Steinhardt, Sep 7, 2026
  2. 01/11 builtin/init: rename "--ref-format=" to "--ref-storage-format="Patrick Steinhardt, Sep 7, 2026
  3. Kaartic SivaraamSep 8, 2026
  4. Patrick SteinhardtSep 9, 2026
  5. Kaartic SivaraamSep 9, 2026
  6. 02/11 builtin/clone: rename "--ref-format=" to "--ref-storage-format="Patrick Steinhardt, Sep 7, 2026
  7. Kaartic SivaraamSep 8, 2026
  8. Patrick SteinhardtSep 9, 2026
  9. 03/11 builtin/refs: rename "--ref-format=" to "--ref-storage-format="Patrick Steinhardt, Sep 7, 2026
  10. Kaartic SivaraamSep 8, 2026
  11. Patrick SteinhardtSep 9, 2026
  12. 04/11 builtin/submodule: rename "--ref-format=" to "--ref-storage-format="Patrick Steinhardt, Sep 7, 2026
  13. 05/11 builtin/rev-parse: rename "--show-ref-format" to "--show-ref-storage-format"Patrick Steinhardt, Sep 7, 2026
  14. 06/11 help: rename "default-ref-format" to "default-ref-storage-format"Patrick Steinhardt, Sep 7, 2026
  15. 07/11 refs: expose function to parse reference URIsPatrick Steinhardt, Sep 7, 2026
  16. Kaartic SivaraamSep 8, 2026
  17. Patrick SteinhardtSep 9, 2026
  18. 08/11 setup: refactor how we configure the ref storage formatPatrick Steinhardt, Sep 7, 2026
  19. Kaartic SivaraamSep 9, 2026
  20. Patrick SteinhardtSep 9, 2026
  21. 09/11 setup: rename ref storage format environment variablesPatrick Steinhardt, Sep 7, 2026
  22. Kaartic SivaraamSep 9, 2026
  23. Patrick SteinhardtSep 9, 2026
  24. 10/11 setup: rename "init.defaultRefFormat" to "init.defaultRefStorageFormat"Patrick Steinhardt, Sep 7, 2026
  25. 11/11 setup: allow "git init --ref-storage-format=" to specify a payloadPatrick Steinhardt, Sep 7, 2026
  26. Kaartic SivaraamSep 9, 2026
  27. Patrick SteinhardtSep 9, 2026

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.