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

Re: [PATCH 0/2] refs: allow setting the reference directory

From
Patrick Steinhardt <ps@pks.im>
Date
Dec 1, 2025, 13:19 UTC
Message-ID
<aS2V4TKeS4V_oxAb@pks.im>
In-Reply-To
<xmqq34651ie5.fsf@gitster.g>
On Sat, Nov 22, 2025 at 08:29:22PM -0800, Junio C Hamano wrote:
Show 24 quoted lines
> Karthik Nayak <karthik.188@gmail.com> writes:
> 
> > While Git allows users to select different reference backends, unlike
> > with objects, there is no flexibility in selecting the reference
> > directory. Currently, the reference format is obtained from the config
> > of the repository and the reference directory is set to the $GIT_DIR.
> 
> I actually am not sure if I like the proposed environment variable.
> 
> The proposal is based on an assumption that any reference backend
> should be able to move their backing store anywhere, and they should
> be able to express the location of their backing store as a single
> string <path>.  For a new backend, "where is your backing store" may
> not even be a question that does not make much sense (as "somewhere
> in the cloud that you do not even have to know" is certainly
> possible), and even for a new backend design that does allow such a
> question to have a meaningful answer, this "you have to be able to
> use a random place specified by this environment variable as your
> backing storage" is an additional requirement that its implementors
> may not need to satisfy in order to please their user base.
> 
> For reftable and files backends, these assumptions may be true, but
> then it is not too cumbersome if these stay to be backend specific,
> as there are only two backends.

I think it's a reasonable assumption to make that the path _can_ be represented as a single string. For now, we don't really require any configuration for the backend in the first place. So all you need to do is to say:

    [extension]
    refStorage = reftable

This implicitly identifies the location of the backend, too, as we derive it from the commondir/gitdir. As you say that's sufficient for the "files" and "reftable" backends, but it may be insufficient for other backends.

Suppose that we for example have a Postgres database to store data. It's clearly not sufficient to specify "extension.refStorage=postgres", as that wouldn't give you enough information to also know how to connect to the database.

It's a problem I have been thinking about quite a lot in the context of pluggable object databases, as well. Ultimately, the solution I arrived at is to extend the extension format itself. For pluggable ODBs this would look like this:

    [extension]
    objectStorage = postgres://127.0.0.1:5432?database=myrepo

This is similar to a normal URI with a schema: everything before the "://" identifies the format that is to be used, and everything after is then passed as-is to the backend itself. I think this should give us enough flexibility for any future formats and it is easy enough to configure. The added benefit is that this can also work in contexts like the GIT_OBJECT_DIRECTORY and GIT_ALTERNATE_OBJECT_DIRECTORIES environment variables, even though their naming is off now.

For the reference storage I think we should be moving into a similar direction. Sure, for the current formats that we know its sufficient to only specify their directory. But I think we should treat the directory as an opaque string and then let the reference backend handle it, same as with the proposed format for object databases:

    # A schema-only variable will be treated as if we specified the
    # common directory.
    [extension]
    refStorage = reftable
    # It's also possible to explicitly specify a different location for
    # the backend.
    [extension]
    refStorage = reftable:///foo/bar
    # And same as above, we can also specify non-locations.
    [extension]
    refStorage = postgres://127.0.0.1:5432?database=myrepo

As said, the important thing here is that the reference backends get the string after the schema as opaque blobs that they can self-interpret.

Show 7 quoted lines
> So I dunno.  In addition, if this is designed to help migration
> (which is the impression I am getting from the cover letter
> description), don't you need a way to specify more than one (i.e.,
> source to migrate from and destination to migrate to)?  With a
> single GIT_REF_URI, it would not be obvious what it refers to,
> whether it is an additional place to write to, to read from, or
> something completely unrelated.  For example ...

I think we cannot easily retrofit handling of multiple refdbs into Git at this point in time anymore. The way to drive this would be that we have two processes:

  - One `git refs list` process in the repository that uses the old
    format.
  - One `git update-ref --stdin` process in the repository that uses the
    new format specified via GIT_REF_URI.

This allows us to do an online migration of data into a separate ref store.

Show 31 quoted lines
> > This patch series adds a new ENV variable 'GIT_REF_URI' which takes the
> > reference backend and path in a URI form:
> >
> >     <reference_backend>://<path>
> >
> > For e.g. 'reftable:///foo' or 'files://$GIT_DIR/ref_migration.0xBsa0'.
> >
> > One use case for this is migration between different backends. On the
> > server side, migrating from the files backend to the newly introduced
> > reftable backend can be achieved by running 'git refs migrate'. However,
> > for large repositories with millions of references, this migration can
> > take from seconds to minutes.
> >
> > We could make the migration non-blocking by running the migration in the
> > background and capturing and replaying updates to both backends. This
> > would require Git to support writing references to different reference
> > backends and paths.
> 
> ... I am reading that the above is saying that the system will write
> to whatever reference backend specified in the extension.refStorage,
> plus also where GIT_REF_URI points at, but if that is the way how
> the mechanism works, the variable should be named more specific to
> what it does, no?  It is not just a random "REF URI"; it is an
> additional ref backend that the updates are dumped to.  Maybe there
> would be a different use case where you may want to read from two
> reference backends, and you'd need to specify the secondary one with
> an environment variable, but if the system behaves one specific way
> for GIT_REF_URI (say, all updates are also copied to this additional
> ref backend at the specified ref backing store), a different
> environment variable name needs to be chosen to serve such a
> different use case, no?

Truth be told, I'm not realy a huge fan of the name, either. But as said, I don't think we can easily "overlay" multiple refdbs, as it would lead to various different questions due to our hierarchical layout of references.

That being said, I personally would prefer `GIT_REFERENCE_BACKEND` as variable name that accepts exactly the same kind of strings as the `extension.refStorage` values I have proposed above.

Thanks!
Patrick
Previous: Junio C HamanoNext: Junio C Hamano
Message 20 of 101 in “refs: allow setting the reference directory”
  1. 0/2 refs: allow setting the reference directoryKarthik Nayak, Nov 19, 2025
  2. 1/2 refs: support obtaining ref_store for given dirKarthik Nayak, Nov 19, 2025
  3. Justin ToblerNov 20, 2025
  4. Karthik NayakNov 21, 2025
  5. 2/2 refs: add GIT_REF_URI to specify reference backend and directoryKarthik Nayak, Nov 19, 2025
  6. Eric SunshineNov 19, 2025
  7. Karthik NayakNov 19, 2025
  8. Jean-Noël AvilaNov 20, 2025
  9. Karthik NayakNov 21, 2025
  10. Justin ToblerNov 20, 2025
  11. Karthik NayakNov 24, 2025
  12. Toon ClaesNov 21, 2025
  13. Junio C HamanoNov 21, 2025
  14. Karthik NayakNov 24, 2025
  15. Toon ClaesNov 26, 2025
  16. Karthik NayakNov 24, 2025
  17. Patrick SteinhardtDec 1, 2025
  18. Karthik NayakDec 2, 2025
  19. Junio C HamanoNov 23, 2025
  20. Patrick SteinhardtDec 1, 2025
  21. Junio C HamanoDec 2, 2025
  22. Karthik NayakDec 2, 2025
  23. 0/4 refs: allow setting the reference directoryKarthik Nayak, Feb 2, 2026
  24. 1/4 refs: allow reference location in refstorage configKarthik Nayak, Feb 2, 2026
  25. Patrick SteinhardtFeb 6, 2026
  26. Karthik NayakFeb 9, 2026
  27. 2/4 refs: extract out `refs_create_refdir_stubs()`Karthik Nayak, Feb 2, 2026
  28. Patrick SteinhardtFeb 6, 2026
  29. Karthik NayakFeb 9, 2026
  30. 3/4 refs: parse and use the reference storage payloadKarthik Nayak, Feb 2, 2026
  31. Patrick SteinhardtFeb 6, 2026
  32. Karthik NayakFeb 9, 2026
  33. 4/4 refs: add GIT_REFERENCE_BACKEND to specify reference backendKarthik Nayak, Feb 2, 2026
  34. Patrick SteinhardtFeb 6, 2026
  35. Karthik NayakFeb 9, 2026
  36. Patrick SteinhardtFeb 6, 2026
  37. Junio C HamanoFeb 6, 2026
  38. Karthik NayakFeb 9, 2026
  39. 0/4 refs: allow setting the reference directoryKarthik Nayak, Feb 9, 2026
  40. 1/4 refs: extract out `refs_create_refdir_stubs()`Karthik Nayak, Feb 9, 2026
  41. 2/4 refs: forward and use the reference storage payloadKarthik Nayak, Feb 9, 2026
  42. Patrick SteinhardtFeb 9, 2026
  43. Karthik NayakFeb 10, 2026
  44. Jeff KingFeb 10, 2026
  45. Karthik NayakFeb 13, 2026
  46. Jeff KingFeb 15, 2026
  47. 3/4 refs: allow reference location in refstorage configKarthik Nayak, Feb 9, 2026
  48. Patrick SteinhardtFeb 9, 2026
  49. Karthik NayakFeb 10, 2026
  50. Jeff KingFeb 10, 2026
  51. Karthik NayakFeb 11, 2026
  52. 4/4 refs: add GIT_REFERENCE_BACKEND to specify reference backendKarthik Nayak, Feb 9, 2026
  53. Patrick SteinhardtFeb 9, 2026
  54. Junio C HamanoFeb 9, 2026
  55. Karthik NayakFeb 10, 2026
  56. Junio C HamanoFeb 10, 2026
  57. 0/6 refs: allow setting the reference directoryKarthik Nayak, Feb 14, 2026
  58. 1/6 setup: don't modify repo in `create_reference_database()`Karthik Nayak, Feb 14, 2026
  59. Patrick SteinhardtFeb 17, 2026
  60. Karthik NayakFeb 17, 2026
  61. 2/6 refs: extract out `refs_create_refdir_stubs()`Karthik Nayak, Feb 14, 2026
  62. 3/6 refs: receive and use the reference storage payloadKarthik Nayak, Feb 14, 2026
  63. Patrick SteinhardtFeb 17, 2026
  64. Karthik NayakFeb 17, 2026
  65. 4/6 refs: move out stub modification to generic layerKarthik Nayak, Feb 14, 2026
  66. Patrick SteinhardtFeb 17, 2026
  67. Karthik NayakFeb 17, 2026
  68. Toon ClaesFeb 18, 2026
  69. Karthik NayakFeb 19, 2026
  70. 5/6 refs: allow reference location in refstorage configKarthik Nayak, Feb 14, 2026
  71. 6/6 refs: add GIT_REFERENCE_BACKEND to specify reference backendKarthik Nayak, Feb 14, 2026
  72. Patrick SteinhardtFeb 17, 2026
  73. Karthik NayakFeb 17, 2026
  74. Patrick SteinhardtFeb 17, 2026
  75. Toon ClaesFeb 18, 2026
  76. Karthik NayakFeb 19, 2026
  77. 0/6 refs: allow setting the reference directoryKarthik Nayak, Feb 23, 2026
  78. 1/6 setup: don't modify repo in `create_reference_database()`Karthik Nayak, Feb 23, 2026
  79. 2/6 refs: extract out `refs_create_refdir_stubs()`Karthik Nayak, Feb 23, 2026
  80. 3/6 refs: move out stub modification to generic layerKarthik Nayak, Feb 23, 2026
  81. 4/6 refs: receive and use the reference storage payloadKarthik Nayak, Feb 23, 2026
  82. 5/6 refs: allow reference location in refstorage configKarthik Nayak, Feb 23, 2026
  83. Kristoffer HaugsbakkFeb 23, 2026
  84. Karthik NayakFeb 24, 2026
  85. Kristoffer HaugsbakkFeb 24, 2026
  86. Karthik NayakFeb 24, 2026
  87. 6/6 refs: add GIT_REFERENCE_BACKEND to specify reference backendKarthik Nayak, Feb 23, 2026
  88. Toon ClaesFeb 25, 2026
  89. Karthik NayakFeb 25, 2026
  90. Patrick SteinhardtFeb 23, 2026
  91. Karthik NayakFeb 23, 2026
  92. Junio C HamanoFeb 23, 2026
  93. Karthik NayakFeb 25, 2026
  94. 0/6 refs: allow setting the reference directoryKarthik Nayak, Feb 25, 2026
  95. 1/6 setup: don't modify repo in `create_reference_database()`Karthik Nayak, Feb 25, 2026
  96. 2/6 refs: extract out `refs_create_refdir_stubs()`Karthik Nayak, Feb 25, 2026
  97. 3/6 refs: move out stub modification to generic layerKarthik Nayak, Feb 25, 2026
  98. 4/6 refs: receive and use the reference storage payloadKarthik Nayak, Feb 25, 2026
  99. 5/6 refs: allow reference location in refstorage configKarthik Nayak, Feb 25, 2026
  100. Junio C HamanoFeb 25, 2026
  101. 6/6 refs: add GIT_REFERENCE_BACKEND to specify reference backendKarthik Nayak, Feb 25, 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.