Use relative URLs for git submodules #4879
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR closes #1925 and maybe some other duplicate issues where people are complaining about not knowing how to clone submodules. It also removes the need for this section in the Wiki.
It does so by modifying the submodule configuration to inherit the parent repository's cloning method.
Feel free to close this if there's no appetite to mess with submodules at the moment!
Implementation
Git actually allows submodule URLs to be specified relative to the repo's upstream URL. For example, let's say I have a GitHub repo
OpenEmu/repo
with a submodule configured like:If I clone
git clone https://github.com/OpenEmu/repo
and initialize the submodule, this would usehttps://github.com/OpenEmu/dep.git
as the submodule URL. Meanwhile, if I were to usegit clone git@github.com:OpenEmu/repo
, this would usegit@github.com/OpenEmu/dep.git
. That is, this approach is agnostic between HTTPS and SSH cloning, and just inherits the parent repo's upstream URL!Notes
.gitmodules
, make sure to rungit submodule sync
to actually update those URLs in the submodule repositories. This would only need to happen when changing between this and other branches and if this branch gets merged.github.com
) as the parent repo. Submodules not on GitHub would need to be specified via an absolute URL. Currently all submodules are GitHub repos, so non-issue.url = ../../OpenEmu/dep.git
, I could have just as easily seturl = ../dep.git
. The reason to fully qualify the repo owner/name is because it ensures that the URLs are correct for forks -- when I fork OpenEmu intorpadaki/OpenEmu
, I still want to useOpenEmu/XXX.git
repos for the submodules, notrpadaki/XXX.git
.