refs: allow setting the reference directory

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.

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.

The first commit adds the required changes to create a 'ref_store' for a given path. The second commit parses the URI if available when creating the main ref store.

This is based on top of 9a2fb147 (Git 2.52, 2025-11-17).

Closes: #618

Edited by Karthik Nayak

Merge request reports

Loading