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
4 changes: 2 additions & 2 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,8 +1386,8 @@ def _clone(
Git.check_unsafe_protocols(url)
if not allow_unsafe_options:
Git.check_unsafe_options(options=list(kwargs.keys()), unsafe_options=cls.unsafe_git_clone_options)
if not allow_unsafe_options and multi_options:
Git.check_unsafe_options(options=multi_options, unsafe_options=cls.unsafe_git_clone_options)
if not allow_unsafe_options and multi:
Git.check_unsafe_options(options=multi, unsafe_options=cls.unsafe_git_clone_options)

proc = git.clone(
multi,
Expand Down
18 changes: 18 additions & 0 deletions test/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ def test_clone_unsafe_options(self, rw_repo):
rw_repo.clone(tmp_dir, **unsafe_option)
assert not tmp_file.exists()

@with_rw_repo("HEAD")
def test_clone_unsafe_options_are_checked_after_splitting_multi_options(self, rw_repo):
with tempfile.TemporaryDirectory() as tdir:
tmp_dir = pathlib.Path(tdir)
payload = "--single-branch --config protocol.ext.allow=always"

with self.assertRaises(UnsafeOptionError):
rw_repo.clone(tmp_dir, multi_options=[payload])

@pytest.mark.xfail(
sys.platform == "win32",
reason=(
Expand Down Expand Up @@ -216,6 +225,15 @@ def test_clone_from_unsafe_options(self, rw_repo):
Repo.clone_from(rw_repo.working_dir, tmp_dir, **unsafe_option)
assert not tmp_file.exists()

@with_rw_repo("HEAD")
def test_clone_from_unsafe_options_are_checked_after_splitting_multi_options(self, rw_repo):
with tempfile.TemporaryDirectory() as tdir:
tmp_dir = pathlib.Path(tdir)
payload = "--single-branch --config protocol.ext.allow=always"

with self.assertRaises(UnsafeOptionError):
Repo.clone_from(rw_repo.working_dir, tmp_dir, multi_options=[payload])

@pytest.mark.xfail(
sys.platform == "win32",
reason=(
Expand Down
11 changes: 11 additions & 0 deletions test/test_submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,17 @@ def test_submodule_update_unsafe_options(self, rw_repo):
submodule.update(clone_multi_options=[unsafe_option])
assert not tmp_file.exists()

@with_rw_repo("HEAD")
def test_submodule_update_unsafe_options_are_checked_after_splitting_multi_options(self, rw_repo):
with tempfile.TemporaryDirectory() as tdir:
tmp_dir = Path(tdir)
payload = "--single-branch --config protocol.ext.allow=always"
submodule = Submodule(rw_repo, b"\0" * 20, name="new", path="new", url=str(tmp_dir))

with self.assertRaises(UnsafeOptionError):
submodule.update(clone_multi_options=[payload])
assert not submodule.module_exists()

@with_rw_repo("HEAD")
def test_submodule_update_unsafe_options_allowed(self, rw_repo):
with tempfile.TemporaryDirectory() as tdir:
Expand Down
Loading