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

Re: [PATCH v2 08/11] setup: refactor how we configure the ref storage format

From
Patrick Steinhardt <ps@pks.im>
Date
Sep 9, 2026, 09:23 UTC
Message-ID
<aqEllv3TicOLB7g0@pks.im>
In-Reply-To
<be1c7560-0da6-436e-8f46-073e95bcad07@gmail.com>
On Wed, Sep 09, 2026 at 01:30:55PM +0530, Kaartic Sivaraam wrote:
Show 48 quoted lines
> On 9/7/26 16:48, Patrick Steinhardt wrote:
> > diff --git a/setup.c b/setup.c
> > index 3be7dac452..38fa5e854c 100644
> > --- a/setup.c
> > +++ b/setup.c
> > @@ -2761,40 +2761,65 @@ static void repository_format_configure(struct repository_format *repo_fmt,
> > 
> > ... snip ...
> > -
> > -	ref_backend_uri = getenv(GIT_REFERENCE_BACKEND_ENVIRONMENT);
> > -	if (ref_backend_uri) {
> > -		enum ref_storage_format format;
> > -		char *payload;
> > -
> > -		format = ref_storage_format_by_uri(ref_backend_uri, &payload);
> > -		if (format == REF_STORAGE_FORMAT_UNKNOWN)
> > -			die(_("unknown ref storage format: '%s'"), ref_backend_uri);
> > -
> > -		repo_fmt->ref_storage_format = format;
> > -		free(repo_fmt->ref_storage_payload);
> > -		repo_fmt->ref_storage_payload = payload;
> > -	}
> > +	/*
> > +	 * If we have a preexisting repository we need to verify that its
> > +	 * current ref storage format does not change.
> > +	 */
> > +	if (repo_fmt->version >= 0) {
> > +		if (ref_storage_format != repo_fmt->ref_storage_format)
> > +			die(_("attempt to reinitialize repository with different reference storage format"));
> > +		if ((ref_storage_payload || repo_fmt->ref_storage_payload) &&
> > +		    strcmp(ref_storage_payload ? ref_storage_payload : "",
> > +			   repo_fmt->ref_storage_payload ? repo_fmt->ref_storage_payload : ""))
> 
> Rather than a strcmp, wouldn't it be ideal to do the path comparison using
> strbuf_realpath to make sure we avoid similar paths like the following from
> failing during reinitialization?
> 
>   $ mkdir store
>   $ git init --ref-storage-format="files://$PWD/store" r1
>   Initialized empty Git repository in .../r1/.git/
>   $ git init --ref-storage-format="files://$PWD/store" r1
>   Reinitialized existing Git repository in .../r1/.git/
>   $ git init --ref-storage-format="files://$PWD/./store" r1
>   fatal: attempt to reinitialize repository with different reference storage
> payload
> 
> This matches with how we actually make use of the path at runtime in the
> refs_compute_filesystem_location function in refs.c.

No, because that'd assume that the payload even is a path. But in theory, it could be anything, like for example a database host to connect to. In `refs_compute_filesystem_location()` it's a different thing though as that call happens inside the backends themselves, and they know what kind of payload to expect.

Patrick
Previous: Kaartic SivaraamNext: Patrick Steinhardt
Message 20 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.