Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ def _clone_repo(
os.makedirs(module_abspath_dir)
module_checkout_path = osp.join(str(repo.working_tree_dir), path)

if url.startswith("../"):
remote_name = repo.active_branch.tracking_branch().remote_name
repo_remote_url = repo.remote(remote_name).url
url = os.path.join(repo_remote_url, url)

clone = git.Repo.clone_from(
url,
module_checkout_path,
Expand Down
16 changes: 16 additions & 0 deletions test/test_submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,22 @@ def test_add_empty_repo(self, rwdir):
)
# END for each checkout mode

@with_rw_directory
@_patch_git_config("protocol.file.allow", "always")
def test_update_submodule_with_relative_path(self, rwdir):
repo_path = osp.join(rwdir, "parent")
repo = git.Repo.init(repo_path)
module_repo_path = osp.join(rwdir, "module")
module_repo = git.Repo.init(module_repo_path)
module_repo.git.commit(m="test", allow_empty=True)
repo.git.submodule("add", "../module", "module")
repo.index.commit("add submodule")

cloned_repo_path = osp.join(rwdir, "cloned_repo")
cloned_repo = git.Repo.clone_from(repo_path, cloned_repo_path)

cloned_repo.submodule_update(init=True, recursive=True)

@with_rw_directory
@_patch_git_config("protocol.file.allow", "always")
def test_list_only_valid_submodules(self, rwdir):
Expand Down
Loading