-
Notifications
You must be signed in to change notification settings - Fork 284
Description
The Remote.IsValidURL()
method is too restrictive, as it allows only the following types of URLs:
- https
- ssh
- Absolute path to existing (local) folder whose name ends with
.git
From the docs for git submodule add
:
<repository>
is the URL of the new submodule’s origin repository. This may be either an absolute URL, or (if it begins with ./ or ../), the location relative to the superproject’s default remote repository
This means any path beginning with ./
or ../
should be allowed (even if not existing on local disk, since it may be relative to the default Remote repo). Using a relative path is very common when adding a submodule from the same Remote "root" (like a GitHub organization etc), or even just from a local "sibling" repo (when working without a Remote).
(BTW, a local [bare] repo directory may not always end with .git
so that check could be made more elaborate...)
NOTE: Git does not allow file
protocol URLs (including relative paths) by default (for vulnerability reasons), so it must be explicitly allowed. Therefore, I'd also suggest adding a new checkbox Allow file protocol URL
(or similar) in the Add Submodule
dialog, to insert the protocol.<name>.allow
config like this when adding the submodule:
git -c protocol.file.allow=always submodule add <repo-URL> <path>