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
10 changes: 10 additions & 0 deletions git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import ntpath
import os
import os.path as osp
import shlex
import stat
import sys
import uuid
Expand Down Expand Up @@ -363,6 +364,15 @@ def _clone_repo(
module_abspath = cls._module_abspath(repo, path, name)
module_checkout_path = module_abspath
if cls._need_gitfile_submodules(repo.git):
if not allow_unsafe_options:
Git.check_unsafe_options(Git._option_candidates([], kwargs), repo.unsafe_git_clone_options)
multi_options = kwargs.get("multi_options")
if multi_options:
Git.check_unsafe_options(
shlex.split(" ".join(cast("Sequence[str]", multi_options))),
repo.unsafe_git_clone_options,
)
allow_unsafe_options = True
kwargs["separate_git_dir"] = module_abspath
module_abspath_dir = osp.dirname(module_abspath)
if not osp.isdir(module_abspath_dir):
Expand Down
2 changes: 2 additions & 0 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ class Repo:
"-c",
# Can install hooks that execute during clone:
"--template",
# Redirects the repository metadata to a caller-controlled path:
"--separate-git-dir",
# Fetches from an additional caller-controlled URI:
Comment thread
Byron marked this conversation as resolved.
"--bundle-uri",
]
Expand Down
4 changes: 4 additions & 0 deletions test/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def test_clone_unsafe_options(self, rw_repo):
"-vcprotocol.ext.allow=always",
f"--template={tmp_dir}",
f"--bundle-uri=file://{tmp_dir}",
f"--separate-git-dir={tmp_dir / 'git-dir'}",
]
Comment thread
Byron marked this conversation as resolved.
for unsafe_option in unsafe_options:
with self.assertRaises(UnsafeOptionError):
Expand All @@ -149,6 +150,7 @@ def test_clone_unsafe_options(self, rw_repo):
{"c": "protocol.ext.allow=always"},
{"template": tmp_dir},
{"bundle_uri": f"file://{tmp_dir}"},
{"separate_git_dir": tmp_dir / "git-dir"},
]
for unsafe_option in unsafe_options:
with self.assertRaises(UnsafeOptionError):
Expand Down Expand Up @@ -258,6 +260,7 @@ def test_clone_from_unsafe_options(self, rw_repo):
"-c protocol.ext.allow=always",
"-cprotocol.ext.allow=always",
"-vcprotocol.ext.allow=always",
f"--separate-git-dir={tmp_dir / 'git-dir'}",
]
for unsafe_option in unsafe_options:
with self.assertRaises(UnsafeOptionError):
Expand All @@ -270,6 +273,7 @@ def test_clone_from_unsafe_options(self, rw_repo):
{"u": f"touch {tmp_file}"},
{"config": "protocol.ext.allow=always"},
{"c": "protocol.ext.allow=always"},
{"separate_git_dir": tmp_dir / "git-dir"},
]
for unsafe_option in unsafe_options:
with self.assertRaises(UnsafeOptionError):
Expand Down
1 change: 1 addition & 0 deletions test/test_submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,7 @@ def test_update_rejects_parent_component_in_name(self, rwdir):
source.working_tree_dir,
osp.join(clone.working_tree_dir, "module"),
separate_git_dir=osp.join(rwdir, "escaped", "module"),
allow_unsafe_options=True,
)
with pytest.raises(ValueError, match="submodule name"):
clone.submodules[0].update(init=True)
Expand Down
Loading