Re: Mirror repositories for submodules
- From
Matt Hunter <m@lfurio.us>
- Date
- Jun 5, 2026, 09:34 UTC
- Message-ID
- <DJ10HH5HZF0E.3000F6WUQ1M08@lfurio.us>
- In-Reply-To
- <87pl25r3tz.fsf@emailplus.org>
On Fri Jun 5, 2026 at 12:47 AM EDT, Benson Muite wrote:
Show 7 quoted lines
> > For submodules, the metadata consists of the url of the repository to > clone from. One could have a list of absolute URLs. The default would > be to assume that the URLs are tried in order, and if a URL times out, > the next one would be tried. One may want to change the default > ordering as a user setting, or do a ping test to get obtain content from > the closest repository.
Another idea is for the client to attempt in a random order as a kind of load balancing.
Show 16 quoted lines
> > As an example, for linphone-desktop, the first part of the .gitmodules > file contains: > > [submodule "linphone-sdk"] > path = external/linphone-sdk > url = https://gitlab.linphone.org/BC/public/linphone-sdk.git > [submodule "external/google/gn"] > > This could be updated to > > [submodule "linphone-sdk"] > path = external/linphone-sdk > url = https://gitlab.linphone.org/BC/public/linphone-sdk.git > url = https://github.com/BelledonneCommunications/linphone-sdk.git > [submodule "external/google/gn"]
Relevant to Junio's earlier comment about aiming for a general solution:
It looks like the remote URL configuration already supports multiple URLs per a single entry. It's just that git only considers the first in the list for fetching, and will push to all.
Your proposed change to .gitmodules may be used to initialize the list of URLs for a cloned submodule's (single) initial remote? At this point, any kind of mirror management logic could generically operate on each remote's URL list.
From git-config(1):
remote.<name>.url
The URL of a remote repository. See git-fetch(1) or git-push(1).
A configured remote can have multiple URLs; in this case the first
is used for fetching, and all are used for pushing (assuming no
remote.<name>.pushurl is defined). Setting this key to the empty
string clears the list of urls, allowing you to override earlier
config.From gitmodules(5):
submodule.<name>.url
Defines a URL from which the submodule repository can be cloned.
This may be either an absolute URL ready to be passed to
git-clone(1) or (if it begins with ./ or ../) a location relative
to the superproject’s origin repository.Note that the submodule format seems to explicitly support only a single value right now. Of course, I am assuming that the implementation matches the documentation.